Modify to upper case variable name from lower case for unit tests

This commit is contained in:
bells17
2020-02-20 23:13:12 +09:00
parent dd390a3e38
commit 8e9680affd
3 changed files with 24 additions and 24 deletions

View File

@@ -62,10 +62,10 @@ var class5Parameters = map[string]string{
}
var class6Parameters = map[string]string{
"csi.storage.k8s.io/snapshotter-secret-name": "secret",
"csi.storage.k8s.io/snapshotter-secret-namespace": "default",
"csi.storage.k8s.io/snapshotter-list-secret-name": "secret",
"csi.storage.k8s.io/snapshotter-list-secret-namespace": "default",
utils.PrefixedSnapshotterSecretNameKey: "secret",
utils.PrefixedSnapshotterSecretNamespaceKey: "default",
utils.PrefixedSnapshotterListSecretNameKey: "secret",
utils.PrefixedSnapshotterListSecretNamespaceKey: "default",
}
var snapshotClasses = []*crdv1.VolumeSnapshotClass{

View File

@@ -53,11 +53,11 @@ const (
// fields in subsequent CSI calls or Kubernetes API objects.
csiParameterPrefix = "csi.storage.k8s.io/"
prefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
prefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
PrefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
PrefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
prefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
prefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
PrefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
PrefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
// Name of finalizer on VolumeSnapshotContents that are bound by VolumeSnapshots
VolumeSnapshotContentFinalizer = "snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection"
@@ -86,14 +86,14 @@ const (
var SnapshotterSecretParams = secretParamsMap{
name: "Snapshotter",
secretNameKey: prefixedSnapshotterSecretNameKey,
secretNamespaceKey: prefixedSnapshotterSecretNamespaceKey,
secretNameKey: PrefixedSnapshotterSecretNameKey,
secretNamespaceKey: PrefixedSnapshotterSecretNamespaceKey,
}
var SnapshotterListSecretParams = secretParamsMap{
name: "SnapshotterList",
secretNameKey: prefixedSnapshotterListSecretNameKey,
secretNamespaceKey: prefixedSnapshotterListSecretNamespaceKey,
secretNameKey: PrefixedSnapshotterListSecretNameKey,
secretNamespaceKey: PrefixedSnapshotterListSecretNamespaceKey,
}
func SnapshotKey(vs *crdv1.VolumeSnapshot) string {
@@ -366,10 +366,10 @@ func RemovePrefixedParameters(param map[string]string) (map[string]string, error
if strings.HasPrefix(k, csiParameterPrefix) {
// Check if its well known
switch k {
case prefixedSnapshotterSecretNameKey:
case prefixedSnapshotterSecretNamespaceKey:
case prefixedSnapshotterListSecretNameKey:
case prefixedSnapshotterListSecretNamespaceKey:
case PrefixedSnapshotterSecretNameKey:
case PrefixedSnapshotterSecretNamespaceKey:
case PrefixedSnapshotterListSecretNameKey:
case PrefixedSnapshotterListSecretNamespaceKey:
default:
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
}

View File

@@ -41,18 +41,18 @@ func TestGetSecretReference(t *testing.T) {
},
"namespace, no name": {
secretParams: SnapshotterSecretParams,
params: map[string]string{prefixedSnapshotterSecretNamespaceKey: "foo"},
params: map[string]string{PrefixedSnapshotterSecretNamespaceKey: "foo"},
expectErr: true,
},
"simple - valid": {
secretParams: SnapshotterSecretParams,
params: map[string]string{prefixedSnapshotterSecretNameKey: "name", prefixedSnapshotterSecretNamespaceKey: "ns"},
params: map[string]string{PrefixedSnapshotterSecretNameKey: "name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
snapshot: &crdv1.VolumeSnapshot{},
expectRef: &v1.SecretReference{Name: "name", Namespace: "ns"},
},
"simple - invalid name": {
secretParams: SnapshotterSecretParams,
params: map[string]string{prefixedSnapshotterSecretNameKey: "bad name", prefixedSnapshotterSecretNamespaceKey: "ns"},
params: map[string]string{PrefixedSnapshotterSecretNameKey: "bad name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
snapshot: &crdv1.VolumeSnapshot{},
expectRef: nil,
expectErr: true,
@@ -60,8 +60,8 @@ func TestGetSecretReference(t *testing.T) {
"template - invalid": {
secretParams: SnapshotterSecretParams,
params: map[string]string{
prefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
prefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
PrefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
PrefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
},
snapContentName: "snapcontentname",
snapshot: &crdv1.VolumeSnapshot{
@@ -111,14 +111,14 @@ func TestRemovePrefixedCSIParams(t *testing.T) {
},
{
name: "one prefixed",
params: map[string]string{prefixedSnapshotterSecretNameKey: "bar", "bim": "baz"},
params: map[string]string{PrefixedSnapshotterSecretNameKey: "bar", "bim": "baz"},
expectedParams: map[string]string{"bim": "baz"},
},
{
name: "all known prefixed",
params: map[string]string{
prefixedSnapshotterSecretNameKey: "csiBar",
prefixedSnapshotterSecretNamespaceKey: "csiBar",
PrefixedSnapshotterSecretNameKey: "csiBar",
PrefixedSnapshotterSecretNamespaceKey: "csiBar",
},
expectedParams: map[string]string{},
},