feat(vault-tui): implement KV client and service for managing secrets
- Added internal/vault/client.go for creating a Vault client with configuration settings. - Introduced internal/vault/errors.go to classify Vault API errors for better UI handling. - Created internal/vault/kv.go to manage KV secrets, including listing, reading, writing, and deleting operations. - Implemented internal/vault/mounts.go to list and describe secret engine mounts. - Developed internal/vault/service.go to provide a unified entry point for Vault operations. - Added internal/vault/kv_test.go for comprehensive testing of KV operations. - Introduced internal/ui/toast.go for transient notifications in the UI. - Added renovate.json for dependency management and updates.
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
)
|
||||
|
||||
func listCommand() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "list secrets under a path (e.g. `vault-tui list secret/team/`)",
|
||||
ArgsUsage: "<path>",
|
||||
Flags: []cli.Flag{&cli.BoolFlag{Name: "json"}},
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
a, err := appFrom(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cmd.Args().Len() == 0 {
|
||||
return fmt.Errorf("usage: vault-tui list <path>")
|
||||
}
|
||||
if _, err := a.EnsureLoggedIn(ctx, cmd.String("token")); err != nil {
|
||||
return err
|
||||
}
|
||||
svc := a.Service()
|
||||
mount, rel, err := splitMountPath(ctx, svc, cmd.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l, err := svc.KV.List(ctx, mount, rel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if cmd.Bool("json") {
|
||||
return printJSON(os.Stdout, l)
|
||||
}
|
||||
for _, d := range l.Dirs {
|
||||
fmt.Println(d)
|
||||
}
|
||||
for _, f := range l.Leaves {
|
||||
fmt.Println(f)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user