From 3d5bb3726826733ded8876ccf96d0b58acd6f029 Mon Sep 17 00:00:00 2001 From: Alex Pana <8968914+acpana@users.noreply.github.com> Date: Tue, 10 Sep 2024 19:30:45 +0000 Subject: [PATCH 1/2] tests: support status.externalRef Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com> --- pkg/k8s/allowlist_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/k8s/allowlist_test.go b/pkg/k8s/allowlist_test.go index 33b54251c9..c5df02a4b3 100644 --- a/pkg/k8s/allowlist_test.go +++ b/pkg/k8s/allowlist_test.go @@ -145,6 +145,11 @@ func TestOutputOnlyFieldsAreUnderObservedState(t *testing.T) { } requiredFieldsMap := map[string]bool{"observedGeneration": true, "conditions": true} optionalFieldsMap := map[string]bool{"observedState": true} + + // for direct resources, we will use the "externalRef" prop under the "status" + // to track the KCC full resource ID + optionalFieldsMap["externalRef"] = true + for k, _ := range statusProp.Properties { foundInMaps := false if _, ok := requiredFieldsMap[k]; ok { @@ -156,7 +161,7 @@ func TestOutputOnlyFieldsAreUnderObservedState(t *testing.T) { delete(optionalFieldsMap, k) } if !foundInMaps { - t.Errorf("CRD has non-boilerplate field %v under 'status'", k) + t.Errorf("CRD has non-boilerplate field '%v' under 'status'", k) } } From 4aff91a1cd70b9040fdd4b27a7fae7d46f971402 Mon Sep 17 00:00:00 2001 From: Alex Pana <8968914+acpana@users.noreply.github.com> Date: Wed, 11 Sep 2024 00:06:38 +0000 Subject: [PATCH 2/2] tests: direct storageVersion Signed-off-by: Alex Pana <8968914+acpana@users.noreply.github.com> --- config/tests/servicemapping/servicemapping_test.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/tests/servicemapping/servicemapping_test.go b/config/tests/servicemapping/servicemapping_test.go index 8afb1c10fe..729fe9d810 100644 --- a/config/tests/servicemapping/servicemapping_test.go +++ b/config/tests/servicemapping/servicemapping_test.go @@ -1267,6 +1267,11 @@ func TestStorageVersionIsSetAndValidIFFV1alpha1ToV1beta1IsSet(t *testing.T) { continue } if isV1alpha1ToV1beta1 { + // if this is a direct resource, the storage version is defiend + // in the kubebuilder tooling + if r.Direct { + continue + } if hasStorageVersion { t.Errorf("Resource config %v has `v1alpha1ToV1beta1: "+ "true` but doesn't have a valid `storageVersion`: "+