Skip to content

Commit

Permalink
issue-384, A single "default" storage class secret is added
Browse files Browse the repository at this point in the history
  • Loading branch information
taaraora committed Jan 3, 2020
1 parent feb6776 commit 1a38101
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ const (

prefixedFsTypeKey = csiParameterPrefix + "fstype"

prefixedDefaultSecretNameKey = csiParameterPrefix + "secret-name"
prefixedDefaultSecretNamespaceKey = csiParameterPrefix + "secret-namespace"

prefixedProvisionerSecretNameKey = csiParameterPrefix + "provisioner-secret-name"
prefixedProvisionerSecretNamespaceKey = csiParameterPrefix + "provisioner-secret-namespace"

Expand Down Expand Up @@ -128,6 +131,12 @@ const (
)

var (
defaultSecretParams = secretParamsMap{
name: "Default",
secretNameKey: prefixedDefaultSecretNameKey,
secretNamespaceKey: prefixedDefaultSecretNamespaceKey,
}

provisionerSecretParams = secretParamsMap{
name: "Provisioner",
deprecatedSecretNameKey: provisionerSecretNameKey,
Expand Down Expand Up @@ -702,6 +711,8 @@ func removePrefixedParameters(param map[string]string) (map[string]string, error
case prefixedNodePublishSecretNamespaceKey:
case prefixedControllerExpandSecretNameKey:
case prefixedControllerExpandSecretNamespaceKey:
case prefixedDefaultSecretNameKey:
case prefixedDefaultSecretNamespaceKey:
default:
return map[string]string{}, fmt.Errorf("found unknown parameter key \"%s\" with reserved namespace %s", k, csiParameterPrefix)
}
Expand Down Expand Up @@ -1042,6 +1053,15 @@ func getSecretReference(secretParams secretParamsMap, storageClassParams map[str
if err != nil {
return nil, fmt.Errorf("failed to get name and namespace template from params: %v", err)
}

// if didn't find secrets for specific call, try to check default values
if nameTemplate == "" && namespaceTemplate == "" {
nameTemplate, namespaceTemplate, err = verifyAndGetSecretNameAndNamespaceTemplate(defaultSecretParams, storageClassParams)
if err != nil {
return nil, fmt.Errorf("failed to get default name and namespace template from params: %v", err)
}
}

if nameTemplate == "" && namespaceTemplate == "" {
return nil, nil
}
Expand Down

0 comments on commit 1a38101

Please sign in to comment.