Skip to content

Commit

Permalink
avoiding the dependency of vault command over profile existence
Browse files Browse the repository at this point in the history
  • Loading branch information
shibme committed Mar 1, 2024
1 parent b1d9262 commit 8705a8b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 18 deletions.
25 changes: 10 additions & 15 deletions cli/internal/commands/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,21 @@ func vaultInfoCommand() *cobra.Command {
if err != nil {
exitOnError(err)
}
profile, err := profiles.GetDefaultProfile()
if err != nil {
exitOnError(err)
}
profile, _ := profiles.GetDefaultProfile()
envMap := make(map[string]string, len(accessors))
for _, accessor := range accessors {
var env *environments.Environment
envId := accessor.String()
env, err := profile.GetEnv(envId)
if err != nil {
exitOnError(err)
if profile != nil {
env, err = profile.GetEnv(envId)
if err != nil {
exitOnError(err)
}
}
if env != nil {
envMap[envId] = env.Name
envMap[envId] = envId + "\t(" + env.Name + ")"
} else {
envMap[envId] = ""
envMap[envId] = envId
}
}
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.TabIndent)
Expand All @@ -115,12 +114,8 @@ func vaultInfoCommand() *cobra.Command {
}
}
fmt.Fprintln(w, "Accessible by:")
for envId, envName := range envMap {
if envName == "" {
fmt.Fprintln(w, " -", envId)
} else {
fmt.Fprintln(w, " -", envId, "\t(", envName, ")")
}
for _, envDesc := range envMap {
fmt.Fprintln(w, " -", envDesc)
}
w.Flush()
safeExit()
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module savesecrets.org/slv
go 1.21

require (
dev.shib.me/xipher v0.9.0
dev.shib.me/xipher v0.9.1
github.com/aws/aws-sdk-go v1.50.29
github.com/fatih/color v1.16.0
github.com/go-git/go-git/v5 v5.11.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ cloud.google.com/go/kms v1.15.7 h1:7caV9K3yIxvlQPAcaFffhlT7d1qpxjB1wHBtjWa13SM=
cloud.google.com/go/kms v1.15.7/go.mod h1:ub54lbsa6tDkUwnu4W7Yt1aAIFLnspgh0kPGToDukeI=
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
dev.shib.me/xipher v0.9.0 h1:0F8TQLnrP+Ulnp9zMoEY+kZs7IP7pIC/dBZIGxOxJi8=
dev.shib.me/xipher v0.9.0/go.mod h1:z3dJVgTIoA1Y4rhoD2DeimISTLiVheABWWLQ8VOJE0w=
dev.shib.me/xipher v0.9.1 h1:kB67xHE2W/RjyuVp+xVWEudqgFaJ0nIc7UzVK3WV9aI=
dev.shib.me/xipher v0.9.1/go.mod h1:z3dJVgTIoA1Y4rhoD2DeimISTLiVheABWWLQ8VOJE0w=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
Expand Down

0 comments on commit 8705a8b

Please sign in to comment.