From 3103c3ac38947d185e957882c529b2fad9d5ca07 Mon Sep 17 00:00:00 2001 From: Stefan Bueringer Date: Thu, 17 Jul 2025 12:10:38 +0200 Subject: [PATCH] test/e2e: default to strict field validation & fix unknown field in ClusterClass MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Büringer buringerst@vmware.com --- .../infrastructure-docker/main/clusterclass-quick-start.yaml | 2 +- test/framework/cluster_proxy.go | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml index 6399a4cb6bfa..0c67b15920a2 100644 --- a/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml +++ b/test/e2e/data/infrastructure-docker/main/clusterclass-quick-start.yaml @@ -74,7 +74,7 @@ spec: - name: etcdImageTag required: true # This metadata has just been added to verify that we can set metadata. - metadata: + deprecatedV1Beta1Metadata: labels: testLabelKey: testLabelValue annotations: diff --git a/test/framework/cluster_proxy.go b/test/framework/cluster_proxy.go index 0fd828293a22..cecffc3b3d4f 100644 --- a/test/framework/cluster_proxy.go +++ b/test/framework/cluster_proxy.go @@ -307,6 +307,7 @@ func (p *clusterProxy) GetCache(ctx context.Context) cache.Cache { } // CreateOrUpdate creates or updates objects using the clusterProxy client. +// Defaults to use FieldValidation: strict, which can be overwritten with CreateOrUpdateOptions. func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opts ...CreateOrUpdateOption) error { Expect(ctx).NotTo(BeNil(), "ctx is required for CreateOrUpdate") Expect(resources).NotTo(BeNil(), "resources is required for CreateOrUpdate") @@ -318,6 +319,9 @@ func (p *clusterProxy) CreateOrUpdate(ctx context.Context, resources []byte, opt if config.labelSelector != nil { labelSelector = config.labelSelector } + // Prepending field validation strict so that it is used per default, but can still be overwritten. + config.createOpts = append([]client.CreateOption{client.FieldValidation("Strict")}, config.createOpts...) + config.updateOpts = append([]client.UpdateOption{client.FieldValidation("Strict")}, config.updateOpts...) objs, err := yaml.ToUnstructured(resources) if err != nil { return err