Workaround to hide output-only spec field but support it in observed state #2075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change description
This is a workaround for #2051 so that the output-only field
spec.softDeletePolicy.EffectiveTime
won't be added to CRD.Tests you have done
make ready-pr
to ensure this PR is ready for review.Verified that the created resource doesn't have
spec.softDeletePolicy.EffectiveTime
field even ifstate-into-spec: merge
is configured by default:dynamic_controller_integration_test.go:248: created resource is &{map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 kind:StorageBucket metadata:map[annotations:map[cnrm.cloud.google.com/management-conflict-prevention-policy:none cnrm.cloud.google.com/project-id:[PROJECT_ID] cnrm.cloud.google.com/state-into-spec:merge] creationTimestamp:2024-06-21T23:51:21Z finalizers:[cnrm.cloud.google.com/finalizer cnrm.cloud.google.com/deletion-defender] generation:4 labels:map[cnrm-test:true label-one:value-one managed-by-cnrm:true newkey:newval] managedFields:[map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 fieldsType:FieldsV1 fieldsV1:map[f:metadata:map[f:labels:map[.:map[] f:cnrm-test:map[] f:label-one:map[] f:newkey:map[]]] f:spec:map[.:map[] f:location:map[] f:softDeletePolicy:map[.:map[] f:retentionDurationSeconds:map[]] f:versioning:map[.:map[] f:enabled:map[]]]] manager:___198TestCreateNoChangeUpdateDelete_in_github_com_GoogleCloudPlatform_k8s_config_connector_pkg_controller_dynamic.test operation:Update time:2024-06-21T23:58:13Z] map[apiVersion:storage.cnrm.cloud.google.com/v1beta1 fieldsType:FieldsV1 fieldsV1:map[f:metadata:map[f:annotations:map[f:cnrm.cloud.google.com/state-into-spec:map[]] f:finalizers:map[.:map[] v:"cnrm.cloud.google.com/deletion-defender":map[] v:"cnrm.cloud.google.com/finalizer":map[]]] f:spec:map[f:publicAccessPrevention:map[] f:resourceID:map[] f:storageClass:map[]] f:status:map[.:map[] f:conditions:map[] f:observedGeneration:map[] f:observedState:map[.:map[] f:softDeletePolicy:map[.:map[] f:effectiveTime:map[] f:retentionDurationSeconds:map[]]] f:selfLink:map[] f:url:map[]]] manager:cnrm-controller-manager operation:Update time:2024-06-22T00:16:40Z]] name:storagebucket-sample-7lyh7jdpfbs5usazbgdq namespace:7lyh7jdpfbs5usazbgdq resourceVersion:1555 uid:dd773a67-40f3-45c7-85f0-79ebf814ac14] spec:map[location:US publicAccessPrevention:inherited resourceID:storagebucket-sample-7lyh7jdpfbs5usazbgdq softDeletePolicy:map[retentionDurationSeconds:6000000] storageClass:STANDARD versioning:map[enabled:true]] status:map[conditions:[map[lastTransitionTime:2024-06-22T00:16:40Z message:The resource is up to date reason:UpToDate status:True type:Ready]] observedGeneration:4 observedState:map[softDeletePolicy:map[effectiveTime:2024-06-22T00:16:10.816Z retentionDurationSeconds:6000000]] selfLink:https://www.googleapis.com/storage/v1/b/storagebucket-sample-7lyh7jdpfbs5usazbgdq url:gs://storagebucket-sample-7lyh7jdpfbs5usazbgdq]]}