Skip to content

Commit

Permalink
Merge pull request #1896 from cemakd/validate
Browse files Browse the repository at this point in the history
Add validation for negative provisioned-throughput-on-create parameter
  • Loading branch information
k8s-ci-robot authored Jan 15, 2025
2 parents f299c4d + 40c0773 commit 9090993
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pkg/common/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func (pp *ParameterProcessor) ExtractAndDefaultParameters(parameters map[string]
if err != nil {
return p, fmt.Errorf("parameters contain invalid provisionedThroughputOnCreate parameter: %w", err)
}
if paramProvisionedThroughputOnCreate < 0 {
return p, fmt.Errorf("parameter provisionedThroughputOnCreate cannot be negative")
}
p.ProvisionedThroughputOnCreate = paramProvisionedThroughputOnCreate
case ParameterAvailabilityClass:
paramAvailabilityClass, err := ConvertStringToAvailabilityClass(v)
Expand Down
7 changes: 7 additions & 0 deletions pkg/common/parameters_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,13 @@ func TestExtractAndDefaultParameters(t *testing.T) {
labels: map[string]string{},
expectErr: true,
},
{
name: "invalid storage pool parameters, negative ProvisionedThroughputOnCreate",
enableStoragePools: true,
parameters: map[string]string{ParameterKeyType: "hyperdisk-throughput", ParameterKeyReplicationType: "none", ParameterKeyDiskEncryptionKmsKey: "foo/key", ParameterKeyLabels: "key1=value1,key2=value2", ParameterKeyResourceTags: "parent1/key1/value1,parent2/key2/value2", ParameterKeyProvisionedThroughputOnCreate: "-50Mi"},
labels: map[string]string{},
expectErr: true,
},
{
name: "storage pool parameters, enableStoragePools is false",
enableStoragePools: false,
Expand Down

0 comments on commit 9090993

Please sign in to comment.