Skip to content

Commit

Permalink
cleanup getStore()
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Fuentes committed Aug 2, 2018
1 parent 67ef9eb commit ff5fb8f
Showing 1 changed file with 8 additions and 25 deletions.
33 changes: 8 additions & 25 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,16 @@ func validateKey(key string) error {
}

func getSecretStore() store.Store {
backend, ok := os.LookupEnv(BackendEnvVar)
if !ok {
backend = SSMBackend
}

backend = strings.ToUpper(backend)
if !stringInSlice(backend, Backends) {
// TODO: warn user
backend = SSMBackend
}
backend := strings.ToUpper(os.Getenv(BackendEnvVar))

var s store.Store
switch backend {
case SSMBackend:
return store.NewSSMStore(numRetries)
case S3Backend:
return store.NewS3Store(numRetries)
}

// This line is unreachable, but necessary to satisfy the compiler
panic("unreachable")
}

func stringInSlice(v string, sl []string) bool {
for _, val := range sl {
if v == val {
return true
}
s = store.NewS3Store(numRetries)
case SSMBackend:
fallthrough
default:
s = store.NewSSMStore(numRetries)
}
return false
return s
}

0 comments on commit ff5fb8f

Please sign in to comment.