feat: lazysecrets list prints everything lazysecrets can find, for fzf and editor pickers #70
No files matched your search
@@ -51,6 +51,11 @@ type Entry struct {
|
|||||||
Enabled *bool `json:"enabled,omitempty"`
|
Enabled *bool `json:"enabled,omitempty"`
|
||||||
// Note is the user's note on it, if any.
|
// Note is the user's note on it, if any.
|
||||||
Note string `json:"note,omitempty"`
|
Note string `json:"note,omitempty"`
|
||||||
|
// Reference is how config refers to a secret, where the provider has
|
||||||
|
// a way (@Microsoft.KeyVault(...), {{secrets/scope/key}}); URL its
|
||||||
|
// web page (portal, workspace), if any.
|
||||||
|
Reference string `json:"reference,omitempty"`
|
||||||
|
URL string `json:"url,omitempty"`
|
||||||
// Error says why a source's vaults or a vault's secrets couldn't be
|
// Error says why a source's vaults or a vault's secrets couldn't be
|
||||||
// listed. The entry is then that source or vault, again, or with an
|
// listed. The entry is then that source or vault, again, or with an
|
||||||
// account's sources unreadable, the account without a link.
|
// account's sources unreadable, the account without a link.
|
||||||
@@ -207,12 +212,12 @@ func (l *lister) objects(p provider.Provider, c provider.Container, objs []provi
|
|||||||
}
|
}
|
||||||
l.put(p, Entry{Link: r.String(), Kind: strings.ToLower(string(o.Type)), Provider: kindOf(c.Source.Kind),
|
l.put(p, Entry{Link: r.String(), Kind: strings.ToLower(string(o.Type)), Provider: kindOf(c.Source.Kind),
|
||||||
Path: []string{c.Source.Name, c.Name, o.Name}, AccountLabel: accountOf(c.Source),
|
Path: []string{c.Source.Name, c.Name, o.Name}, AccountLabel: accountOf(c.Source),
|
||||||
Expires: o.Expires, Enabled: o.Enabled})
|
Expires: o.Expires, Enabled: o.Enabled, Reference: o.Reference, URL: o.URL})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func sourceEntry(src provider.Source) Entry {
|
func sourceEntry(src provider.Source) Entry {
|
||||||
e := Entry{Kind: "source", Provider: kindOf(src.Kind), Path: []string{src.Name}, AccountLabel: accountOf(src)}
|
e := Entry{Kind: "source", Provider: kindOf(src.Kind), Path: []string{src.Name}, AccountLabel: accountOf(src), URL: src.URL}
|
||||||
if r, err := ref.ForSource(src); err == nil {
|
if r, err := ref.ForSource(src); err == nil {
|
||||||
e.Link = r.String()
|
e.Link = r.String()
|
||||||
}
|
}
|
||||||
@@ -220,7 +225,7 @@ func sourceEntry(src provider.Source) Entry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func containerEntry(c provider.Container) Entry {
|
func containerEntry(c provider.Container) Entry {
|
||||||
e := Entry{Kind: "vault", Provider: kindOf(c.Source.Kind), Path: []string{c.Source.Name, c.Name}, AccountLabel: accountOf(c.Source)}
|
e := Entry{Kind: "vault", Provider: kindOf(c.Source.Kind), Path: []string{c.Source.Name, c.Name}, AccountLabel: accountOf(c.Source), URL: c.URL}
|
||||||
if r, err := ref.ForContainer(c, provider.TypeSecret); err == nil {
|
if r, err := ref.ForContainer(c, provider.TypeSecret); err == nil {
|
||||||
e.Link = r.String()
|
e.Link = r.String()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ func TestListLoadsAndCaches(t *testing.T) {
|
|||||||
t.Errorf("provider %q", e.Provider)
|
t.Errorf("provider %q", e.Provider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, e := range got {
|
||||||
|
if e.Kind == "secret" && e.Provider == "azure" && (!strings.HasPrefix(e.Reference, "@Microsoft.KeyVault(") || e.URL == "") {
|
||||||
|
t.Errorf("%s: reference %q, url %q", e.Link, e.Reference, e.URL)
|
||||||
|
}
|
||||||
|
}
|
||||||
if len(f.Sources) != 1 || len(f.Containers) == 0 || len(f.Objects) == 0 {
|
if len(f.Sources) != 1 || len(f.Containers) == 0 || len(f.Objects) == 0 {
|
||||||
t.Errorf("not cached: %d sources, %d containers, %d objects", len(f.Sources), len(f.Containers), len(f.Objects))
|
t.Errorf("not cached: %d sources, %d containers, %d objects", len(f.Sources), len(f.Containers), len(f.Objects))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user