Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into release-1.30
Browse files Browse the repository at this point in the history
  • Loading branch information
k8s-release-robot committed Apr 2, 2024
2 parents 13ccca8 + c9f6d4e commit 389cfeb
Showing 1 changed file with 6 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,23 +220,12 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
}

uuidString := string(uuid.NewUUID())
// UUID string is just hex separated by dashes, which is safe to
// throw into regex like this
pattern := "^" + uuidString + "$"
sentinelName := "__ratcheting_sentinel_field__"
sch.Properties[sentinelName] = apiextensionsv1.JSONSchemaProps{
Type: "string",
Pattern: pattern,

// Put MaxLength condition inside AllOf since the string_validator
// in kube-openapi short circuits upon seeing MaxLength, and we
// want both pattern and MaxLength errors
AllOf: []apiextensionsv1.JSONSchemaProps{
{
MinLength: ptr((int64(1))), // 1 MinLength to prevent empty value from ever being admitted
MaxLength: ptr((int64(0))), // 0 MaxLength to prevent non-empty value from ever being admitted
},
},
Type: "string",
Enum: []apiextensionsv1.JSON{{
Raw: []byte(`"` + uuidString + `"`),
}},
}

for _, v := range myCRD.Spec.Versions {
Expand All @@ -254,7 +243,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
}

// Keep trying to create an invalid instance of the CRD until we
// get an error containing the ResourceVersion we are looking for
// get an error containing the message we are looking for
//
counter := 0
return wait.PollUntilContextCancel(context.TODO(), 100*time.Millisecond, true, func(_ context.Context) (done bool, err error) {
Expand All @@ -263,8 +252,7 @@ func (u updateMyCRDV1Beta1Schema) Do(ctx *ratchetingTestContext) error {
gvr: myCRDV1Beta1,
name: "sentinel-resource",
patch: map[string]interface{}{
// Just keep using different values
sentinelName: fmt.Sprintf("invalid %v %v", uuidString, counter),
sentinelName: fmt.Sprintf("invalid-%d", counter),
}}.Do(ctx)

if err == nil {
Expand Down

0 comments on commit 389cfeb

Please sign in to comment.