Modify to upper case variable name from lower case for unit tests
This commit is contained in:
@@ -62,10 +62,10 @@ var class5Parameters = map[string]string{
|
|||||||
}
|
}
|
||||||
|
|
||||||
var class6Parameters = map[string]string{
|
var class6Parameters = map[string]string{
|
||||||
"csi.storage.k8s.io/snapshotter-secret-name": "secret",
|
utils.PrefixedSnapshotterSecretNameKey: "secret",
|
||||||
"csi.storage.k8s.io/snapshotter-secret-namespace": "default",
|
utils.PrefixedSnapshotterSecretNamespaceKey: "default",
|
||||||
"csi.storage.k8s.io/snapshotter-list-secret-name": "secret",
|
utils.PrefixedSnapshotterListSecretNameKey: "secret",
|
||||||
"csi.storage.k8s.io/snapshotter-list-secret-namespace": "default",
|
utils.PrefixedSnapshotterListSecretNamespaceKey: "default",
|
||||||
}
|
}
|
||||||
|
|
||||||
var snapshotClasses = []*crdv1.VolumeSnapshotClass{
|
var snapshotClasses = []*crdv1.VolumeSnapshotClass{
|
||||||
|
@@ -53,11 +53,11 @@ const (
|
|||||||
// fields in subsequent CSI calls or Kubernetes API objects.
|
// fields in subsequent CSI calls or Kubernetes API objects.
|
||||||
csiParameterPrefix = "csi.storage.k8s.io/"
|
csiParameterPrefix = "csi.storage.k8s.io/"
|
||||||
|
|
||||||
prefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
|
PrefixedSnapshotterSecretNameKey = csiParameterPrefix + "snapshotter-secret-name"
|
||||||
prefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
|
PrefixedSnapshotterSecretNamespaceKey = csiParameterPrefix + "snapshotter-secret-namespace"
|
||||||
|
|
||||||
prefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
|
PrefixedSnapshotterListSecretNameKey = csiParameterPrefix + "snapshotter-list-secret-name"
|
||||||
prefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
|
PrefixedSnapshotterListSecretNamespaceKey = csiParameterPrefix + "snapshotter-list-secret-namespace"
|
||||||
|
|
||||||
// Name of finalizer on VolumeSnapshotContents that are bound by VolumeSnapshots
|
// Name of finalizer on VolumeSnapshotContents that are bound by VolumeSnapshots
|
||||||
VolumeSnapshotContentFinalizer = "snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection"
|
VolumeSnapshotContentFinalizer = "snapshot.storage.kubernetes.io/volumesnapshotcontent-bound-protection"
|
||||||
@@ -86,14 +86,14 @@ const (
|
|||||||
|
|
||||||
var SnapshotterSecretParams = secretParamsMap{
|
var SnapshotterSecretParams = secretParamsMap{
|
||||||
name: "Snapshotter",
|
name: "Snapshotter",
|
||||||
secretNameKey: prefixedSnapshotterSecretNameKey,
|
secretNameKey: PrefixedSnapshotterSecretNameKey,
|
||||||
secretNamespaceKey: prefixedSnapshotterSecretNamespaceKey,
|
secretNamespaceKey: PrefixedSnapshotterSecretNamespaceKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
var SnapshotterListSecretParams = secretParamsMap{
|
var SnapshotterListSecretParams = secretParamsMap{
|
||||||
name: "SnapshotterList",
|
name: "SnapshotterList",
|
||||||
secretNameKey: prefixedSnapshotterListSecretNameKey,
|
secretNameKey: PrefixedSnapshotterListSecretNameKey,
|
||||||
secretNamespaceKey: prefixedSnapshotterListSecretNamespaceKey,
|
secretNamespaceKey: PrefixedSnapshotterListSecretNamespaceKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
func SnapshotKey(vs *crdv1.VolumeSnapshot) string {
|
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) {
|
if strings.HasPrefix(k, csiParameterPrefix) {
|
||||||
// Check if its well known
|
// Check if its well known
|
||||||
switch k {
|
switch k {
|
||||||
case prefixedSnapshotterSecretNameKey:
|
case PrefixedSnapshotterSecretNameKey:
|
||||||
case prefixedSnapshotterSecretNamespaceKey:
|
case PrefixedSnapshotterSecretNamespaceKey:
|
||||||
case prefixedSnapshotterListSecretNameKey:
|
case PrefixedSnapshotterListSecretNameKey:
|
||||||
case prefixedSnapshotterListSecretNamespaceKey:
|
case PrefixedSnapshotterListSecretNamespaceKey:
|
||||||
default:
|
default:
|
||||||
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
|
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
|
||||||
}
|
}
|
||||||
|
@@ -41,18 +41,18 @@ func TestGetSecretReference(t *testing.T) {
|
|||||||
},
|
},
|
||||||
"namespace, no name": {
|
"namespace, no name": {
|
||||||
secretParams: SnapshotterSecretParams,
|
secretParams: SnapshotterSecretParams,
|
||||||
params: map[string]string{prefixedSnapshotterSecretNamespaceKey: "foo"},
|
params: map[string]string{PrefixedSnapshotterSecretNamespaceKey: "foo"},
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
},
|
},
|
||||||
"simple - valid": {
|
"simple - valid": {
|
||||||
secretParams: SnapshotterSecretParams,
|
secretParams: SnapshotterSecretParams,
|
||||||
params: map[string]string{prefixedSnapshotterSecretNameKey: "name", prefixedSnapshotterSecretNamespaceKey: "ns"},
|
params: map[string]string{PrefixedSnapshotterSecretNameKey: "name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
|
||||||
snapshot: &crdv1.VolumeSnapshot{},
|
snapshot: &crdv1.VolumeSnapshot{},
|
||||||
expectRef: &v1.SecretReference{Name: "name", Namespace: "ns"},
|
expectRef: &v1.SecretReference{Name: "name", Namespace: "ns"},
|
||||||
},
|
},
|
||||||
"simple - invalid name": {
|
"simple - invalid name": {
|
||||||
secretParams: SnapshotterSecretParams,
|
secretParams: SnapshotterSecretParams,
|
||||||
params: map[string]string{prefixedSnapshotterSecretNameKey: "bad name", prefixedSnapshotterSecretNamespaceKey: "ns"},
|
params: map[string]string{PrefixedSnapshotterSecretNameKey: "bad name", PrefixedSnapshotterSecretNamespaceKey: "ns"},
|
||||||
snapshot: &crdv1.VolumeSnapshot{},
|
snapshot: &crdv1.VolumeSnapshot{},
|
||||||
expectRef: nil,
|
expectRef: nil,
|
||||||
expectErr: true,
|
expectErr: true,
|
||||||
@@ -60,8 +60,8 @@ func TestGetSecretReference(t *testing.T) {
|
|||||||
"template - invalid": {
|
"template - invalid": {
|
||||||
secretParams: SnapshotterSecretParams,
|
secretParams: SnapshotterSecretParams,
|
||||||
params: map[string]string{
|
params: map[string]string{
|
||||||
prefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
|
PrefixedSnapshotterSecretNameKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}-${volumesnapshot.name}-${volumesnapshot.annotations['akey']}",
|
||||||
prefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
|
PrefixedSnapshotterSecretNamespaceKey: "static-${volumesnapshotcontent.name}-${volumesnapshot.namespace}",
|
||||||
},
|
},
|
||||||
snapContentName: "snapcontentname",
|
snapContentName: "snapcontentname",
|
||||||
snapshot: &crdv1.VolumeSnapshot{
|
snapshot: &crdv1.VolumeSnapshot{
|
||||||
@@ -111,14 +111,14 @@ func TestRemovePrefixedCSIParams(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "one prefixed",
|
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"},
|
expectedParams: map[string]string{"bim": "baz"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "all known prefixed",
|
name: "all known prefixed",
|
||||||
params: map[string]string{
|
params: map[string]string{
|
||||||
prefixedSnapshotterSecretNameKey: "csiBar",
|
PrefixedSnapshotterSecretNameKey: "csiBar",
|
||||||
prefixedSnapshotterSecretNamespaceKey: "csiBar",
|
PrefixedSnapshotterSecretNamespaceKey: "csiBar",
|
||||||
},
|
},
|
||||||
expectedParams: map[string]string{},
|
expectedParams: map[string]string{},
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user