Compare commits
3
Commits
v0.1.1
...
5cd6d90555
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cd6d90555 | ||
|
|
dc99779885 | ||
|
|
47ef86293d |
No files matched your search
@@ -36,6 +36,8 @@ A terminal UI for finding, reading and sharing secrets. Inspired by the fantasti
|
|||||||
On macOS or Linux (arm64 or x86_64):
|
On macOS or Linux (arm64 or x86_64):
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/karleinarb/lazysecrets/main/install.sh | sh
|
||||||
|
# Or
|
||||||
curl -fsSL https://git.kebcloud.no/keb/lazysecrets/raw/branch/main/install.sh | sh
|
curl -fsSL https://git.kebcloud.no/keb/lazysecrets/raw/branch/main/install.sh | sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ Flags:
|
|||||||
if start == "" {
|
if start == "" {
|
||||||
start, _ = os.Getwd()
|
start, _ = os.Getwd()
|
||||||
}
|
}
|
||||||
roots := []string{"~/git"}
|
roots := repo.DefaultRoots
|
||||||
if pc.Repos.Roots != nil {
|
if pc.Repos.Roots != nil {
|
||||||
roots = *pc.Repos.Roots
|
roots = *pc.Repos.Roots
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -7,10 +7,11 @@ lazysecrets shows git repositories under **Repos**: their
|
|||||||
|
|
||||||
## Which repos
|
## Which repos
|
||||||
|
|
||||||
**Repos** lists every repo with secret files under the `roots` (`~/git`
|
**Repos** lists every repo with secret files under the `roots` (by
|
||||||
by default; one or two levels down, `repo` or `org/repo`), any listed in
|
default whichever of `~/git`, `~/repo`, `~/repos`, `~/projects`, `~/code`,
|
||||||
`paths`, and any you starred something in (the repo, a file or a key),
|
`~/source` and `~/src` exist; one or two levels down, `repo` or
|
||||||
wherever it is. They're checked in the background.
|
`org/repo`), any listed in `paths`, and any you starred something in
|
||||||
|
(the repo, a file or a key), wherever it is. They're checked in the background.
|
||||||
|
|
||||||
Started inside a repo, that repo gets a row of its own at the top,
|
Started inside a repo, that repo gets a row of its own at the top,
|
||||||
`Repo · <name>`, and lazysecrets opens on it, with the files under the
|
`Repo · <name>`, and lazysecrets opens on it, with the files under the
|
||||||
@@ -49,7 +50,7 @@ Folders of dependencies and caches are never looked in, tracked or not:
|
|||||||
```yaml
|
```yaml
|
||||||
providers:
|
providers:
|
||||||
repos:
|
repos:
|
||||||
roots: [~/git] # folders of repos (the default; [] turns it off)
|
roots: [~/git] # folders of repos (replaces the defaults; [] turns it off)
|
||||||
paths: [~/work/infra] # single repos elsewhere
|
paths: [~/work/infra] # single repos elsewhere
|
||||||
include: ["secrets/**", "**/*.sops.yaml"] # globs from the repo root; ** for any depth
|
include: ["secrets/**", "**/*.sops.yaml"] # globs from the repo root; ** for any depth
|
||||||
exclude: ["**/testdata/**"]
|
exclude: ["**/testdata/**"]
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ require (
|
|||||||
github.com/atotto/clipboard v0.1.4
|
github.com/atotto/clipboard v0.1.4
|
||||||
github.com/charmbracelet/x/ansi v0.11.9
|
github.com/charmbracelet/x/ansi v0.11.9
|
||||||
github.com/charmbracelet/x/exp/golden v0.0.0-20251109135125-8916d276318f
|
github.com/charmbracelet/x/exp/golden v0.0.0-20251109135125-8916d276318f
|
||||||
github.com/databricks/databricks-sdk-go v0.187.0
|
github.com/databricks/databricks-sdk-go v0.188.0
|
||||||
github.com/junegunn/fzf v0.74.4
|
github.com/junegunn/fzf v0.74.5
|
||||||
go.yaml.in/yaml/v3 v3.0.5
|
go.yaml.in/yaml/v3 v3.0.5
|
||||||
golang.org/x/mod v0.42.0
|
golang.org/x/mod v0.42.0
|
||||||
golang.org/x/term v0.47.0
|
golang.org/x/term v0.47.0
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ github.com/clipperhouse/displaywidth v0.11.0 h1:lBc6kY44VFw+TDx4I8opi/EtL9m20WSE
|
|||||||
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
github.com/clipperhouse/displaywidth v0.11.0/go.mod h1:bkrFNkf81G8HyVqmKGxsPufD3JhNl3dSqnGhOoSD/o0=
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
github.com/clipperhouse/uax29/v2 v2.7.0 h1:+gs4oBZ2gPfVrKPthwbMzWZDaAFPGYK72F0NJv2v7Vk=
|
||||||
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
github.com/clipperhouse/uax29/v2 v2.7.0/go.mod h1:EFJ2TJMRUaplDxHKj1qAEhCtQPW2tJSwu5BF98AuoVM=
|
||||||
github.com/databricks/databricks-sdk-go v0.187.0 h1:V1rGbEUaEdGS7tTZSyplDLnE2Vp5N1aIPiIh/LzjOC8=
|
github.com/databricks/databricks-sdk-go v0.188.0 h1:1nxBqlctGnPzlReyziG199abHs9cR/KNjsCnSM+oDGA=
|
||||||
github.com/databricks/databricks-sdk-go v0.187.0/go.mod h1:udBw6nxkaqa0fgPQ7ZW1kGFkltQncYx+qFJeVFmxtz8=
|
github.com/databricks/databricks-sdk-go v0.188.0/go.mod h1:udBw6nxkaqa0fgPQ7ZW1kGFkltQncYx+qFJeVFmxtz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
|
||||||
@@ -100,8 +100,8 @@ github.com/googleapis/enterprise-certificate-proxy v0.3.11 h1:vAe81Msw+8tKUxi2Dq
|
|||||||
github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=
|
github.com/googleapis/enterprise-certificate-proxy v0.3.11/go.mod h1:RFV7MUdlb7AgEq2v7FmMCfeSMCllAzWxFgRdusoGks8=
|
||||||
github.com/googleapis/gax-go/v2 v2.17.0 h1:RksgfBpxqff0EZkDWYuz9q/uWsTVz+kf43LsZ1J6SMc=
|
github.com/googleapis/gax-go/v2 v2.17.0 h1:RksgfBpxqff0EZkDWYuz9q/uWsTVz+kf43LsZ1J6SMc=
|
||||||
github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY=
|
github.com/googleapis/gax-go/v2 v2.17.0/go.mod h1:mzaqghpQp4JDh3HvADwrat+6M3MOIDp5YKHhb9PAgDY=
|
||||||
github.com/junegunn/fzf v0.74.4 h1:DSqIW3ZxtkuuPzeLKrVnHdoWqT9VCIGRbjc/lXiGCso=
|
github.com/junegunn/fzf v0.74.5 h1:mpJlCdgGuddKerHrdjvV3cnezEBgyjZAVn8KCo/4OMc=
|
||||||
github.com/junegunn/fzf v0.74.4/go.mod h1:TBRY54j3mGjAm4JcpDyiUIuDq38QlHvAzrB3GLKxQXM=
|
github.com/junegunn/fzf v0.74.5/go.mod h1:TBRY54j3mGjAm4JcpDyiUIuDq38QlHvAzrB3GLKxQXM=
|
||||||
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741 h1:7dYDtfMDfKzjT+DVfIS4iqknSEKtZpEcXtu6vuaasHs=
|
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741 h1:7dYDtfMDfKzjT+DVfIS4iqknSEKtZpEcXtu6vuaasHs=
|
||||||
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741/go.mod h1:6EILKtGpo5t+KLb85LNZLAF6P9LKp78hJI80PXMcn3c=
|
github.com/junegunn/go-shellwords v0.0.0-20250127100254-2aa3b3277741/go.mod h1:6EILKtGpo5t+KLb85LNZLAF6P9LKp78hJI80PXMcn3c=
|
||||||
github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=
|
github.com/keybase/go-keychain v0.0.1 h1:way+bWYa6lDppZoZcgMbYsvC7GxljxrskdNInRtuthU=
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ type Repos struct {
|
|||||||
// Enabled defaults to true.
|
// Enabled defaults to true.
|
||||||
Enabled *bool `yaml:"enabled"`
|
Enabled *bool `yaml:"enabled"`
|
||||||
Paths []string `yaml:"paths"`
|
Paths []string `yaml:"paths"`
|
||||||
// Roots are folders of repos. Defaults to ~/git; an empty list
|
// Roots are folders of repos. Defaults to repo.DefaultRoots (~/git,
|
||||||
// turns it off.
|
// ~/src, ~/code and the like); an empty list turns it off.
|
||||||
Roots *[]string `yaml:"roots"`
|
Roots *[]string `yaml:"roots"`
|
||||||
// Include and Exclude are globs relative to a repo's root (** for any
|
// Include and Exclude are globs relative to a repo's root (** for any
|
||||||
// depth), for repos without their own .lazysecrets.yaml. Without them,
|
// depth), for repos without their own .lazysecrets.yaml. Without them,
|
||||||
|
|||||||
@@ -80,6 +80,10 @@ type repoInfo struct {
|
|||||||
here bool // the repo lazysecrets started in
|
here bool // the repo lazysecrets started in
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// DefaultRoots are the usual folders of repos, used when the config
|
||||||
|
// doesn't set roots. Ones that don't exist cost a stat each.
|
||||||
|
var DefaultRoots = []string{"~/git", "~/repo", "~/repos", "~/projects", "~/code", "~/source", "~/src"}
|
||||||
|
|
||||||
func New(s Settings) *Provider {
|
func New(s Settings) *Provider {
|
||||||
if s.Sops == "" {
|
if s.Sops == "" {
|
||||||
s.Sops = "sops"
|
s.Sops = "sops"
|
||||||
@@ -116,10 +120,18 @@ func (p *Provider) load() {
|
|||||||
}
|
}
|
||||||
add(root)
|
add(root)
|
||||||
}
|
}
|
||||||
|
// Missing roots are skipped (most of the defaults are), and one
|
||||||
|
// that's a symlink to another is scanned once.
|
||||||
|
scanned := map[string]bool{}
|
||||||
for _, dir := range p.s.Roots {
|
for _, dir := range p.s.Roots {
|
||||||
base, _ := filepath.EvalSymlinks(expandHome(dir))
|
base, err := filepath.EvalSymlinks(expandHome(dir))
|
||||||
for _, root := range reposIn(expandHome(dir), 2) {
|
if err != nil || scanned[base] {
|
||||||
if name, err := filepath.Rel(base, root); err == nil && !strings.HasPrefix(name, "..") {
|
continue
|
||||||
|
}
|
||||||
|
scanned[base] = true
|
||||||
|
for _, root := range reposIn(base, 2) {
|
||||||
|
// A repo under two roots keeps the first one's name.
|
||||||
|
if name, err := filepath.Rel(base, root); err == nil && !strings.HasPrefix(name, "..") && names[root] == "" {
|
||||||
names[root] = filepath.ToSlash(name)
|
names[root] = filepath.ToSlash(name)
|
||||||
}
|
}
|
||||||
add(root)
|
add(root)
|
||||||
|
|||||||
@@ -336,6 +336,30 @@ func TestRoots(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRootsDeduped(t *testing.T) {
|
||||||
|
root, _ := filepath.EvalSymlinks(t.TempDir())
|
||||||
|
os.Rename(gitRepo(t, map[string]string{"secrets/a.yaml": sopsYAML}), filepath.Join(root, "infra"))
|
||||||
|
os.MkdirAll(filepath.Join(root, "acme"), 0o755)
|
||||||
|
os.Rename(gitRepo(t, map[string]string{"prod.env": sopsEnv}), filepath.Join(root, "acme", "billing"))
|
||||||
|
|
||||||
|
// ~/src → ~/git, and a root reaching one repo at another depth.
|
||||||
|
links := t.TempDir()
|
||||||
|
alias := filepath.Join(links, "src")
|
||||||
|
os.Symlink(root, alias)
|
||||||
|
missing := filepath.Join(links, "nope")
|
||||||
|
acme := filepath.Join(root, "acme")
|
||||||
|
|
||||||
|
srcs, err := New(Settings{Dir: links, Roots: []string{missing, root, alias, acme}}).Sources(context.Background())
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got := names(srcs, func(s provider.Source) string { return s.Name })
|
||||||
|
slices.Sort(got)
|
||||||
|
if !slices.Equal(got, []string{"acme/billing", "infra"}) {
|
||||||
|
t.Errorf("repos: %v, want each once, named from the first root", got)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestStarredReposAlongside(t *testing.T) {
|
func TestStarredReposAlongside(t *testing.T) {
|
||||||
here := gitRepo(t, map[string]string{"secrets/a.yaml": sopsYAML})
|
here := gitRepo(t, map[string]string{"secrets/a.yaml": sopsYAML})
|
||||||
starred := gitRepo(t, map[string]string{"prod.env": sopsEnv})
|
starred := gitRepo(t, map[string]string{"prod.env": sopsEnv})
|
||||||
|
|||||||
Reference in new issue
Block a user