Skip to content

Commit

Permalink
Check if GOOGLE_APPLICATION_CREDENTIALS is set in the environment
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaszone committed Jan 26, 2021
1 parent 9961cb0 commit a3a00a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@

# Dependency directories (remove the comment below to include it)
# vendor/

release/
8 changes: 8 additions & 0 deletions cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ THE SOFTWARE.
package cmd

import (
"fmt"
"github.com/spf13/cobra"
reader "github.com/yamaszone/gcp-secret-manager-buddy/internal"
"os"
)

var getCmd = &cobra.Command{
Expand Down Expand Up @@ -58,6 +60,12 @@ func init() {
}

func getSecrets(cmd *cobra.Command, args []string) error {
_, present := os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS")
if !present {
fmt.Println("Error: GOOGLE_APPLICATION_CREDENTIALS not set in the environment.")
os.Exit(1)
}

inputFile, err := cmd.Flags().GetString("input")
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0m
github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I=
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
Expand Down

0 comments on commit a3a00a9

Please sign in to comment.