diff --git a/cmd/root.go b/cmd/root.go index b75e1256..ba282415 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -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 }