Skip to content

Commit 8e9680a

Browse files
committed
Modify to upper case variable name from lower case for unit tests
1 parent dd390a3 commit 8e9680a

File tree

3 files changed

+24
-24
lines changed

3 files changed

+24
-24
lines changed

pkg/sidecar-controller/snapshot_delete_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ var class5Parameters = map[string]string{
6262
}
6363

6464
var class6Parameters = map[string]string{
65-
"csi.storage.k8s.io/snapshotter-secret-name": "secret",
66-
"csi.storage.k8s.io/snapshotter-secret-namespace": "default",
67-
"csi.storage.k8s.io/snapshotter-list-secret-name": "secret",
68-
"csi.storage.k8s.io/snapshotter-list-secret-namespace": "default",
65+
utils.PrefixedSnapshotterSecretNameKey: "secret",
66+
utils.PrefixedSnapshotterSecretNamespaceKey: "default",
67+
utils.PrefixedSnapshotterListSecretNameKey: "secret",
68+
utils.PrefixedSnapshotterListSecretNamespaceKey: "default",
6969
}
7070

7171
var snapshotClasses = []*crdv1.VolumeSnapshotClass{

pkg/utils/util.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ const (
5353
// fields in subsequent CSI calls or Kubernetes API objects.
5454
csiParameterPrefix = "csi.storage.k8s.io/"
5555

56-
prefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
57-
prefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
56+
PrefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
57+
PrefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
5858

59-
prefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
60-
prefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
59+
PrefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
60+
PrefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
6161

6262
// Name of finalizer on VolumeSnapshotContents that are bound by VolumeSnapshots
6363
VolumeSnapshotContentFinalizer = "snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection"
@@ -86,14 +86,14 @@ const (
8686

8787
var SnapshotterSecretParams = secretParamsMap{
8888
name: "Snapshotter",
89-
secretNameKey: prefixedSnapshotterSecretNameKey,
90-
secretNamespaceKey: prefixedSnapshotterSecretNamespaceKey,
89+
secretNameKey: PrefixedSnapshotterSecretNameKey,
90+
secretNamespaceKey: PrefixedSnapshotterSecretNamespaceKey,
9191
}
9292

9393
var SnapshotterListSecretParams = secretParamsMap{
9494
name: "SnapshotterList",
95-
secretNameKey: prefixedSnapshotterListSecretNameKey,
96-
secretNamespaceKey: prefixedSnapshotterListSecretNamespaceKey,
95+
secretNameKey: PrefixedSnapshotterListSecretNameKey,
96+
secretNamespaceKey: PrefixedSnapshotterListSecretNamespaceKey,
9797
}
9898

9999
func SnapshotKey(vs *crdv1.VolumeSnapshot) string {
@@ -366,10 +366,10 @@ func RemovePrefixedParameters(param map[string]string) (map[string]string, error
366366
if strings.HasPrefix(k, csiParameterPrefix) {
367367
// Check if its well known
368368
switch k {
369-
case prefixedSnapshotterSecretNameKey:
370-
case prefixedSnapshotterSecretNamespaceKey:
371-
case prefixedSnapshotterListSecretNameKey:
372-
case prefixedSnapshotterListSecretNamespaceKey:
369+
case PrefixedSnapshotterSecretNameKey:
370+
case PrefixedSnapshotterSecretNamespaceKey:
371+
case PrefixedSnapshotterListSecretNameKey:
372+
case PrefixedSnapshotterListSecretNamespaceKey:
373373
default:
374374
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
375375
}

pkg/utils/util_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,27 +41,27 @@ func TestGetSecretReference(t *testing.T) {
4141
},
4242
"namespace, no name": {
4343
secretParams: SnapshotterSecretParams,
44-
params: map[string]string{prefixedSnapshotterSecretNamespaceKey: "foo"},
44+
params: map[string]string{PrefixedSnapshotterSecretNamespaceKey: "foo"},
4545
expectErr: true,
4646
},
4747
"simple - valid": {
4848
secretParams: SnapshotterSecretParams,
49-
params: map[string]string{prefixedSnapshotterSecretNameKey: "name", prefixedSnapshotterSecretNamespaceKey: "ns"},
49+
params: map[string]string{PrefixedSnapshotterSecretNameKey: "name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
5050
snapshot: &crdv1.VolumeSnapshot{},
5151
expectRef: &v1.SecretReference{Name: "name", Namespace: "ns"},
5252
},
5353
"simple - invalid name": {
5454
secretParams: SnapshotterSecretParams,
55-
params: map[string]string{prefixedSnapshotterSecretNameKey: "bad name", prefixedSnapshotterSecretNamespaceKey: "ns"},
55+
params: map[string]string{PrefixedSnapshotterSecretNameKey: "bad name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
5656
snapshot: &crdv1.VolumeSnapshot{},
5757
expectRef: nil,
5858
expectErr: true,
5959
},
6060
"template - invalid": {
6161
secretParams: SnapshotterSecretParams,
6262
params: map[string]string{
63-
prefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
64-
prefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
63+
PrefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
64+
PrefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
6565
},
6666
snapContentName: "snapcontentname",
6767
snapshot: &crdv1.VolumeSnapshot{
@@ -111,14 +111,14 @@ func TestRemovePrefixedCSIParams(t *testing.T) {
111111
},
112112
{
113113
name: "one prefixed",
114-
params: map[string]string{prefixedSnapshotterSecretNameKey: "bar", "bim": "baz"},
114+
params: map[string]string{PrefixedSnapshotterSecretNameKey: "bar", "bim": "baz"},
115115
expectedParams: map[string]string{"bim": "baz"},
116116
},
117117
{
118118
name: "all known prefixed",
119119
params: map[string]string{
120-
prefixedSnapshotterSecretNameKey: "csiBar",
121-
prefixedSnapshotterSecretNamespaceKey: "csiBar",
120+
PrefixedSnapshotterSecretNameKey: "csiBar",
121+
PrefixedSnapshotterSecretNamespaceKey: "csiBar",
122122
},
123123
expectedParams: map[string]string{},
124124
},

0 commit comments

Comments
 (0)