Skip to content

Commit

Permalink
fix: Make ResourceID field "mutable"
Browse files Browse the repository at this point in the history
In practice, due to in-controller enforcement, the only valid change is
to set from empty string -> actual resource ID.
  • Loading branch information
jasonvigil committed Dec 19, 2024
1 parent 0898bc1 commit e8131e0
Show file tree
Hide file tree
Showing 45 changed files with 58 additions and 157 deletions.
2 changes: 0 additions & 2 deletions apis/bigquerydatatransfer/v1alpha1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ type BigQueryDataTransferConfigSpec struct {

Parent `json:",inline"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The BigQueryDataTransferConfig name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/bigquerydatatransfer/v1beta1/transferconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,6 @@ type BigQueryDataTransferConfigSpec struct {

Parent `json:",inline"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The BigQueryDataTransferConfig name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
3 changes: 1 addition & 2 deletions apis/certificatemanager/v1alpha1/dnsauthorization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ type CertificateManagerDNSAuthorizationSpec struct {
// +required
ProjectRef refs.ProjectRef `json:"projectRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
/* Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */
/* Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */
// +optional
ResourceID *string `json:"resourceID,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions apis/certificatemanager/v1beta1/dnsauthorization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ type CertificateManagerDNSAuthorizationSpec struct {
// +optional
Location string `json:"location"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
/* Immutable. Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */
/* Optional. The name of the resource. Used for creation and acquisition. When unset, the value of `metadata.name` is used as the default. */
// +optional
ResourceID *string `json:"resourceID,omitempty"`
}
Expand Down
3 changes: 1 addition & 2 deletions apis/compute/v1beta1/targettcpproxy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ type ComputeTargetTCPProxySpec struct {
// the backend. Default value: "NONE" Possible values: ["NONE", "PROXY_V1"].
ProxyHeader *string `json:"proxyHeader,omitempty"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID is immutable"
// Immutable. The ComputeTargetTCPProxy name. If not given, the metadata.name will be used.
// The ComputeTargetTCPProxy name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`
}

Expand Down
3 changes: 1 addition & 2 deletions apis/containerattached/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ type ContainerAttachedClusterSpec struct {
/* The ID of the project in which the resource belongs.*/
ProjectRef *refs.ProjectRef `json:"projectRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable, Optional.
// Optional.
// The ContainerAttachedCluster name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ var DiscoveryEngineDataStoreGVK = GroupVersion.WithKind("DiscoveryEngineDataStor
// DiscoveryEngineDataStoreSpec defines the desired state of DiscoveryEngineDataStore
// +kcc:proto=google.cloud.discoveryengine.v1.DataStore
type DiscoveryEngineDataStoreSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The DiscoveryEngineDataStore name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/kms/v1alpha1/keyhandle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var KMSKeyHandleGVK = GroupVersion.WithKind("KMSKeyHandle")
// KMSKeyHandleSpec defines the desired state of KMSKeyHandle
// +kcc:proto=google.cloud.kms.v1.KeyHandle
type KMSKeyHandleSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The KMS Key Handle ID used for resource creation or acquisition.
// For creation: If specified, this value is used as the key handle ID. If not provided, a UUID will be generated and assigned as the key handle ID.
// For acquisition: This field must be provided to identify the key handle resource to acquire.
Expand Down
2 changes: 0 additions & 2 deletions apis/kms/v1beta1/keyhandle_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ var KMSKeyHandleGVK = SchemeGroupVersion.WithKind("KMSKeyHandle")
// KMSKeyHandleSpec defines the desired state of KMSKeyHandle
// +kcc:proto=google.cloud.kms.v1.KeyHandle
type KMSKeyHandleSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The KMS Key Handle ID used for resource creation or acquisition.
// For creation: If specified, this value is used as the key handle ID. If not provided, a UUID will be generated and assigned as the key handle ID.
// For acquisition: This field must be provided to identify the key handle resource to acquire.
Expand Down
2 changes: 0 additions & 2 deletions apis/privilegedaccessmanager/v1alpha1/entitlement_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ type PrivilegedAccessManagerEntitlementSpec struct {
// +required
Location *string `json:"location"`

// Immutable.
// The PrivilegedAccessManagerEntitlement name. If not given, the
// 'metadata.name' will be used.
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// +optional
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ type PrivilegedAccessManagerEntitlementSpec struct {
// Immutable.
// The PrivilegedAccessManagerEntitlement name. If not given, the
// 'metadata.name' will be used.
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// +optional
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/secretmanager/v1beta1/secret_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ var SecretManagerSecretGVK = GroupVersion.WithKind("SecretManagerSecret")
// SecretManagerSecretSpec defines the desired state of SecretManagerSecret
// +kcc:proto=google.cloud.secretmanager.v1.Secret
type SecretManagerSecretSpec struct {
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The SecretManagerSecret name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/securesourcemanager/v1alpha1/repository_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ type SecureSourceManagerRepositorySpec struct {
// +required
Location string `json:"location"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The SecureSourceManagerRepository name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/spanner/v1beta1/instance_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ type SpannerInstanceSpec struct {
// +optional
ProcessingUnits *int32 `json:"processingUnits,omitempty"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The SpannerInstance name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`
}
Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1alpha1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type WorkstationClusterSpec struct {
// The location of the cluster.
Location string `json:"location,omitempty"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The WorkstationCluster name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1alpha1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ type WorkstationConfigSpec struct {
// Parent is a reference to the parent WorkstationCluster for this WorkstationConfig.
Parent *WorkstationClusterRef `json:"parentRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The WorkstationConfig name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1alpha1/workstation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type WorkstationSpec struct {
// Parent is a reference to the parent WorkstationConfig for this Workstation.
Parent *WorkstationConfigRef `json:"parentRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The Workstation name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1beta1/cluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ type WorkstationClusterSpec struct {
// The location of the cluster.
Location string `json:"location,omitempty"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The WorkstationCluster name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1beta1/config_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,6 @@ type WorkstationConfigSpec struct {
// Parent is a reference to the parent WorkstationCluster for this WorkstationConfig.
Parent *WorkstationClusterRef `json:"parentRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The WorkstationConfig name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
2 changes: 0 additions & 2 deletions apis/workstations/v1beta1/workstation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ type WorkstationSpec struct {
// Parent is a reference to the parent WorkstationConfig for this Workstation.
Parent *WorkstationConfigRef `json:"parentRef"`

// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="ResourceID field is immutable"
// Immutable.
// The Workstation name. If not given, the metadata.name will be used.
ResourceID *string `json:"resourceID,omitempty"`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,9 @@ spec:
type: string
type: object
resourceID:
description: Immutable. The BigQueryDataTransferConfig name. If not
given, the metadata.name will be used.
description: The BigQueryDataTransferConfig name. If not given, the
metadata.name will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
schedule:
description: |-
Data transfer schedule.
Expand Down Expand Up @@ -621,12 +618,9 @@ spec:
type: string
type: object
resourceID:
description: Immutable. The BigQueryDataTransferConfig name. If not
given, the metadata.name will be used.
description: The BigQueryDataTransferConfig name. If not given, the
metadata.name will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
schedule:
description: |-
Data transfer schedule.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,10 @@ spec:
type: string
type: object
resourceID:
description: Immutable. Optional. The name of the resource. Used for
creation and acquisition. When unset, the value of `metadata.name`
is used as the default.
description: Optional. The name of the resource. Used for creation
and acquisition. When unset, the value of `metadata.name` is used
as the default.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- domain
- projectRef
Expand Down Expand Up @@ -270,13 +267,10 @@ spec:
type: string
type: object
resourceID:
description: Immutable. Optional. The name of the resource. Used for
creation and acquisition. When unset, the value of `metadata.name`
is used as the default.
description: Optional. The name of the resource. Used for creation
and acquisition. When unset, the value of `metadata.name` is used
as the default.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- domain
- projectRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,9 @@ spec:
["NONE", "PROXY_V1"].'
type: string
resourceID:
description: Immutable. The ComputeTargetTCPProxy name. If not given,
the metadata.name will be used.
description: The ComputeTargetTCPProxy name. If not given, the metadata.name
will be used.
type: string
x-kubernetes-validations:
- message: ResourceID is immutable
rule: self == oldSelf
required:
- backendServiceRef
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,9 @@ spec:
type: string
type: object
resourceID:
description: Immutable, Optional. The ContainerAttachedCluster name.
If not given, the metadata.name will be used.
description: Optional. The ContainerAttachedCluster name. If not given,
the metadata.name will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- distribution
- fleet
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,9 @@ spec:
type: string
type: object
resourceID:
description: Immutable. The DiscoveryEngineDataStore name. If not
given, the metadata.name will be used.
description: The DiscoveryEngineDataStore name. If not given, the
metadata.name will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
solutionTypes:
description: |-
The solutions that the data store enrolls. Available solutions for each
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,12 @@ spec:
type: string
type: object
resourceID:
description: 'Immutable. The KMS Key Handle ID used for resource creation
or acquisition. For creation: If specified, this value is used as
the key handle ID. If not provided, a UUID will be generated and
assigned as the key handle ID. For acquisition: This field must
be provided to identify the key handle resource to acquire.'
description: 'The KMS Key Handle ID used for resource creation or
acquisition. For creation: If specified, this value is used as the
key handle ID. If not provided, a UUID will be generated and assigned
as the key handle ID. For acquisition: This field must be provided
to identify the key handle resource to acquire.'
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
resourceTypeSelector:
description: Indicates the resource type that the resulting [CryptoKey][]
is meant to protect, e.g. `{SERVICE}.googleapis.com/{TYPE}`. See
Expand Down Expand Up @@ -239,15 +236,12 @@ spec:
type: string
type: object
resourceID:
description: 'Immutable. The KMS Key Handle ID used for resource creation
or acquisition. For creation: If specified, this value is used as
the key handle ID. If not provided, a UUID will be generated and
assigned as the key handle ID. For acquisition: This field must
be provided to identify the key handle resource to acquire.'
description: 'The KMS Key Handle ID used for resource creation or
acquisition. For creation: If specified, this value is used as the
key handle ID. If not provided, a UUID will be generated and assigned
as the key handle ID. For acquisition: This field must be provided
to identify the key handle resource to acquire.'
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
resourceTypeSelector:
description: Indicates the resource type that the resulting [CryptoKey][]
is meant to protect, e.g. `{SERVICE}.googleapis.com/{TYPE}`. See
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,9 @@ spec:
x-kubernetes-preserve-unknown-fields: true
type: object
resourceID:
description: Immutable. The PrivilegedAccessManagerEntitlement name.
If not given, the 'metadata.name' will be used.
description: The PrivilegedAccessManagerEntitlement name. If not given,
the 'metadata.name' will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- eligibleUsers
- location
Expand Down Expand Up @@ -673,9 +670,6 @@ spec:
description: Immutable. The PrivilegedAccessManagerEntitlement name.
If not given, the 'metadata.name' will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- eligibleUsers
- location
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,9 @@ spec:
type: object
type: object
resourceID:
description: Immutable. The SecretManagerSecret name. If not given,
the metadata.name will be used.
description: The SecretManagerSecret name. If not given, the metadata.name
will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
rotation:
description: Optional. Rotation policy attached to the [Secret][google.cloud.secretmanager.v1.Secret].
May be excluded if there is no rotation policy.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,9 @@ spec:
type: string
type: object
resourceID:
description: Immutable. The SecureSourceManagerRepository name. If
not given, the metadata.name will be used.
description: The SecureSourceManagerRepository name. If not given,
the metadata.name will be used.
type: string
x-kubernetes-validations:
- message: ResourceID field is immutable
rule: self == oldSelf
required:
- instanceRef
- location
Expand Down
Loading

0 comments on commit e8131e0

Please sign in to comment.