Skip to content

Commit 79d6f0a

Browse files
authored
Merge pull request #12501 from sbueringer/pr-improve-e2e
⚠️ test/e2e: default to strict field validation & fix unknown field in ClusterClass YAML
2 parents 2576709 + 3103c3a commit 79d6f0a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ spec:
7474
- name: etcdImageTag
7575
required: true
7676
# This metadata has just been added to verify that we can set metadata.
77-
metadata:
77+
deprecatedV1Beta1Metadata:
7878
labels:
7979
testLabelKey: testLabelValue
8080
annotations:

test/framework/cluster_proxy.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ func (p *clusterProxy) GetCache(ctx context.Context) cache.Cache {
307307
}
308308

309309
// CreateOrUpdate creates or updates objects using the clusterProxy client.
310+
// Defaults to use FieldValidation: strict, which can be overwritten with CreateOrUpdateOptions.
310311
func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opts ...CreateOrUpdateOption) error {
311312
Expect(ctx).NotTo(BeNil(), "ctx is required for CreateOrUpdate")
312313
Expect(resources).NotTo(BeNil(), "resources is required for CreateOrUpdate")
@@ -318,6 +319,9 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt
318319
if config.labelSelector != nil {
319320
labelSelector = config.labelSelector
320321
}
322+
// Prepending field validation strict so that it is used per default, but can still be overwritten.
323+
config.createOpts = append([]client.CreateOption{client.FieldValidation("Strict")}, config.createOpts...)
324+
config.updateOpts = append([]client.UpdateOption{client.FieldValidation("Strict")}, config.updateOpts...)
321325
objs, err := yaml.ToUnstructured(resources)
322326
if err != nil {
323327
return err

0 commit comments

Comments
 (0)