Skip to content

Commit

Permalink
solve misleading struct deprecatedSecretParamsMap
Browse files Browse the repository at this point in the history
since the struct contains "deprecated" prefix hinting but some of the key is not really deprecated.
so it may confuse us. This is a private struct, it's simple to just rename in Controller and
test file.

224
  • Loading branch information
hoyho committed Apr 24, 2019
1 parent 66fd58e commit 048a5c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ import (
"google.golang.org/grpc"
)

type deprecatedSecretParamsMap struct {
//secretParamsMap provides a mapping of current as well as deprecated secret keys
type secretParamsMap struct {
name string
deprecatedSecretNameKey string
deprecatedSecretNamespaceKey string
Expand Down Expand Up @@ -111,31 +112,31 @@ const (
)

var (
provisionerSecretParams = deprecatedSecretParamsMap{
provisionerSecretParams = secretParamsMap{
name: "Provisioner",
deprecatedSecretNameKey: provisionerSecretNameKey,
deprecatedSecretNamespaceKey: provisionerSecretNamespaceKey,
secretNameKey: prefixedProvisionerSecretNameKey,
secretNamespaceKey: prefixedProvisionerSecretNamespaceKey,
}

nodePublishSecretParams = deprecatedSecretParamsMap{
nodePublishSecretParams = secretParamsMap{
name: "NodePublish",
deprecatedSecretNameKey: nodePublishSecretNameKey,
deprecatedSecretNamespaceKey: nodePublishSecretNamespaceKey,
secretNameKey: prefixedNodePublishSecretNameKey,
secretNamespaceKey: prefixedNodePublishSecretNamespaceKey,
}

controllerPublishSecretParams = deprecatedSecretParamsMap{
controllerPublishSecretParams = secretParamsMap{
name: "ControllerPublish",
deprecatedSecretNameKey: controllerPublishSecretNameKey,
deprecatedSecretNamespaceKey: controllerPublishSecretNamespaceKey,
secretNameKey: prefixedControllerPublishSecretNameKey,
secretNamespaceKey: prefixedControllerPublishSecretNamespaceKey,
}

nodeStageSecretParams = deprecatedSecretParamsMap{
nodeStageSecretParams = secretParamsMap{
name: "NodeStage",
deprecatedSecretNameKey: nodeStageSecretNameKey,
deprecatedSecretNamespaceKey: nodeStageSecretNamespaceKey,
Expand Down Expand Up @@ -704,7 +705,7 @@ func (p *csiProvisioner) volumeHandleToId(handle string) string {

// verifyAndGetSecretNameAndNamespaceTemplate gets the values (templates) associated
// with the parameters specified in "secret" and verifies that they are specified correctly.
func verifyAndGetSecretNameAndNamespaceTemplate(secret deprecatedSecretParamsMap, storageClassParams map[string]string) (nameTemplate, namespaceTemplate string, err error) {
func verifyAndGetSecretNameAndNamespaceTemplate(secret secretParamsMap, storageClassParams map[string]string) (nameTemplate, namespaceTemplate string, err error) {
numName := 0
numNamespace := 0

Expand Down Expand Up @@ -766,7 +767,7 @@ func verifyAndGetSecretNameAndNamespaceTemplate(secret deprecatedSecretParamsMap
// - the nameTemplate or namespaceTemplate contains a token that cannot be resolved
// - the resolved name is not a valid secret name
// - the resolved namespace is not a valid namespace name
func getSecretReference(secretParams deprecatedSecretParamsMap, storageClassParams map[string]string, pvName string, pvc *v1.PersistentVolumeClaim) (*v1.SecretReference, error) {
func getSecretReference(secretParams secretParamsMap, storageClassParams map[string]string, pvName string, pvc *v1.PersistentVolumeClaim) (*v1.SecretReference, error) {
nameTemplate, namespaceTemplate, err := verifyAndGetSecretNameAndNamespaceTemplate(secretParams, storageClassParams)
if err != nil {
return nil, fmt.Errorf("failed to get name and namespace template from params: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ func createFakePVCWithVolumeMode(requestBytes int64, volumeMode v1.PersistentVol

func TestGetSecretReference(t *testing.T) {
testcases := map[string]struct {
secretParams deprecatedSecretParamsMap
secretParams secretParamsMap
params map[string]string
pvName string
pvc *v1.PersistentVolumeClaim
Expand Down

0 comments on commit 048a5c5

Please sign in to comment.