-
Notifications
You must be signed in to change notification settings - Fork 159
Allow to label PD disk with k8s cluster ID #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,79 +25,105 @@ func TestExtractAndDefaultParameters(t *testing.T) { | |
tests := []struct { | ||
name string | ||
parameters map[string]string | ||
labels map[string]string | ||
expectParams DiskParameters | ||
expectErr bool | ||
}{ | ||
{ | ||
name: "defaults", | ||
parameters: map[string]string{}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "", | ||
Tags: make(map[string]string), | ||
Labels: make(map[string]string), | ||
}, | ||
}, | ||
{ | ||
name: "specified empties", | ||
parameters: map[string]string{ParameterKeyType: "", ParameterKeyReplicationType: "", ParameterKeyDiskEncryptionKmsKey: ""}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "", | ||
Tags: make(map[string]string), | ||
Labels: make(map[string]string), | ||
}, | ||
}, | ||
{ | ||
name: "random keys", | ||
parameters: map[string]string{ParameterKeyType: "", "foo": "", ParameterKeyDiskEncryptionKmsKey: ""}, | ||
labels: map[string]string{}, | ||
expectErr: true, | ||
}, | ||
{ | ||
name: "real values", | ||
parameters: map[string]string{ParameterKeyType: "pd-ssd", ParameterKeyReplicationType: "regional-pd", ParameterKeyDiskEncryptionKmsKey: "foo/key"}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-ssd", | ||
ReplicationType: "regional-pd", | ||
DiskEncryptionKMSKey: "foo/key", | ||
Tags: make(map[string]string), | ||
Labels: make(map[string]string), | ||
}, | ||
}, | ||
{ | ||
name: "real values, checking balanced pd", | ||
parameters: map[string]string{ParameterKeyType: "pd-balanced", ParameterKeyReplicationType: "regional-pd", ParameterKeyDiskEncryptionKmsKey: "foo/key"}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-balanced", | ||
ReplicationType: "regional-pd", | ||
DiskEncryptionKMSKey: "foo/key", | ||
Tags: make(map[string]string), | ||
Labels: make(map[string]string), | ||
}, | ||
}, | ||
{ | ||
name: "partial spec", | ||
parameters: map[string]string{ParameterKeyDiskEncryptionKmsKey: "foo/key"}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "foo/key", | ||
Tags: make(map[string]string), | ||
Labels: make(map[string]string), | ||
}, | ||
}, | ||
{ | ||
name: "tags", | ||
parameters: map[string]string{ParameterKeyPVCName: "testPVCName", ParameterKeyPVCNamespace: "testPVCNamespace", ParameterKeyPVName: "testPVName"}, | ||
labels: map[string]string{}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "", | ||
Tags: map[string]string{tagKeyCreatedForClaimName: "testPVCName", tagKeyCreatedForClaimNamespace: "testPVCNamespace", tagKeyCreatedForVolumeName: "testPVName", tagKeyCreatedBy: "testDriver"}, | ||
Labels: make(map[string]string), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did I miss it or shouldn't there be a test case for the new labels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed the code since There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they're only we being copied we should test that---these also serve as regression tests. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added the test in the latest commit. |
||
}, | ||
}, | ||
{ | ||
name: "labels", | ||
parameters: map[string]string{}, | ||
labels: map[string]string{"label-1": "label-value-1", "label-2": "label-value-2"}, | ||
expectParams: DiskParameters{ | ||
DiskType: "pd-standard", | ||
ReplicationType: "none", | ||
DiskEncryptionKMSKey: "", | ||
Tags: map[string]string{}, | ||
Labels: map[string]string{"label-1": "label-value-1", "label-2": "label-value-2"}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tc := range tests { | ||
t.Run(tc.name, func(t *testing.T) { | ||
p, err := ExtractAndDefaultParameters(tc.parameters, "testDriver") | ||
p, err := ExtractAndDefaultParameters(tc.parameters, "testDriver", tc.labels) | ||
if gotErr := err != nil; gotErr != tc.expectErr { | ||
t.Fatalf("ExtractAndDefaultParameters(%+v) = %v; expectedErr: %v", tc.parameters, err, tc.expectErr) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to remove the csi-proxy? It's used by windows. At any rate we should clean this up in a separate PR.
@jingxu97 We seem to have both 0.2.1 and 0.2.2 of the proxy here, not sure what's going on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At any rate this PR should not be changing go.mod (sorry I wasn't clear on that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I'll fix that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above is a result of
go mod tidy
. I usek8s.io/component-base/cli/flag
for the CLI parsing and it was not vendored yet so I actually have to update go.mod for this patch. I think the removal of the (older) csi-proxy v0.2.1 is correct and the v0.2.2 is listed twice in go.sum.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fair enough. I'm not going to argue with go mod tidy.