From 5a479e600e28905e81435c7b8f5f9b31d327060c Mon Sep 17 00:00:00 2001 From: caozhiyuan Date: Wed, 14 Apr 2021 20:19:41 +0800 Subject: [PATCH] fix hardcoding and format error log Kubernetes-commit: c468a02718402bf42ffc0cd8cdbdf805fdf903a2 --- pkg/storage/storagebackend/config.go | 1 + pkg/storage/storagebackend/factory/factory.go | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkg/storage/storagebackend/config.go b/pkg/storage/storagebackend/config.go index 500e55c02..45f0d6f4a 100644 --- a/pkg/storage/storagebackend/config.go +++ b/pkg/storage/storagebackend/config.go @@ -27,6 +27,7 @@ import ( const ( StorageTypeUnset = "" + StorageTypeETCD2 = "etcd2" StorageTypeETCD3 = "etcd3" DefaultCompactInterval = 5 * time.Minute diff --git a/pkg/storage/storagebackend/factory/factory.go b/pkg/storage/storagebackend/factory/factory.go index 1e8a8cdb0..fb1e2d289 100644 --- a/pkg/storage/storagebackend/factory/factory.go +++ b/pkg/storage/storagebackend/factory/factory.go @@ -30,8 +30,8 @@ type DestroyFunc func() // Create creates a storage backend based on given config. func Create(c storagebackend.Config, newFunc func() runtime.Object) (storage.Interface, DestroyFunc, error) { switch c.Type { - case "etcd2": - return nil, nil, fmt.Errorf("%v is no longer a supported storage backend", c.Type) + case storagebackend.StorageTypeETCD2: + return nil, nil, fmt.Errorf("%s is no longer a supported storage backend", c.Type) case storagebackend.StorageTypeUnset, storagebackend.StorageTypeETCD3: return newETCD3Storage(c, newFunc) default: @@ -42,8 +42,8 @@ func Create(c storagebackend.Config, newFunc func() runtime.Object) (storage.Int // CreateHealthCheck creates a healthcheck function based on given config. func CreateHealthCheck(c storagebackend.Config) (func() error, error) { switch c.Type { - case "etcd2": - return nil, fmt.Errorf("%v is no longer a supported storage backend", c.Type) + case storagebackend.StorageTypeETCD2: + return nil, fmt.Errorf("%s is no longer a supported storage backend", c.Type) case storagebackend.StorageTypeUnset, storagebackend.StorageTypeETCD3: return newETCD3HealthCheck(c) default: