GoogleCloudPlatform / k8s-config-connector

GCP Config Connector, a Kubernetes add-on for managing GCP resources
https://cloud.google.com/config-connector/docs/overview
Apache License 2.0
861 stars 201 forks source link

fix: handle uri skeleton non null #2135

Open acpana opened 1 week ago

acpana commented 1 week ago

Today it seems that the ExpectedSkeleton is not checked if it is not null BUT the servicemappings lists idTemplateCanBeUsedToMatchResourceName == false . We should at least throw a warning in this scenario, otherwise the ExpectedSkeleton is not checked which may lead contributors to believe that their test is passing!

acpana commented 1 week ago

Example:

https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/2f4f2c6ee65034f7bbb4b4f62d2ba15842ff114d/config/servicemappings/vertexai.yaml#L20-L31

But the ExpectedSkeleton is not null

https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/2f4f2c6ee65034f7bbb4b4f62d2ba15842ff114d/pkg/resourceskeleton/testdata/uri-skeleton.yaml#L1114-L1122

This stood out to me for the "malformed" schema and then I realized that we don't check the yamls if the idTemplateCanBeUsedToMatchResourceName is unset:

https://github.com/GoogleCloudPlatform/k8s-config-connector/blob/2f4f2c6ee65034f7bbb4b4f62d2ba15842ff114d/pkg/resourceskeleton/resourceskeleton_test.go#L74-L75