diff --git a/docs/core-concepts/stateconfig.md b/docs/core-concepts/stateconfig.md index c5c0c3c91..05b162819 100644 --- a/docs/core-concepts/stateconfig.md +++ b/docs/core-concepts/stateconfig.md @@ -34,7 +34,7 @@ state: backend: k8s options: namespace: devstream # optional, default is "devstream", will be created if not exists - configmap: devstream-state # optional, default is "devstream-state", will be created if not exists + configmap: state # optional, default is "state", will be created if not exists ``` ## S3 Backend diff --git a/internal/pkg/backend/backend.go b/internal/pkg/backend/backend.go index 1100371ec..b94b72aef 100644 --- a/internal/pkg/backend/backend.go +++ b/internal/pkg/backend/backend.go @@ -10,7 +10,7 @@ import ( "github.com/devstream-io/devstream/internal/pkg/configmanager" ) -// Backend is used to persist data, it can be local file/etcd/s3/k8s... +// Backend is used to persist data, it can be local file/s3/k8s... type Backend interface { // Read is used to read data from persistent storage. Read() ([]byte, error) @@ -20,20 +20,15 @@ type Backend interface { // GetBackend will return a Backend by the given name. func GetBackend(state configmanager.State) (Backend, error) { - typeName := types.Type(state.Backend) - switch { - case types.Local == typeName: + typeName := types.Type(strings.ToLower(state.Backend)) + + switch typeName { + case types.Local: return local.NewLocal(state.Options.StateFile) - case types.S3 == typeName: - return s3.NewS3Backend( - state.Options.Bucket, - state.Options.Region, - state.Options.Key) - case strings.ToLower(state.Backend) == types.K8s.String() || - strings.ToLower(state.Backend) == types.K8sAlis.String(): - return k8s.NewBackend( - state.Options.Namespace, - state.Options.ConfigMap) + case types.S3: + return s3.NewS3Backend(state.Options.Bucket, state.Options.Region, state.Options.Key) + case types.K8s, types.K8sAlias: + return k8s.NewBackend(state.Options.Namespace, state.Options.ConfigMap) default: return nil, types.NewInvalidBackendErr(state.Backend) } diff --git a/internal/pkg/backend/k8s/backend.go b/internal/pkg/backend/k8s/backend.go index 51bd5e4b9..72bd90cbf 100644 --- a/internal/pkg/backend/k8s/backend.go +++ b/internal/pkg/backend/k8s/backend.go @@ -9,7 +9,7 @@ import ( const ( defaultNamespace = "devstream" - defaultConfigMapName = "devstream-state" + defaultConfigMapName = "state" stateKey = "state" ) diff --git a/internal/pkg/backend/types/vars.go b/internal/pkg/backend/types/vars.go index cb405af58..f478623ba 100644 --- a/internal/pkg/backend/types/vars.go +++ b/internal/pkg/backend/types/vars.go @@ -7,8 +7,8 @@ func (t Type) String() string { } const ( - Local Type = "local" - S3 Type = "s3" - K8s Type = "k8s" - K8sAlis Type = "kubernetes" + Local Type = "local" + S3 Type = "s3" + K8s Type = "k8s" + K8sAlias Type = "kubernetes" )