mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-08-08 23:37:11 +00:00
Fixes range for min value in imagepolicy admission
This commit is contained in:
@@ -86,7 +86,7 @@ func normalizeConfigDuration(name string, scale, value, min, max, defaultValue t
|
||||
value *= scale
|
||||
|
||||
// check value is within range
|
||||
if value <= min || value > max {
|
||||
if value < min || value > max {
|
||||
return value, fmt.Errorf("valid value is between %v and %v, got %v", min, max, value)
|
||||
}
|
||||
return value, nil
|
||||
|
||||
@@ -89,6 +89,34 @@ func TestConfigNormalization(t *testing.T) {
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
test: "config within normal ranges for min values",
|
||||
config: imagePolicyWebhookConfig{
|
||||
AllowTTL: minAllowTTL / time.Second,
|
||||
DenyTTL: minDenyTTL / time.Second,
|
||||
RetryBackoff: minRetryBackoff,
|
||||
},
|
||||
normalizedConfig: imagePolicyWebhookConfig{
|
||||
AllowTTL: minAllowTTL,
|
||||
DenyTTL: minDenyTTL,
|
||||
RetryBackoff: minRetryBackoff * time.Millisecond,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
test: "config within normal ranges for max values",
|
||||
config: imagePolicyWebhookConfig{
|
||||
AllowTTL: maxAllowTTL / time.Second,
|
||||
DenyTTL: maxDenyTTL / time.Second,
|
||||
RetryBackoff: maxRetryBackoff / time.Millisecond,
|
||||
},
|
||||
normalizedConfig: imagePolicyWebhookConfig{
|
||||
AllowTTL: maxAllowTTL,
|
||||
DenyTTL: maxDenyTTL,
|
||||
RetryBackoff: maxRetryBackoff,
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
err := normalizeWebhookConfig(&tt.config)
|
||||
|
||||
Reference in New Issue
Block a user