Skip to content

Commit

Permalink
Merge pull request #5 from jacobbednarz/handle-keyring-failures
Browse files Browse the repository at this point in the history
exec: exit if the credentials aren't accessible
  • Loading branch information
jacobbednarz committed Sep 17, 2020
2 parents e574eb2 + 19acc15 commit f07f90f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cmd/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,15 @@ var execCmd = &cobra.Command{
log.Fatal("cf-vault sessions shouldn't be nested, unset CLOUDFLARE_VAULT_SESSION to continue or open a new shell session")
}

ring, _ := keyring.Open(keyringDefaults)
keychain, _ := ring.Get(fmt.Sprintf("%s-%s", profileName, profileSection.Key("auth_type").String()))
ring, err := keyring.Open(keyringDefaults)
if err != nil {
log.Fatalf("failed to open keyring backend: %s", strings.ToLower(err.Error()))
}

keychain, err := ring.Get(fmt.Sprintf("%s-%s", profileName, profileSection.Key("auth_type").String()))
if err != nil {
log.Fatalf("failed to get item from keyring: %s", strings.ToLower(err.Error()))
}

cloudflareCreds := []string{
fmt.Sprintf("CLOUDFLARE_VAULT_SESSION=%s", profileName),
Expand Down

0 comments on commit f07f90f

Please sign in to comment.