Skip to content

Commit

Permalink
Making it such that we only define supported components in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanrainer committed Oct 19, 2021
1 parent 67bd78e commit d1da19b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 2 additions & 2 deletions pkg/driver/controller.go
Expand Up @@ -509,13 +509,13 @@ func createRootDirNameFromComponents(components string, volumeParams map[string]
} else {
return "", status.Errorf(codes.InvalidArgument,
"Directory structure specified \"%v\" contains invalid elements. Can only contain %v", components,
getSupportComponentNames())
getSupportedComponentNames())
}
}
return result, nil
}

func getSupportComponentNames() []string {
func getSupportedComponentNames() []string {
keys := make([]string, len(accessPointDirectoryComponents))

i := 0
Expand Down
5 changes: 2 additions & 3 deletions pkg/driver/controller_test.go
Expand Up @@ -30,7 +30,6 @@ func TestCreateVolume(t *testing.T) {
Mode: csi.VolumeCapability_AccessMode_MULTI_NODE_MULTI_WRITER,
},
}
supportedComponents = "[pvcName pvcNamespace]"
)
testCases := []struct {
name string
Expand Down Expand Up @@ -1598,7 +1597,7 @@ func TestCreateVolume(t *testing.T) {
t.Fatal("CreateVolume did not fail")
}
if !errors.Is(err, status.Errorf(codes.InvalidArgument,
"Directory structure specified \"%v\" contains invalid elements. Can only contain %v", accessPointStructure, supportedComponents)) {
"Directory structure specified \"%v\" contains invalid elements. Can only contain %v", accessPointStructure, getSupportedComponentNames())) {
t.Fatalf("Did not throw InvalidArgument error, instead threw %v", err)
}
mockCtl.Finish()
Expand Down Expand Up @@ -1647,7 +1646,7 @@ func TestCreateVolume(t *testing.T) {
t.Fatal("CreateVolume did not fail")
}
if !errors.Is(err, status.Errorf(codes.InvalidArgument,
"Directory structure specified \"%v\" contains invalid elements. Can only contain %v", accessPointStructure, supportedComponents)) {
"Directory structure specified \"%v\" contains invalid elements. Can only contain %v", accessPointStructure, getSupportedComponentNames())) {
t.Fatalf("Did not throw InvalidArgument error, instead threw %v", err)
}
mockCtl.Finish()
Expand Down

0 comments on commit d1da19b

Please sign in to comment.