From 793ee09f338e5860dc5efca0bd68431ecfad7556 Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Tue, 24 Sep 2024 11:44:59 +0200 Subject: [PATCH 1/3] feat(redis): add Redis Cluster support This adds support for google_redis_cluster Terraform resource, see https://registry.terraform.io/providers/hashicorp/google/5.39.1/docs/resources/redis_cluster Signed-off-by: Rickard von Essen --- apis/redis/v1beta1/zz_cluster_terraformed.go | 129 +++ apis/redis/v1beta1/zz_cluster_types.go | 426 +++++++ .../v1beta1/zz_generated.conversion_hubs.go | 10 + apis/redis/v1beta1/zz_generated.deepcopy.go | 1006 +++++++++++++++-- apis/redis/v1beta1/zz_generated.managed.go | 60 + .../redis/v1beta1/zz_generated.managedlist.go | 9 + apis/redis/v1beta1/zz_generated.resolvers.go | 57 +- config/externalname.go | 2 + config/generated.lst | 2 +- config/redis/config.go | 46 +- examples-generated/redis/v1beta1/cluster.yaml | 78 ++ examples/redis/v1beta1/cluster.yaml | 78 ++ .../controller/redis/cluster/zz_controller.go | 92 ++ internal/controller/zz_monolith_setup.go | 2 + internal/controller/zz_redis_setup.go | 2 + .../crds/redis.gcp.upbound.io_clusters.yaml | 807 +++++++++++++ 16 files changed, 2707 insertions(+), 99 deletions(-) create mode 100755 apis/redis/v1beta1/zz_cluster_terraformed.go create mode 100755 apis/redis/v1beta1/zz_cluster_types.go create mode 100755 apis/redis/v1beta1/zz_generated.conversion_hubs.go create mode 100644 examples-generated/redis/v1beta1/cluster.yaml create mode 100644 examples/redis/v1beta1/cluster.yaml create mode 100755 internal/controller/redis/cluster/zz_controller.go create mode 100644 package/crds/redis.gcp.upbound.io_clusters.yaml diff --git a/apis/redis/v1beta1/zz_cluster_terraformed.go b/apis/redis/v1beta1/zz_cluster_terraformed.go new file mode 100755 index 000000000..32ceb38a7 --- /dev/null +++ b/apis/redis/v1beta1/zz_cluster_terraformed.go @@ -0,0 +1,129 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +import ( + "dario.cat/mergo" + "github.com/pkg/errors" + + "github.com/crossplane/upjet/pkg/resource" + "github.com/crossplane/upjet/pkg/resource/json" +) + +// GetTerraformResourceType returns Terraform resource type for this Cluster +func (mg *Cluster) GetTerraformResourceType() string { + return "google_redis_cluster" +} + +// GetConnectionDetailsMapping for this Cluster +func (tr *Cluster) GetConnectionDetailsMapping() map[string]string { + return nil +} + +// GetObservation of this Cluster +func (tr *Cluster) GetObservation() (map[string]any, error) { + o, err := json.TFParser.Marshal(tr.Status.AtProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(o, &base) +} + +// SetObservation for this Cluster +func (tr *Cluster) SetObservation(obs map[string]any) error { + p, err := json.TFParser.Marshal(obs) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Status.AtProvider) +} + +// GetID returns ID of underlying Terraform resource of this Cluster +func (tr *Cluster) GetID() string { + if tr.Status.AtProvider.ID == nil { + return "" + } + return *tr.Status.AtProvider.ID +} + +// GetParameters of this Cluster +func (tr *Cluster) GetParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.ForProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// SetParameters for this Cluster +func (tr *Cluster) SetParameters(params map[string]any) error { + p, err := json.TFParser.Marshal(params) + if err != nil { + return err + } + return json.TFParser.Unmarshal(p, &tr.Spec.ForProvider) +} + +// GetInitParameters of this Cluster +func (tr *Cluster) GetInitParameters() (map[string]any, error) { + p, err := json.TFParser.Marshal(tr.Spec.InitProvider) + if err != nil { + return nil, err + } + base := map[string]any{} + return base, json.TFParser.Unmarshal(p, &base) +} + +// GetInitParameters of this Cluster +func (tr *Cluster) GetMergedParameters(shouldMergeInitProvider bool) (map[string]any, error) { + params, err := tr.GetParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get parameters for resource '%q'", tr.GetName()) + } + if !shouldMergeInitProvider { + return params, nil + } + + initParams, err := tr.GetInitParameters() + if err != nil { + return nil, errors.Wrapf(err, "cannot get init parameters for resource '%q'", tr.GetName()) + } + + // Note(lsviben): mergo.WithSliceDeepCopy is needed to merge the + // slices from the initProvider to forProvider. As it also sets + // overwrite to true, we need to set it back to false, we don't + // want to overwrite the forProvider fields with the initProvider + // fields. + err = mergo.Merge(¶ms, initParams, mergo.WithSliceDeepCopy, func(c *mergo.Config) { + c.Overwrite = false + }) + if err != nil { + return nil, errors.Wrapf(err, "cannot merge spec.initProvider and spec.forProvider parameters for resource '%q'", tr.GetName()) + } + + return params, nil +} + +// LateInitialize this Cluster using its observed tfState. +// returns True if there are any spec changes for the resource. +func (tr *Cluster) LateInitialize(attrs []byte) (bool, error) { + params := &ClusterParameters{} + if err := json.TFParser.Unmarshal(attrs, params); err != nil { + return false, errors.Wrap(err, "failed to unmarshal Terraform state parameters for late-initialization") + } + opts := []resource.GenericLateInitializerOption{resource.WithZeroValueJSONOmitEmptyFilter(resource.CNameWildcard)} + + li := resource.NewGenericLateInitializer(opts...) + return li.LateInitialize(&tr.Spec.ForProvider, params) +} + +// GetTerraformSchemaVersion returns the associated Terraform schema version +func (tr *Cluster) GetTerraformSchemaVersion() int { + return 0 +} diff --git a/apis/redis/v1beta1/zz_cluster_types.go b/apis/redis/v1beta1/zz_cluster_types.go new file mode 100755 index 000000000..f0e66a5fb --- /dev/null +++ b/apis/redis/v1beta1/zz_cluster_types.go @@ -0,0 +1,426 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" + + v1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +) + +type ClusterInitParameters struct { + + // Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + // Default value is AUTH_MODE_DISABLED. + // Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + AuthorizationMode *string `json:"authorizationMode,omitempty" tf:"authorization_mode,omitempty"` + + // The nodeType for the Redis cluster. + // If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + // Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + NodeType *string `json:"nodeType,omitempty" tf:"node_type,omitempty"` + + // The ID of the project in which the resource belongs. + // If it is not provided, the provider project is used. + Project *string `json:"project,omitempty" tf:"project,omitempty"` + + // Required. Each PscConfig configures the consumer network where two + // network addresses will be designated to the cluster for client access. + // Currently, only one PscConfig is supported. + // Structure is documented below. + PscConfigs []PscConfigsInitParameters `json:"pscConfigs,omitempty" tf:"psc_configs,omitempty"` + + // Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + // Please check Memorystore documentation for the list of supported parameters: + // https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + // +mapType=granular + RedisConfigs map[string]*string `json:"redisConfigs,omitempty" tf:"redis_configs,omitempty"` + + // Optional. The number of replica nodes per shard. + ReplicaCount *float64 `json:"replicaCount,omitempty" tf:"replica_count,omitempty"` + + // Required. Number of shards for the Redis cluster. + ShardCount *float64 `json:"shardCount,omitempty" tf:"shard_count,omitempty"` + + // Optional. The in-transit encryption for the Redis cluster. + // If not provided, encryption is disabled for the cluster. + // Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + // Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + TransitEncryptionMode *string `json:"transitEncryptionMode,omitempty" tf:"transit_encryption_mode,omitempty"` + + // Immutable. Zone distribution config for Memorystore Redis cluster. + // Structure is documented below. + ZoneDistributionConfig *ZoneDistributionConfigInitParameters `json:"zoneDistributionConfig,omitempty" tf:"zone_distribution_config,omitempty"` +} + +type ClusterObservation struct { + + // Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + // Default value is AUTH_MODE_DISABLED. + // Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + AuthorizationMode *string `json:"authorizationMode,omitempty" tf:"authorization_mode,omitempty"` + + // The timestamp associated with the cluster creation request. A timestamp in + // RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional + // digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". + CreateTime *string `json:"createTime,omitempty" tf:"create_time,omitempty"` + + // Output only. Endpoints created on each given network, + // for Redis clients to connect to the cluster. + // Currently only one endpoint is supported. + // Structure is documented below. + DiscoveryEndpoints []DiscoveryEndpointsObservation `json:"discoveryEndpoints,omitempty" tf:"discovery_endpoints,omitempty"` + + // an identifier for the resource with format projects/{{project}}/locations/{{region}}/clusters/{{name}} + ID *string `json:"id,omitempty" tf:"id,omitempty"` + + // The nodeType for the Redis cluster. + // If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + // Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + NodeType *string `json:"nodeType,omitempty" tf:"node_type,omitempty"` + + // Output only. Redis memory precise size in GB for the entire cluster. + PreciseSizeGb *float64 `json:"preciseSizeGb,omitempty" tf:"precise_size_gb,omitempty"` + + // The ID of the project in which the resource belongs. + // If it is not provided, the provider project is used. + Project *string `json:"project,omitempty" tf:"project,omitempty"` + + // Required. Each PscConfig configures the consumer network where two + // network addresses will be designated to the cluster for client access. + // Currently, only one PscConfig is supported. + // Structure is documented below. + PscConfigs []PscConfigsObservation `json:"pscConfigs,omitempty" tf:"psc_configs,omitempty"` + + // Output only. PSC connections for discovery of the cluster topology and accessing the cluster. + // Structure is documented below. + PscConnections []PscConnectionsObservation `json:"pscConnections,omitempty" tf:"psc_connections,omitempty"` + + // Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + // Please check Memorystore documentation for the list of supported parameters: + // https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + // +mapType=granular + RedisConfigs map[string]*string `json:"redisConfigs,omitempty" tf:"redis_configs,omitempty"` + + // The name of the region of the Redis cluster. + Region *string `json:"region,omitempty" tf:"region,omitempty"` + + // Optional. The number of replica nodes per shard. + ReplicaCount *float64 `json:"replicaCount,omitempty" tf:"replica_count,omitempty"` + + // Required. Number of shards for the Redis cluster. + ShardCount *float64 `json:"shardCount,omitempty" tf:"shard_count,omitempty"` + + // Output only. Redis memory size in GB for the entire cluster. + SizeGb *float64 `json:"sizeGb,omitempty" tf:"size_gb,omitempty"` + + // The current state of this cluster. Can be CREATING, READY, UPDATING, DELETING and SUSPENDED + State *string `json:"state,omitempty" tf:"state,omitempty"` + + // Output only. Additional information about the current state of the cluster. + // Structure is documented below. + StateInfo []StateInfoObservation `json:"stateInfo,omitempty" tf:"state_info,omitempty"` + + // Optional. The in-transit encryption for the Redis cluster. + // If not provided, encryption is disabled for the cluster. + // Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + // Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + TransitEncryptionMode *string `json:"transitEncryptionMode,omitempty" tf:"transit_encryption_mode,omitempty"` + + // System assigned, unique identifier for the cluster. + UID *string `json:"uid,omitempty" tf:"uid,omitempty"` + + // Immutable. Zone distribution config for Memorystore Redis cluster. + // Structure is documented below. + ZoneDistributionConfig *ZoneDistributionConfigObservation `json:"zoneDistributionConfig,omitempty" tf:"zone_distribution_config,omitempty"` +} + +type ClusterParameters struct { + + // Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + // Default value is AUTH_MODE_DISABLED. + // Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + // +kubebuilder:validation:Optional + AuthorizationMode *string `json:"authorizationMode,omitempty" tf:"authorization_mode,omitempty"` + + // The nodeType for the Redis cluster. + // If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + // Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + // +kubebuilder:validation:Optional + NodeType *string `json:"nodeType,omitempty" tf:"node_type,omitempty"` + + // The ID of the project in which the resource belongs. + // If it is not provided, the provider project is used. + // +kubebuilder:validation:Optional + Project *string `json:"project,omitempty" tf:"project,omitempty"` + + // Required. Each PscConfig configures the consumer network where two + // network addresses will be designated to the cluster for client access. + // Currently, only one PscConfig is supported. + // Structure is documented below. + // +kubebuilder:validation:Optional + PscConfigs []PscConfigsParameters `json:"pscConfigs,omitempty" tf:"psc_configs,omitempty"` + + // Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + // Please check Memorystore documentation for the list of supported parameters: + // https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + // +kubebuilder:validation:Optional + // +mapType=granular + RedisConfigs map[string]*string `json:"redisConfigs,omitempty" tf:"redis_configs,omitempty"` + + // The name of the region of the Redis cluster. + // +kubebuilder:validation:Required + Region *string `json:"region" tf:"region,omitempty"` + + // Optional. The number of replica nodes per shard. + // +kubebuilder:validation:Optional + ReplicaCount *float64 `json:"replicaCount,omitempty" tf:"replica_count,omitempty"` + + // Required. Number of shards for the Redis cluster. + // +kubebuilder:validation:Optional + ShardCount *float64 `json:"shardCount,omitempty" tf:"shard_count,omitempty"` + + // Optional. The in-transit encryption for the Redis cluster. + // If not provided, encryption is disabled for the cluster. + // Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + // Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + // +kubebuilder:validation:Optional + TransitEncryptionMode *string `json:"transitEncryptionMode,omitempty" tf:"transit_encryption_mode,omitempty"` + + // Immutable. Zone distribution config for Memorystore Redis cluster. + // Structure is documented below. + // +kubebuilder:validation:Optional + ZoneDistributionConfig *ZoneDistributionConfigParameters `json:"zoneDistributionConfig,omitempty" tf:"zone_distribution_config,omitempty"` +} + +type DiscoveryEndpointsInitParameters struct { +} + +type DiscoveryEndpointsObservation struct { + + // Output only. Network address of the exposed Redis endpoint used by clients to connect to the service. + Address *string `json:"address,omitempty" tf:"address,omitempty"` + + // Output only. The port number of the exposed Redis endpoint. + Port *float64 `json:"port,omitempty" tf:"port,omitempty"` + + // Output only. Customer configuration for where the endpoint + // is created and accessed from. + // Structure is documented below. + PscConfig *PscConfigObservation `json:"pscConfig,omitempty" tf:"psc_config,omitempty"` +} + +type DiscoveryEndpointsParameters struct { +} + +type PscConfigInitParameters struct { +} + +type PscConfigObservation struct { + + // The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}. + Network *string `json:"network,omitempty" tf:"network,omitempty"` +} + +type PscConfigParameters struct { +} + +type PscConfigsInitParameters struct { + + // Required. The consumer network where the network address of + // the discovery endpoint will be reserved, in the form of + // projects/{network_project_id_or_number}/global/networks/{network_id}. + // +crossplane:generate:reference:type=github.com/upbound/provider-gcp/apis/compute/v1beta1.Network + // +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractResourceID() + Network *string `json:"network,omitempty" tf:"network,omitempty"` + + // Reference to a Network in compute to populate network. + // +kubebuilder:validation:Optional + NetworkRef *v1.Reference `json:"networkRef,omitempty" tf:"-"` + + // Selector for a Network in compute to populate network. + // +kubebuilder:validation:Optional + NetworkSelector *v1.Selector `json:"networkSelector,omitempty" tf:"-"` +} + +type PscConfigsObservation struct { + + // Required. The consumer network where the network address of + // the discovery endpoint will be reserved, in the form of + // projects/{network_project_id_or_number}/global/networks/{network_id}. + Network *string `json:"network,omitempty" tf:"network,omitempty"` +} + +type PscConfigsParameters struct { + + // Required. The consumer network where the network address of + // the discovery endpoint will be reserved, in the form of + // projects/{network_project_id_or_number}/global/networks/{network_id}. + // +crossplane:generate:reference:type=github.com/upbound/provider-gcp/apis/compute/v1beta1.Network + // +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractResourceID() + // +kubebuilder:validation:Optional + Network *string `json:"network,omitempty" tf:"network,omitempty"` + + // Reference to a Network in compute to populate network. + // +kubebuilder:validation:Optional + NetworkRef *v1.Reference `json:"networkRef,omitempty" tf:"-"` + + // Selector for a Network in compute to populate network. + // +kubebuilder:validation:Optional + NetworkSelector *v1.Selector `json:"networkSelector,omitempty" tf:"-"` +} + +type PscConnectionsInitParameters struct { +} + +type PscConnectionsObservation struct { + + // Output only. The IP allocated on the consumer network for the PSC forwarding rule. + Address *string `json:"address,omitempty" tf:"address,omitempty"` + + // Output only. The URI of the consumer side forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}. + ForwardingRule *string `json:"forwardingRule,omitempty" tf:"forwarding_rule,omitempty"` + + // The consumer network where the IP address resides, in the form of projects/{projectId}/global/networks/{network_id}. + Network *string `json:"network,omitempty" tf:"network,omitempty"` + + // Output only. The consumer projectId where the forwarding rule is created from. + ProjectID *string `json:"projectId,omitempty" tf:"project_id,omitempty"` + + // Output only. The PSC connection id of the forwarding rule connected to the service attachment. + PscConnectionID *string `json:"pscConnectionId,omitempty" tf:"psc_connection_id,omitempty"` +} + +type PscConnectionsParameters struct { +} + +type StateInfoInitParameters struct { +} + +type StateInfoObservation struct { + + // A nested object resource + // Structure is documented below. + UpdateInfo *UpdateInfoObservation `json:"updateInfo,omitempty" tf:"update_info,omitempty"` +} + +type StateInfoParameters struct { +} + +type UpdateInfoInitParameters struct { +} + +type UpdateInfoObservation struct { + + // Target number of replica nodes per shard. + TargetReplicaCount *float64 `json:"targetReplicaCount,omitempty" tf:"target_replica_count,omitempty"` + + // Target number of shards for redis cluster. + TargetShardCount *float64 `json:"targetShardCount,omitempty" tf:"target_shard_count,omitempty"` +} + +type UpdateInfoParameters struct { +} + +type ZoneDistributionConfigInitParameters struct { + + // Immutable. The mode for zone distribution for Memorystore Redis cluster. + // If not provided, MULTI_ZONE will be used as default + // Possible values are: MULTI_ZONE, SINGLE_ZONE. + Mode *string `json:"mode,omitempty" tf:"mode,omitempty"` + + // Immutable. The zone for single zone Memorystore Redis cluster. + Zone *string `json:"zone,omitempty" tf:"zone,omitempty"` +} + +type ZoneDistributionConfigObservation struct { + + // Immutable. The mode for zone distribution for Memorystore Redis cluster. + // If not provided, MULTI_ZONE will be used as default + // Possible values are: MULTI_ZONE, SINGLE_ZONE. + Mode *string `json:"mode,omitempty" tf:"mode,omitempty"` + + // Immutable. The zone for single zone Memorystore Redis cluster. + Zone *string `json:"zone,omitempty" tf:"zone,omitempty"` +} + +type ZoneDistributionConfigParameters struct { + + // Immutable. The mode for zone distribution for Memorystore Redis cluster. + // If not provided, MULTI_ZONE will be used as default + // Possible values are: MULTI_ZONE, SINGLE_ZONE. + // +kubebuilder:validation:Optional + Mode *string `json:"mode,omitempty" tf:"mode,omitempty"` + + // Immutable. The zone for single zone Memorystore Redis cluster. + // +kubebuilder:validation:Optional + Zone *string `json:"zone,omitempty" tf:"zone,omitempty"` +} + +// ClusterSpec defines the desired state of Cluster +type ClusterSpec struct { + v1.ResourceSpec `json:",inline"` + ForProvider ClusterParameters `json:"forProvider"` + // THIS IS A BETA FIELD. It will be honored + // unless the Management Policies feature flag is disabled. + // InitProvider holds the same fields as ForProvider, with the exception + // of Identifier and other resource reference fields. The fields that are + // in InitProvider are merged into ForProvider when the resource is created. + // The same fields are also added to the terraform ignore_changes hook, to + // avoid updating them after creation. This is useful for fields that are + // required on creation, but we do not desire to update them after creation, + // for example because of an external controller is managing them, like an + // autoscaler. + InitProvider ClusterInitParameters `json:"initProvider,omitempty"` +} + +// ClusterStatus defines the observed state of Cluster. +type ClusterStatus struct { + v1.ResourceStatus `json:",inline"` + AtProvider ClusterObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion + +// Cluster is the Schema for the Clusters API. A Google Cloud Redis Cluster instance. +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:printcolumn:name="AGE",type="date",JSONPath=".metadata.creationTimestamp" +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,gcp} +type Cluster struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.pscConfigs) || (has(self.initProvider) && has(self.initProvider.pscConfigs))",message="spec.forProvider.pscConfigs is a required parameter" + // +kubebuilder:validation:XValidation:rule="!('*' in self.managementPolicies || 'Create' in self.managementPolicies || 'Update' in self.managementPolicies) || has(self.forProvider.shardCount) || (has(self.initProvider) && has(self.initProvider.shardCount))",message="spec.forProvider.shardCount is a required parameter" + Spec ClusterSpec `json:"spec"` + Status ClusterStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// ClusterList contains a list of Clusters +type ClusterList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Cluster `json:"items"` +} + +// Repository type metadata. +var ( + Cluster_Kind = "Cluster" + Cluster_GroupKind = schema.GroupKind{Group: CRDGroup, Kind: Cluster_Kind}.String() + Cluster_KindAPIVersion = Cluster_Kind + "." + CRDGroupVersion.String() + Cluster_GroupVersionKind = CRDGroupVersion.WithKind(Cluster_Kind) +) + +func init() { + SchemeBuilder.Register(&Cluster{}, &ClusterList{}) +} diff --git a/apis/redis/v1beta1/zz_generated.conversion_hubs.go b/apis/redis/v1beta1/zz_generated.conversion_hubs.go new file mode 100755 index 000000000..9f962cae0 --- /dev/null +++ b/apis/redis/v1beta1/zz_generated.conversion_hubs.go @@ -0,0 +1,10 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package v1beta1 + +// Hub marks this type as a conversion hub. +func (tr *Cluster) Hub() {} diff --git a/apis/redis/v1beta1/zz_generated.deepcopy.go b/apis/redis/v1beta1/zz_generated.deepcopy.go index 069d49bfa..fec5ad9f7 100644 --- a/apis/redis/v1beta1/zz_generated.deepcopy.go +++ b/apis/redis/v1beta1/zz_generated.deepcopy.go @@ -13,6 +13,440 @@ import ( runtime "k8s.io/apimachinery/pkg/runtime" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Cluster) DeepCopyInto(out *Cluster) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Cluster. +func (in *Cluster) DeepCopy() *Cluster { + if in == nil { + return nil + } + out := new(Cluster) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Cluster) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterInitParameters) DeepCopyInto(out *ClusterInitParameters) { + *out = *in + if in.AuthorizationMode != nil { + in, out := &in.AuthorizationMode, &out.AuthorizationMode + *out = new(string) + **out = **in + } + if in.NodeType != nil { + in, out := &in.NodeType, &out.NodeType + *out = new(string) + **out = **in + } + if in.Project != nil { + in, out := &in.Project, &out.Project + *out = new(string) + **out = **in + } + if in.PscConfigs != nil { + in, out := &in.PscConfigs, &out.PscConfigs + *out = make([]PscConfigsInitParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RedisConfigs != nil { + in, out := &in.RedisConfigs, &out.RedisConfigs + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } + if in.ReplicaCount != nil { + in, out := &in.ReplicaCount, &out.ReplicaCount + *out = new(float64) + **out = **in + } + if in.ShardCount != nil { + in, out := &in.ShardCount, &out.ShardCount + *out = new(float64) + **out = **in + } + if in.TransitEncryptionMode != nil { + in, out := &in.TransitEncryptionMode, &out.TransitEncryptionMode + *out = new(string) + **out = **in + } + if in.ZoneDistributionConfig != nil { + in, out := &in.ZoneDistributionConfig, &out.ZoneDistributionConfig + *out = new(ZoneDistributionConfigInitParameters) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterInitParameters. +func (in *ClusterInitParameters) DeepCopy() *ClusterInitParameters { + if in == nil { + return nil + } + out := new(ClusterInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterList) DeepCopyInto(out *ClusterList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Cluster, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterList. +func (in *ClusterList) DeepCopy() *ClusterList { + if in == nil { + return nil + } + out := new(ClusterList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterObservation) DeepCopyInto(out *ClusterObservation) { + *out = *in + if in.AuthorizationMode != nil { + in, out := &in.AuthorizationMode, &out.AuthorizationMode + *out = new(string) + **out = **in + } + if in.CreateTime != nil { + in, out := &in.CreateTime, &out.CreateTime + *out = new(string) + **out = **in + } + if in.DiscoveryEndpoints != nil { + in, out := &in.DiscoveryEndpoints, &out.DiscoveryEndpoints + *out = make([]DiscoveryEndpointsObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.NodeType != nil { + in, out := &in.NodeType, &out.NodeType + *out = new(string) + **out = **in + } + if in.PreciseSizeGb != nil { + in, out := &in.PreciseSizeGb, &out.PreciseSizeGb + *out = new(float64) + **out = **in + } + if in.Project != nil { + in, out := &in.Project, &out.Project + *out = new(string) + **out = **in + } + if in.PscConfigs != nil { + in, out := &in.PscConfigs, &out.PscConfigs + *out = make([]PscConfigsObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.PscConnections != nil { + in, out := &in.PscConnections, &out.PscConnections + *out = make([]PscConnectionsObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RedisConfigs != nil { + in, out := &in.RedisConfigs, &out.RedisConfigs + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in + } + if in.ReplicaCount != nil { + in, out := &in.ReplicaCount, &out.ReplicaCount + *out = new(float64) + **out = **in + } + if in.ShardCount != nil { + in, out := &in.ShardCount, &out.ShardCount + *out = new(float64) + **out = **in + } + if in.SizeGb != nil { + in, out := &in.SizeGb, &out.SizeGb + *out = new(float64) + **out = **in + } + if in.State != nil { + in, out := &in.State, &out.State + *out = new(string) + **out = **in + } + if in.StateInfo != nil { + in, out := &in.StateInfo, &out.StateInfo + *out = make([]StateInfoObservation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.TransitEncryptionMode != nil { + in, out := &in.TransitEncryptionMode, &out.TransitEncryptionMode + *out = new(string) + **out = **in + } + if in.UID != nil { + in, out := &in.UID, &out.UID + *out = new(string) + **out = **in + } + if in.ZoneDistributionConfig != nil { + in, out := &in.ZoneDistributionConfig, &out.ZoneDistributionConfig + *out = new(ZoneDistributionConfigObservation) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterObservation. +func (in *ClusterObservation) DeepCopy() *ClusterObservation { + if in == nil { + return nil + } + out := new(ClusterObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterParameters) DeepCopyInto(out *ClusterParameters) { + *out = *in + if in.AuthorizationMode != nil { + in, out := &in.AuthorizationMode, &out.AuthorizationMode + *out = new(string) + **out = **in + } + if in.NodeType != nil { + in, out := &in.NodeType, &out.NodeType + *out = new(string) + **out = **in + } + if in.Project != nil { + in, out := &in.Project, &out.Project + *out = new(string) + **out = **in + } + if in.PscConfigs != nil { + in, out := &in.PscConfigs, &out.PscConfigs + *out = make([]PscConfigsParameters, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.RedisConfigs != nil { + in, out := &in.RedisConfigs, &out.RedisConfigs + *out = make(map[string]*string, len(*in)) + for key, val := range *in { + var outVal *string + if val == nil { + (*out)[key] = nil + } else { + inVal := (*in)[key] + in, out := &inVal, &outVal + *out = new(string) + **out = **in + } + (*out)[key] = outVal + } + } + if in.Region != nil { + in, out := &in.Region, &out.Region + *out = new(string) + **out = **in + } + if in.ReplicaCount != nil { + in, out := &in.ReplicaCount, &out.ReplicaCount + *out = new(float64) + **out = **in + } + if in.ShardCount != nil { + in, out := &in.ShardCount, &out.ShardCount + *out = new(float64) + **out = **in + } + if in.TransitEncryptionMode != nil { + in, out := &in.TransitEncryptionMode, &out.TransitEncryptionMode + *out = new(string) + **out = **in + } + if in.ZoneDistributionConfig != nil { + in, out := &in.ZoneDistributionConfig, &out.ZoneDistributionConfig + *out = new(ZoneDistributionConfigParameters) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterParameters. +func (in *ClusterParameters) DeepCopy() *ClusterParameters { + if in == nil { + return nil + } + out := new(ClusterParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterSpec) DeepCopyInto(out *ClusterSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) + in.InitProvider.DeepCopyInto(&out.InitProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterSpec. +func (in *ClusterSpec) DeepCopy() *ClusterSpec { + if in == nil { + return nil + } + out := new(ClusterSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStatus) DeepCopyInto(out *ClusterStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStatus. +func (in *ClusterStatus) DeepCopy() *ClusterStatus { + if in == nil { + return nil + } + out := new(ClusterStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEndpointsInitParameters) DeepCopyInto(out *DiscoveryEndpointsInitParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEndpointsInitParameters. +func (in *DiscoveryEndpointsInitParameters) DeepCopy() *DiscoveryEndpointsInitParameters { + if in == nil { + return nil + } + out := new(DiscoveryEndpointsInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEndpointsObservation) DeepCopyInto(out *DiscoveryEndpointsObservation) { + *out = *in + if in.Address != nil { + in, out := &in.Address, &out.Address + *out = new(string) + **out = **in + } + if in.Port != nil { + in, out := &in.Port, &out.Port + *out = new(float64) + **out = **in + } + if in.PscConfig != nil { + in, out := &in.PscConfig, &out.PscConfig + *out = new(PscConfigObservation) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEndpointsObservation. +func (in *DiscoveryEndpointsObservation) DeepCopy() *DiscoveryEndpointsObservation { + if in == nil { + return nil + } + out := new(DiscoveryEndpointsObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DiscoveryEndpointsParameters) DeepCopyInto(out *DiscoveryEndpointsParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DiscoveryEndpointsParameters. +func (in *DiscoveryEndpointsParameters) DeepCopy() *DiscoveryEndpointsParameters { + if in == nil { + return nil + } + out := new(DiscoveryEndpointsParameters) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Instance) DeepCopyInto(out *Instance) { *out = *in @@ -769,222 +1203,422 @@ func (in *MaintenancePolicyParameters) DeepCopyInto(out *MaintenancePolicyParame } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenancePolicyParameters. -func (in *MaintenancePolicyParameters) DeepCopy() *MaintenancePolicyParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenancePolicyParameters. +func (in *MaintenancePolicyParameters) DeepCopy() *MaintenancePolicyParameters { + if in == nil { + return nil + } + out := new(MaintenancePolicyParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MaintenanceScheduleInitParameters) DeepCopyInto(out *MaintenanceScheduleInitParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleInitParameters. +func (in *MaintenanceScheduleInitParameters) DeepCopy() *MaintenanceScheduleInitParameters { + if in == nil { + return nil + } + out := new(MaintenanceScheduleInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MaintenanceScheduleObservation) DeepCopyInto(out *MaintenanceScheduleObservation) { + *out = *in + if in.EndTime != nil { + in, out := &in.EndTime, &out.EndTime + *out = new(string) + **out = **in + } + if in.ScheduleDeadlineTime != nil { + in, out := &in.ScheduleDeadlineTime, &out.ScheduleDeadlineTime + *out = new(string) + **out = **in + } + if in.StartTime != nil { + in, out := &in.StartTime, &out.StartTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleObservation. +func (in *MaintenanceScheduleObservation) DeepCopy() *MaintenanceScheduleObservation { + if in == nil { + return nil + } + out := new(MaintenanceScheduleObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MaintenanceScheduleParameters) DeepCopyInto(out *MaintenanceScheduleParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleParameters. +func (in *MaintenanceScheduleParameters) DeepCopy() *MaintenanceScheduleParameters { + if in == nil { + return nil + } + out := new(MaintenanceScheduleParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodesInitParameters) DeepCopyInto(out *NodesInitParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesInitParameters. +func (in *NodesInitParameters) DeepCopy() *NodesInitParameters { + if in == nil { + return nil + } + out := new(NodesInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodesObservation) DeepCopyInto(out *NodesObservation) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.Zone != nil { + in, out := &in.Zone, &out.Zone + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesObservation. +func (in *NodesObservation) DeepCopy() *NodesObservation { + if in == nil { + return nil + } + out := new(NodesObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodesParameters) DeepCopyInto(out *NodesParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesParameters. +func (in *NodesParameters) DeepCopy() *NodesParameters { + if in == nil { + return nil + } + out := new(NodesParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistenceConfigInitParameters) DeepCopyInto(out *PersistenceConfigInitParameters) { + *out = *in + if in.PersistenceMode != nil { + in, out := &in.PersistenceMode, &out.PersistenceMode + *out = new(string) + **out = **in + } + if in.RdbSnapshotPeriod != nil { + in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod + *out = new(string) + **out = **in + } + if in.RdbSnapshotStartTime != nil { + in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigInitParameters. +func (in *PersistenceConfigInitParameters) DeepCopy() *PersistenceConfigInitParameters { + if in == nil { + return nil + } + out := new(PersistenceConfigInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistenceConfigObservation) DeepCopyInto(out *PersistenceConfigObservation) { + *out = *in + if in.PersistenceMode != nil { + in, out := &in.PersistenceMode, &out.PersistenceMode + *out = new(string) + **out = **in + } + if in.RdbNextSnapshotTime != nil { + in, out := &in.RdbNextSnapshotTime, &out.RdbNextSnapshotTime + *out = new(string) + **out = **in + } + if in.RdbSnapshotPeriod != nil { + in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod + *out = new(string) + **out = **in + } + if in.RdbSnapshotStartTime != nil { + in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigObservation. +func (in *PersistenceConfigObservation) DeepCopy() *PersistenceConfigObservation { + if in == nil { + return nil + } + out := new(PersistenceConfigObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PersistenceConfigParameters) DeepCopyInto(out *PersistenceConfigParameters) { + *out = *in + if in.PersistenceMode != nil { + in, out := &in.PersistenceMode, &out.PersistenceMode + *out = new(string) + **out = **in + } + if in.RdbSnapshotPeriod != nil { + in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod + *out = new(string) + **out = **in + } + if in.RdbSnapshotStartTime != nil { + in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigParameters. +func (in *PersistenceConfigParameters) DeepCopy() *PersistenceConfigParameters { if in == nil { return nil } - out := new(MaintenancePolicyParameters) + out := new(PersistenceConfigParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MaintenanceScheduleInitParameters) DeepCopyInto(out *MaintenanceScheduleInitParameters) { +func (in *PscConfigInitParameters) DeepCopyInto(out *PscConfigInitParameters) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleInitParameters. -func (in *MaintenanceScheduleInitParameters) DeepCopy() *MaintenanceScheduleInitParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigInitParameters. +func (in *PscConfigInitParameters) DeepCopy() *PscConfigInitParameters { if in == nil { return nil } - out := new(MaintenanceScheduleInitParameters) + out := new(PscConfigInitParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MaintenanceScheduleObservation) DeepCopyInto(out *MaintenanceScheduleObservation) { +func (in *PscConfigObservation) DeepCopyInto(out *PscConfigObservation) { *out = *in - if in.EndTime != nil { - in, out := &in.EndTime, &out.EndTime - *out = new(string) - **out = **in - } - if in.ScheduleDeadlineTime != nil { - in, out := &in.ScheduleDeadlineTime, &out.ScheduleDeadlineTime - *out = new(string) - **out = **in - } - if in.StartTime != nil { - in, out := &in.StartTime, &out.StartTime + if in.Network != nil { + in, out := &in.Network, &out.Network *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleObservation. -func (in *MaintenanceScheduleObservation) DeepCopy() *MaintenanceScheduleObservation { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigObservation. +func (in *PscConfigObservation) DeepCopy() *PscConfigObservation { if in == nil { return nil } - out := new(MaintenanceScheduleObservation) + out := new(PscConfigObservation) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MaintenanceScheduleParameters) DeepCopyInto(out *MaintenanceScheduleParameters) { +func (in *PscConfigParameters) DeepCopyInto(out *PscConfigParameters) { *out = *in } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MaintenanceScheduleParameters. -func (in *MaintenanceScheduleParameters) DeepCopy() *MaintenanceScheduleParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigParameters. +func (in *PscConfigParameters) DeepCopy() *PscConfigParameters { if in == nil { return nil } - out := new(MaintenanceScheduleParameters) + out := new(PscConfigParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodesInitParameters) DeepCopyInto(out *NodesInitParameters) { +func (in *PscConfigsInitParameters) DeepCopyInto(out *PscConfigsInitParameters) { *out = *in + if in.Network != nil { + in, out := &in.Network, &out.Network + *out = new(string) + **out = **in + } + if in.NetworkRef != nil { + in, out := &in.NetworkRef, &out.NetworkRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.NetworkSelector != nil { + in, out := &in.NetworkSelector, &out.NetworkSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesInitParameters. -func (in *NodesInitParameters) DeepCopy() *NodesInitParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigsInitParameters. +func (in *PscConfigsInitParameters) DeepCopy() *PscConfigsInitParameters { if in == nil { return nil } - out := new(NodesInitParameters) + out := new(PscConfigsInitParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodesObservation) DeepCopyInto(out *NodesObservation) { +func (in *PscConfigsObservation) DeepCopyInto(out *PscConfigsObservation) { *out = *in - if in.ID != nil { - in, out := &in.ID, &out.ID - *out = new(string) - **out = **in - } - if in.Zone != nil { - in, out := &in.Zone, &out.Zone + if in.Network != nil { + in, out := &in.Network, &out.Network *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesObservation. -func (in *NodesObservation) DeepCopy() *NodesObservation { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigsObservation. +func (in *PscConfigsObservation) DeepCopy() *PscConfigsObservation { if in == nil { return nil } - out := new(NodesObservation) + out := new(PscConfigsObservation) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NodesParameters) DeepCopyInto(out *NodesParameters) { +func (in *PscConfigsParameters) DeepCopyInto(out *PscConfigsParameters) { *out = *in + if in.Network != nil { + in, out := &in.Network, &out.Network + *out = new(string) + **out = **in + } + if in.NetworkRef != nil { + in, out := &in.NetworkRef, &out.NetworkRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.NetworkSelector != nil { + in, out := &in.NetworkSelector, &out.NetworkSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodesParameters. -func (in *NodesParameters) DeepCopy() *NodesParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConfigsParameters. +func (in *PscConfigsParameters) DeepCopy() *PscConfigsParameters { if in == nil { return nil } - out := new(NodesParameters) + out := new(PscConfigsParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistenceConfigInitParameters) DeepCopyInto(out *PersistenceConfigInitParameters) { +func (in *PscConnectionsInitParameters) DeepCopyInto(out *PscConnectionsInitParameters) { *out = *in - if in.PersistenceMode != nil { - in, out := &in.PersistenceMode, &out.PersistenceMode - *out = new(string) - **out = **in - } - if in.RdbSnapshotPeriod != nil { - in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod - *out = new(string) - **out = **in - } - if in.RdbSnapshotStartTime != nil { - in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime - *out = new(string) - **out = **in - } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigInitParameters. -func (in *PersistenceConfigInitParameters) DeepCopy() *PersistenceConfigInitParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConnectionsInitParameters. +func (in *PscConnectionsInitParameters) DeepCopy() *PscConnectionsInitParameters { if in == nil { return nil } - out := new(PersistenceConfigInitParameters) + out := new(PscConnectionsInitParameters) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistenceConfigObservation) DeepCopyInto(out *PersistenceConfigObservation) { +func (in *PscConnectionsObservation) DeepCopyInto(out *PscConnectionsObservation) { *out = *in - if in.PersistenceMode != nil { - in, out := &in.PersistenceMode, &out.PersistenceMode + if in.Address != nil { + in, out := &in.Address, &out.Address *out = new(string) **out = **in } - if in.RdbNextSnapshotTime != nil { - in, out := &in.RdbNextSnapshotTime, &out.RdbNextSnapshotTime + if in.ForwardingRule != nil { + in, out := &in.ForwardingRule, &out.ForwardingRule *out = new(string) **out = **in } - if in.RdbSnapshotPeriod != nil { - in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod + if in.Network != nil { + in, out := &in.Network, &out.Network *out = new(string) **out = **in } - if in.RdbSnapshotStartTime != nil { - in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime + if in.ProjectID != nil { + in, out := &in.ProjectID, &out.ProjectID + *out = new(string) + **out = **in + } + if in.PscConnectionID != nil { + in, out := &in.PscConnectionID, &out.PscConnectionID *out = new(string) **out = **in } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigObservation. -func (in *PersistenceConfigObservation) DeepCopy() *PersistenceConfigObservation { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConnectionsObservation. +func (in *PscConnectionsObservation) DeepCopy() *PscConnectionsObservation { if in == nil { return nil } - out := new(PersistenceConfigObservation) + out := new(PscConnectionsObservation) in.DeepCopyInto(out) return out } // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *PersistenceConfigParameters) DeepCopyInto(out *PersistenceConfigParameters) { +func (in *PscConnectionsParameters) DeepCopyInto(out *PscConnectionsParameters) { *out = *in - if in.PersistenceMode != nil { - in, out := &in.PersistenceMode, &out.PersistenceMode - *out = new(string) - **out = **in - } - if in.RdbSnapshotPeriod != nil { - in, out := &in.RdbSnapshotPeriod, &out.RdbSnapshotPeriod - *out = new(string) - **out = **in - } - if in.RdbSnapshotStartTime != nil { - in, out := &in.RdbSnapshotStartTime, &out.RdbSnapshotStartTime - *out = new(string) - **out = **in - } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PersistenceConfigParameters. -func (in *PersistenceConfigParameters) DeepCopy() *PersistenceConfigParameters { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PscConnectionsParameters. +func (in *PscConnectionsParameters) DeepCopy() *PscConnectionsParameters { if in == nil { return nil } - out := new(PersistenceConfigParameters) + out := new(PscConnectionsParameters) in.DeepCopyInto(out) return out } @@ -1164,6 +1798,111 @@ func (in *StartTimeParameters) DeepCopy() *StartTimeParameters { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StateInfoInitParameters) DeepCopyInto(out *StateInfoInitParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateInfoInitParameters. +func (in *StateInfoInitParameters) DeepCopy() *StateInfoInitParameters { + if in == nil { + return nil + } + out := new(StateInfoInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StateInfoObservation) DeepCopyInto(out *StateInfoObservation) { + *out = *in + if in.UpdateInfo != nil { + in, out := &in.UpdateInfo, &out.UpdateInfo + *out = new(UpdateInfoObservation) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateInfoObservation. +func (in *StateInfoObservation) DeepCopy() *StateInfoObservation { + if in == nil { + return nil + } + out := new(StateInfoObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *StateInfoParameters) DeepCopyInto(out *StateInfoParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StateInfoParameters. +func (in *StateInfoParameters) DeepCopy() *StateInfoParameters { + if in == nil { + return nil + } + out := new(StateInfoParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpdateInfoInitParameters) DeepCopyInto(out *UpdateInfoInitParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateInfoInitParameters. +func (in *UpdateInfoInitParameters) DeepCopy() *UpdateInfoInitParameters { + if in == nil { + return nil + } + out := new(UpdateInfoInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpdateInfoObservation) DeepCopyInto(out *UpdateInfoObservation) { + *out = *in + if in.TargetReplicaCount != nil { + in, out := &in.TargetReplicaCount, &out.TargetReplicaCount + *out = new(float64) + **out = **in + } + if in.TargetShardCount != nil { + in, out := &in.TargetShardCount, &out.TargetShardCount + *out = new(float64) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateInfoObservation. +func (in *UpdateInfoObservation) DeepCopy() *UpdateInfoObservation { + if in == nil { + return nil + } + out := new(UpdateInfoObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *UpdateInfoParameters) DeepCopyInto(out *UpdateInfoParameters) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new UpdateInfoParameters. +func (in *UpdateInfoParameters) DeepCopy() *UpdateInfoParameters { + if in == nil { + return nil + } + out := new(UpdateInfoParameters) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *WeeklyMaintenanceWindowInitParameters) DeepCopyInto(out *WeeklyMaintenanceWindowInitParameters) { *out = *in @@ -1249,3 +1988,78 @@ func (in *WeeklyMaintenanceWindowParameters) DeepCopy() *WeeklyMaintenanceWindow in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZoneDistributionConfigInitParameters) DeepCopyInto(out *ZoneDistributionConfigInitParameters) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(string) + **out = **in + } + if in.Zone != nil { + in, out := &in.Zone, &out.Zone + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZoneDistributionConfigInitParameters. +func (in *ZoneDistributionConfigInitParameters) DeepCopy() *ZoneDistributionConfigInitParameters { + if in == nil { + return nil + } + out := new(ZoneDistributionConfigInitParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZoneDistributionConfigObservation) DeepCopyInto(out *ZoneDistributionConfigObservation) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(string) + **out = **in + } + if in.Zone != nil { + in, out := &in.Zone, &out.Zone + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZoneDistributionConfigObservation. +func (in *ZoneDistributionConfigObservation) DeepCopy() *ZoneDistributionConfigObservation { + if in == nil { + return nil + } + out := new(ZoneDistributionConfigObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ZoneDistributionConfigParameters) DeepCopyInto(out *ZoneDistributionConfigParameters) { + *out = *in + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(string) + **out = **in + } + if in.Zone != nil { + in, out := &in.Zone, &out.Zone + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ZoneDistributionConfigParameters. +func (in *ZoneDistributionConfigParameters) DeepCopy() *ZoneDistributionConfigParameters { + if in == nil { + return nil + } + out := new(ZoneDistributionConfigParameters) + in.DeepCopyInto(out) + return out +} diff --git a/apis/redis/v1beta1/zz_generated.managed.go b/apis/redis/v1beta1/zz_generated.managed.go index ed6281bb9..fcfa1b12b 100644 --- a/apis/redis/v1beta1/zz_generated.managed.go +++ b/apis/redis/v1beta1/zz_generated.managed.go @@ -7,6 +7,66 @@ package v1beta1 import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +// GetCondition of this Cluster. +func (mg *Cluster) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this Cluster. +func (mg *Cluster) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetManagementPolicies of this Cluster. +func (mg *Cluster) GetManagementPolicies() xpv1.ManagementPolicies { + return mg.Spec.ManagementPolicies +} + +// GetProviderConfigReference of this Cluster. +func (mg *Cluster) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +// GetPublishConnectionDetailsTo of this Cluster. +func (mg *Cluster) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this Cluster. +func (mg *Cluster) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this Cluster. +func (mg *Cluster) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this Cluster. +func (mg *Cluster) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetManagementPolicies of this Cluster. +func (mg *Cluster) SetManagementPolicies(r xpv1.ManagementPolicies) { + mg.Spec.ManagementPolicies = r +} + +// SetProviderConfigReference of this Cluster. +func (mg *Cluster) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +// SetPublishConnectionDetailsTo of this Cluster. +func (mg *Cluster) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this Cluster. +func (mg *Cluster) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this Instance. func (mg *Instance) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/redis/v1beta1/zz_generated.managedlist.go b/apis/redis/v1beta1/zz_generated.managedlist.go index 4d2d3e8ad..ba3cdbc11 100644 --- a/apis/redis/v1beta1/zz_generated.managedlist.go +++ b/apis/redis/v1beta1/zz_generated.managedlist.go @@ -7,6 +7,15 @@ package v1beta1 import resource "github.com/crossplane/crossplane-runtime/pkg/resource" +// GetItems of this ClusterList. +func (l *ClusterList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this InstanceList. func (l *InstanceList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/redis/v1beta1/zz_generated.resolvers.go b/apis/redis/v1beta1/zz_generated.resolvers.go index 84a0b3716..580b88472 100644 --- a/apis/redis/v1beta1/zz_generated.resolvers.go +++ b/apis/redis/v1beta1/zz_generated.resolvers.go @@ -15,10 +15,65 @@ import ( xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" client "sigs.k8s.io/controller-runtime/pkg/client" - // ResolveReferences of this Instance. + // ResolveReferences of this Cluster. apisresolver "github.com/upbound/provider-gcp/internal/apis" ) +func (mg *Cluster) ResolveReferences(ctx context.Context, c client.Reader) error { + var m xpresource.Managed + var l xpresource.ManagedList + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + for i3 := 0; i3 < len(mg.Spec.ForProvider.PscConfigs); i3++ { + { + m, l, err = apisresolver.GetManagedResource("compute.gcp.upbound.io", "v1beta1", "Network", "NetworkList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.PscConfigs[i3].Network), + Extract: resource.ExtractResourceID(), + Reference: mg.Spec.ForProvider.PscConfigs[i3].NetworkRef, + Selector: mg.Spec.ForProvider.PscConfigs[i3].NetworkSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.PscConfigs[i3].Network") + } + mg.Spec.ForProvider.PscConfigs[i3].Network = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.PscConfigs[i3].NetworkRef = rsp.ResolvedReference + + } + for i3 := 0; i3 < len(mg.Spec.InitProvider.PscConfigs); i3++ { + { + m, l, err = apisresolver.GetManagedResource("compute.gcp.upbound.io", "v1beta1", "Network", "NetworkList") + if err != nil { + return errors.Wrap(err, "failed to get the reference target managed resource and its list for reference resolution") + } + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.PscConfigs[i3].Network), + Extract: resource.ExtractResourceID(), + Reference: mg.Spec.InitProvider.PscConfigs[i3].NetworkRef, + Selector: mg.Spec.InitProvider.PscConfigs[i3].NetworkSelector, + To: reference.To{List: l, Managed: m}, + }) + } + if err != nil { + return errors.Wrap(err, "mg.Spec.InitProvider.PscConfigs[i3].Network") + } + mg.Spec.InitProvider.PscConfigs[i3].Network = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.InitProvider.PscConfigs[i3].NetworkRef = rsp.ResolvedReference + + } + + return nil +} + +// ResolveReferences of this Instance. func (mg *Instance) ResolveReferences(ctx context.Context, c client.Reader) error { var m xpresource.Managed var l xpresource.ManagedList diff --git a/config/externalname.go b/config/externalname.go index c7dfb478e..8588db1ec 100644 --- a/config/externalname.go +++ b/config/externalname.go @@ -691,6 +691,8 @@ var terraformPluginSDKExternalNameConfigs = map[string]config.ExternalName{ // // Imported by using the following format: projects/{{project}}/locations/{{region}}/instances/{{name}} "google_redis_instance": config.TemplatedStringAsIdentifier("name", "projects/{{ .setup.configuration.project }}/locations/{{ .parameters.region }}/instances/{{ .external_name }}"), + // Imported by using the following format: projects/{{project}}/locations/{{region}}/clusters/{{name}} + "google_redis_cluster": config.TemplatedStringAsIdentifier("name", "projects/{{ .setup.configuration.project }}/locations/{{ .parameters.region }}/clusters/{{ .external_name }}"), // resource_manager // diff --git a/config/generated.lst b/config/generated.lst index 7e6231495..ab82fa7f4 100644 --- a/config/generated.lst +++ b/config/generated.lst @@ -1 +1 @@ -["google_access_context_manager_access_level","google_access_context_manager_access_level_condition","google_access_context_manager_access_policy","google_access_context_manager_access_policy_iam_member","google_access_context_manager_service_perimeter","google_access_context_manager_service_perimeter_resource","google_active_directory_domain","google_alloydb_backup","google_alloydb_cluster","google_alloydb_instance","google_apigee_addons_config","google_apigee_endpoint_attachment","google_apigee_envgroup","google_apigee_envgroup_attachment","google_apigee_environment","google_apigee_environment_iam_member","google_apigee_instance","google_apigee_instance_attachment","google_apigee_nat_address","google_apigee_organization","google_apigee_sync_authorization","google_app_engine_application","google_app_engine_application_url_dispatch_rules","google_app_engine_firewall_rule","google_app_engine_service_network_settings","google_app_engine_standard_app_version","google_artifact_registry_repository","google_artifact_registry_repository_iam_member","google_beyondcorp_app_connection","google_beyondcorp_app_connector","google_beyondcorp_app_gateway","google_bigquery_analytics_hub_data_exchange","google_bigquery_analytics_hub_data_exchange_iam_member","google_bigquery_analytics_hub_listing","google_bigquery_connection","google_bigquery_data_transfer_config","google_bigquery_dataset","google_bigquery_dataset_access","google_bigquery_dataset_iam_binding","google_bigquery_dataset_iam_member","google_bigquery_dataset_iam_policy","google_bigquery_job","google_bigquery_reservation","google_bigquery_reservation_assignment","google_bigquery_routine","google_bigquery_table","google_bigquery_table_iam_binding","google_bigquery_table_iam_member","google_bigquery_table_iam_policy","google_bigtable_app_profile","google_bigtable_gc_policy","google_bigtable_instance","google_bigtable_instance_iam_binding","google_bigtable_instance_iam_member","google_bigtable_instance_iam_policy","google_bigtable_table","google_bigtable_table_iam_binding","google_bigtable_table_iam_member","google_bigtable_table_iam_policy","google_binary_authorization_attestor","google_binary_authorization_policy","google_certificate_manager_certificate","google_certificate_manager_certificate_map","google_certificate_manager_certificate_map_entry","google_certificate_manager_dns_authorization","google_cloud_ids_endpoint","google_cloud_run_domain_mapping","google_cloud_run_service","google_cloud_run_service_iam_member","google_cloud_run_v2_job","google_cloud_run_v2_service","google_cloud_scheduler_job","google_cloud_tasks_queue","google_cloudbuild_trigger","google_cloudbuild_worker_pool","google_cloudfunctions2_function","google_cloudfunctions_function","google_cloudfunctions_function_iam_member","google_composer_environment","google_compute_address","google_compute_attached_disk","google_compute_autoscaler","google_compute_backend_bucket","google_compute_backend_bucket_signed_url_key","google_compute_backend_service","google_compute_backend_service_signed_url_key","google_compute_disk","google_compute_disk_iam_member","google_compute_disk_resource_policy_attachment","google_compute_external_vpn_gateway","google_compute_firewall","google_compute_firewall_policy","google_compute_firewall_policy_association","google_compute_firewall_policy_rule","google_compute_forwarding_rule","google_compute_global_address","google_compute_global_forwarding_rule","google_compute_global_network_endpoint","google_compute_global_network_endpoint_group","google_compute_ha_vpn_gateway","google_compute_health_check","google_compute_http_health_check","google_compute_https_health_check","google_compute_image","google_compute_image_iam_member","google_compute_instance","google_compute_instance_from_template","google_compute_instance_group","google_compute_instance_group_manager","google_compute_instance_group_named_port","google_compute_instance_iam_member","google_compute_instance_template","google_compute_interconnect_attachment","google_compute_managed_ssl_certificate","google_compute_network","google_compute_network_endpoint","google_compute_network_endpoint_group","google_compute_network_firewall_policy","google_compute_network_firewall_policy_association","google_compute_network_peering","google_compute_network_peering_routes_config","google_compute_node_group","google_compute_node_template","google_compute_packet_mirroring","google_compute_per_instance_config","google_compute_project_default_network_tier","google_compute_project_metadata","google_compute_project_metadata_item","google_compute_region_autoscaler","google_compute_region_backend_service","google_compute_region_disk","google_compute_region_disk_iam_member","google_compute_region_disk_resource_policy_attachment","google_compute_region_health_check","google_compute_region_instance_group_manager","google_compute_region_network_endpoint","google_compute_region_network_endpoint_group","google_compute_region_network_firewall_policy","google_compute_region_network_firewall_policy_association","google_compute_region_per_instance_config","google_compute_region_ssl_certificate","google_compute_region_target_http_proxy","google_compute_region_target_https_proxy","google_compute_region_target_tcp_proxy","google_compute_region_url_map","google_compute_reservation","google_compute_resource_policy","google_compute_route","google_compute_router","google_compute_router_interface","google_compute_router_nat","google_compute_router_peer","google_compute_security_policy","google_compute_service_attachment","google_compute_shared_vpc_host_project","google_compute_shared_vpc_service_project","google_compute_snapshot","google_compute_snapshot_iam_member","google_compute_ssl_certificate","google_compute_ssl_policy","google_compute_subnetwork","google_compute_subnetwork_iam_member","google_compute_target_grpc_proxy","google_compute_target_http_proxy","google_compute_target_https_proxy","google_compute_target_instance","google_compute_target_pool","google_compute_target_ssl_proxy","google_compute_target_tcp_proxy","google_compute_url_map","google_compute_vpn_gateway","google_compute_vpn_tunnel","google_container_analysis_note","google_container_attached_cluster","google_container_aws_cluster","google_container_aws_node_pool","google_container_azure_client","google_container_azure_cluster","google_container_azure_node_pool","google_container_cluster","google_container_node_pool","google_container_registry","google_data_catalog_entry","google_data_catalog_entry_group","google_data_catalog_tag","google_data_catalog_tag_template","google_data_fusion_instance","google_data_loss_prevention_deidentify_template","google_data_loss_prevention_inspect_template","google_data_loss_prevention_job_trigger","google_data_loss_prevention_stored_info_type","google_dataflow_job","google_dataplex_asset","google_dataplex_lake","google_dataplex_zone","google_dataproc_autoscaling_policy","google_dataproc_cluster","google_dataproc_job","google_dataproc_metastore_service","google_dataproc_workflow_template","google_datastore_index","google_datastream_connection_profile","google_datastream_private_connection","google_dialogflow_cx_agent","google_dialogflow_cx_entity_type","google_dialogflow_cx_environment","google_dialogflow_cx_flow","google_dialogflow_cx_intent","google_dialogflow_cx_page","google_dialogflow_cx_version","google_dialogflow_cx_webhook","google_dns_managed_zone","google_dns_managed_zone_iam_member","google_dns_policy","google_dns_record_set","google_document_ai_processor","google_essential_contacts_contact","google_eventarc_channel","google_eventarc_google_channel_config","google_eventarc_trigger","google_filestore_backup","google_filestore_instance","google_filestore_snapshot","google_firebaserules_release","google_firebaserules_ruleset","google_folder","google_folder_iam_member","google_gke_backup_backup_plan","google_gke_hub_membership","google_gke_hub_membership_iam_member","google_healthcare_consent_store","google_healthcare_dataset","google_healthcare_dataset_iam_member","google_iam_workload_identity_pool","google_iam_workload_identity_pool_provider","google_iap_app_engine_service_iam_member","google_iap_app_engine_version_iam_member","google_iap_tunnel_iam_member","google_iap_web_backend_service_iam_member","google_iap_web_iam_member","google_iap_web_type_app_engine_iam_member","google_iap_web_type_compute_iam_member","google_identity_platform_default_supported_idp_config","google_identity_platform_inbound_saml_config","google_identity_platform_oauth_idp_config","google_identity_platform_project_default_config","google_identity_platform_tenant","google_identity_platform_tenant_default_supported_idp_config","google_identity_platform_tenant_inbound_saml_config","google_identity_platform_tenant_oauth_idp_config","google_kms_crypto_key","google_kms_crypto_key_iam_member","google_kms_crypto_key_version","google_kms_key_ring","google_kms_key_ring_iam_member","google_kms_key_ring_import_job","google_kms_secret_ciphertext","google_logging_folder_bucket_config","google_logging_folder_exclusion","google_logging_folder_sink","google_logging_log_view","google_logging_metric","google_logging_project_bucket_config","google_logging_project_exclusion","google_logging_project_sink","google_memcache_instance","google_ml_engine_model","google_monitoring_alert_policy","google_monitoring_custom_service","google_monitoring_dashboard","google_monitoring_group","google_monitoring_metric_descriptor","google_monitoring_notification_channel","google_monitoring_service","google_monitoring_slo","google_monitoring_uptime_check_config","google_network_connectivity_hub","google_network_connectivity_service_connection_policy","google_network_connectivity_spoke","google_network_management_connectivity_test","google_notebooks_environment","google_notebooks_instance","google_notebooks_instance_iam_member","google_notebooks_runtime","google_notebooks_runtime_iam_member","google_org_policy_policy","google_organization_iam_audit_config","google_organization_iam_custom_role","google_organization_iam_member","google_os_config_os_policy_assignment","google_os_config_patch_deployment","google_os_login_ssh_public_key","google_privateca_ca_pool","google_privateca_ca_pool_iam_member","google_privateca_certificate","google_privateca_certificate_authority","google_privateca_certificate_template","google_privateca_certificate_template_iam_member","google_project","google_project_default_service_accounts","google_project_iam_audit_config","google_project_iam_custom_role","google_project_iam_member","google_project_service","google_project_usage_export_bucket","google_pubsub_lite_reservation","google_pubsub_lite_subscription","google_pubsub_lite_topic","google_pubsub_schema","google_pubsub_subscription","google_pubsub_subscription_iam_member","google_pubsub_topic","google_pubsub_topic_iam_member","google_redis_instance","google_secret_manager_secret","google_secret_manager_secret_iam_member","google_secret_manager_secret_version","google_service_account","google_service_account_iam_member","google_service_account_key","google_service_networking_connection","google_service_networking_peered_dns_domain","google_sourcerepo_repository","google_sourcerepo_repository_iam_member","google_spanner_database","google_spanner_database_iam_member","google_spanner_instance","google_spanner_instance_iam_member","google_sql_database","google_sql_database_instance","google_sql_source_representation_instance","google_sql_ssl_cert","google_sql_user","google_storage_bucket","google_storage_bucket_access_control","google_storage_bucket_acl","google_storage_bucket_iam_member","google_storage_bucket_object","google_storage_default_object_access_control","google_storage_default_object_acl","google_storage_hmac_key","google_storage_notification","google_storage_object_access_control","google_storage_object_acl","google_storage_transfer_agent_pool","google_tags_tag_binding","google_tags_tag_key","google_tags_tag_value","google_tpu_node","google_vertex_ai_dataset","google_vertex_ai_featurestore","google_vertex_ai_featurestore_entitytype","google_vertex_ai_tensorboard","google_vpc_access_connector","google_workflows_workflow"] \ No newline at end of file +["google_access_context_manager_access_level","google_access_context_manager_access_level_condition","google_access_context_manager_access_policy","google_access_context_manager_access_policy_iam_member","google_access_context_manager_service_perimeter","google_access_context_manager_service_perimeter_resource","google_active_directory_domain","google_alloydb_backup","google_alloydb_cluster","google_alloydb_instance","google_apigee_addons_config","google_apigee_endpoint_attachment","google_apigee_envgroup","google_apigee_envgroup_attachment","google_apigee_environment","google_apigee_environment_iam_member","google_apigee_instance","google_apigee_instance_attachment","google_apigee_nat_address","google_apigee_organization","google_apigee_sync_authorization","google_app_engine_application","google_app_engine_application_url_dispatch_rules","google_app_engine_firewall_rule","google_app_engine_service_network_settings","google_app_engine_standard_app_version","google_artifact_registry_repository","google_artifact_registry_repository_iam_member","google_beyondcorp_app_connection","google_beyondcorp_app_connector","google_beyondcorp_app_gateway","google_bigquery_analytics_hub_data_exchange","google_bigquery_analytics_hub_data_exchange_iam_member","google_bigquery_analytics_hub_listing","google_bigquery_connection","google_bigquery_data_transfer_config","google_bigquery_dataset","google_bigquery_dataset_access","google_bigquery_dataset_iam_binding","google_bigquery_dataset_iam_member","google_bigquery_dataset_iam_policy","google_bigquery_job","google_bigquery_reservation","google_bigquery_reservation_assignment","google_bigquery_routine","google_bigquery_table","google_bigquery_table_iam_binding","google_bigquery_table_iam_member","google_bigquery_table_iam_policy","google_bigtable_app_profile","google_bigtable_gc_policy","google_bigtable_instance","google_bigtable_instance_iam_binding","google_bigtable_instance_iam_member","google_bigtable_instance_iam_policy","google_bigtable_table","google_bigtable_table_iam_binding","google_bigtable_table_iam_member","google_bigtable_table_iam_policy","google_binary_authorization_attestor","google_binary_authorization_policy","google_certificate_manager_certificate","google_certificate_manager_certificate_map","google_certificate_manager_certificate_map_entry","google_certificate_manager_dns_authorization","google_cloud_ids_endpoint","google_cloud_run_domain_mapping","google_cloud_run_service","google_cloud_run_service_iam_member","google_cloud_run_v2_job","google_cloud_run_v2_service","google_cloud_scheduler_job","google_cloud_tasks_queue","google_cloudbuild_trigger","google_cloudbuild_worker_pool","google_cloudfunctions2_function","google_cloudfunctions_function","google_cloudfunctions_function_iam_member","google_composer_environment","google_compute_address","google_compute_attached_disk","google_compute_autoscaler","google_compute_backend_bucket","google_compute_backend_bucket_signed_url_key","google_compute_backend_service","google_compute_backend_service_signed_url_key","google_compute_disk","google_compute_disk_iam_member","google_compute_disk_resource_policy_attachment","google_compute_external_vpn_gateway","google_compute_firewall","google_compute_firewall_policy","google_compute_firewall_policy_association","google_compute_firewall_policy_rule","google_compute_forwarding_rule","google_compute_global_address","google_compute_global_forwarding_rule","google_compute_global_network_endpoint","google_compute_global_network_endpoint_group","google_compute_ha_vpn_gateway","google_compute_health_check","google_compute_http_health_check","google_compute_https_health_check","google_compute_image","google_compute_image_iam_member","google_compute_instance","google_compute_instance_from_template","google_compute_instance_group","google_compute_instance_group_manager","google_compute_instance_group_named_port","google_compute_instance_iam_member","google_compute_instance_template","google_compute_interconnect_attachment","google_compute_managed_ssl_certificate","google_compute_network","google_compute_network_endpoint","google_compute_network_endpoint_group","google_compute_network_firewall_policy","google_compute_network_firewall_policy_association","google_compute_network_peering","google_compute_network_peering_routes_config","google_compute_node_group","google_compute_node_template","google_compute_packet_mirroring","google_compute_per_instance_config","google_compute_project_default_network_tier","google_compute_project_metadata","google_compute_project_metadata_item","google_compute_region_autoscaler","google_compute_region_backend_service","google_compute_region_disk","google_compute_region_disk_iam_member","google_compute_region_disk_resource_policy_attachment","google_compute_region_health_check","google_compute_region_instance_group_manager","google_compute_region_network_endpoint","google_compute_region_network_endpoint_group","google_compute_region_network_firewall_policy","google_compute_region_network_firewall_policy_association","google_compute_region_per_instance_config","google_compute_region_ssl_certificate","google_compute_region_target_http_proxy","google_compute_region_target_https_proxy","google_compute_region_target_tcp_proxy","google_compute_region_url_map","google_compute_reservation","google_compute_resource_policy","google_compute_route","google_compute_router","google_compute_router_interface","google_compute_router_nat","google_compute_router_peer","google_compute_security_policy","google_compute_service_attachment","google_compute_shared_vpc_host_project","google_compute_shared_vpc_service_project","google_compute_snapshot","google_compute_snapshot_iam_member","google_compute_ssl_certificate","google_compute_ssl_policy","google_compute_subnetwork","google_compute_subnetwork_iam_member","google_compute_target_grpc_proxy","google_compute_target_http_proxy","google_compute_target_https_proxy","google_compute_target_instance","google_compute_target_pool","google_compute_target_ssl_proxy","google_compute_target_tcp_proxy","google_compute_url_map","google_compute_vpn_gateway","google_compute_vpn_tunnel","google_container_analysis_note","google_container_attached_cluster","google_container_aws_cluster","google_container_aws_node_pool","google_container_azure_client","google_container_azure_cluster","google_container_azure_node_pool","google_container_cluster","google_container_node_pool","google_container_registry","google_data_catalog_entry","google_data_catalog_entry_group","google_data_catalog_tag","google_data_catalog_tag_template","google_data_fusion_instance","google_data_loss_prevention_deidentify_template","google_data_loss_prevention_inspect_template","google_data_loss_prevention_job_trigger","google_data_loss_prevention_stored_info_type","google_dataflow_job","google_dataplex_asset","google_dataplex_lake","google_dataplex_zone","google_dataproc_autoscaling_policy","google_dataproc_cluster","google_dataproc_job","google_dataproc_metastore_service","google_dataproc_workflow_template","google_datastore_index","google_datastream_connection_profile","google_datastream_private_connection","google_dialogflow_cx_agent","google_dialogflow_cx_entity_type","google_dialogflow_cx_environment","google_dialogflow_cx_flow","google_dialogflow_cx_intent","google_dialogflow_cx_page","google_dialogflow_cx_version","google_dialogflow_cx_webhook","google_dns_managed_zone","google_dns_managed_zone_iam_member","google_dns_policy","google_dns_record_set","google_document_ai_processor","google_essential_contacts_contact","google_eventarc_channel","google_eventarc_google_channel_config","google_eventarc_trigger","google_filestore_backup","google_filestore_instance","google_filestore_snapshot","google_firebaserules_release","google_firebaserules_ruleset","google_folder","google_folder_iam_member","google_gke_backup_backup_plan","google_gke_hub_membership","google_gke_hub_membership_iam_member","google_healthcare_consent_store","google_healthcare_dataset","google_healthcare_dataset_iam_member","google_iam_workload_identity_pool","google_iam_workload_identity_pool_provider","google_iap_app_engine_service_iam_member","google_iap_app_engine_version_iam_member","google_iap_tunnel_iam_member","google_iap_web_backend_service_iam_member","google_iap_web_iam_member","google_iap_web_type_app_engine_iam_member","google_iap_web_type_compute_iam_member","google_identity_platform_default_supported_idp_config","google_identity_platform_inbound_saml_config","google_identity_platform_oauth_idp_config","google_identity_platform_project_default_config","google_identity_platform_tenant","google_identity_platform_tenant_default_supported_idp_config","google_identity_platform_tenant_inbound_saml_config","google_identity_platform_tenant_oauth_idp_config","google_kms_crypto_key","google_kms_crypto_key_iam_member","google_kms_crypto_key_version","google_kms_key_ring","google_kms_key_ring_iam_member","google_kms_key_ring_import_job","google_kms_secret_ciphertext","google_logging_folder_bucket_config","google_logging_folder_exclusion","google_logging_folder_sink","google_logging_log_view","google_logging_metric","google_logging_project_bucket_config","google_logging_project_exclusion","google_logging_project_sink","google_memcache_instance","google_ml_engine_model","google_monitoring_alert_policy","google_monitoring_custom_service","google_monitoring_dashboard","google_monitoring_group","google_monitoring_metric_descriptor","google_monitoring_notification_channel","google_monitoring_service","google_monitoring_slo","google_monitoring_uptime_check_config","google_network_connectivity_hub","google_network_connectivity_service_connection_policy","google_network_connectivity_spoke","google_network_management_connectivity_test","google_notebooks_environment","google_notebooks_instance","google_notebooks_instance_iam_member","google_notebooks_runtime","google_notebooks_runtime_iam_member","google_org_policy_policy","google_organization_iam_audit_config","google_organization_iam_custom_role","google_organization_iam_member","google_os_config_os_policy_assignment","google_os_config_patch_deployment","google_os_login_ssh_public_key","google_privateca_ca_pool","google_privateca_ca_pool_iam_member","google_privateca_certificate","google_privateca_certificate_authority","google_privateca_certificate_template","google_privateca_certificate_template_iam_member","google_project","google_project_default_service_accounts","google_project_iam_audit_config","google_project_iam_custom_role","google_project_iam_member","google_project_service","google_project_usage_export_bucket","google_pubsub_lite_reservation","google_pubsub_lite_subscription","google_pubsub_lite_topic","google_pubsub_schema","google_pubsub_subscription","google_pubsub_subscription_iam_member","google_pubsub_topic","google_pubsub_topic_iam_member","google_redis_cluster","google_redis_instance","google_secret_manager_secret","google_secret_manager_secret_iam_member","google_secret_manager_secret_version","google_service_account","google_service_account_iam_member","google_service_account_key","google_service_networking_connection","google_service_networking_peered_dns_domain","google_sourcerepo_repository","google_sourcerepo_repository_iam_member","google_spanner_database","google_spanner_database_iam_member","google_spanner_instance","google_spanner_instance_iam_member","google_sql_database","google_sql_database_instance","google_sql_source_representation_instance","google_sql_ssl_cert","google_sql_user","google_storage_bucket","google_storage_bucket_access_control","google_storage_bucket_acl","google_storage_bucket_iam_member","google_storage_bucket_object","google_storage_default_object_access_control","google_storage_default_object_acl","google_storage_hmac_key","google_storage_notification","google_storage_object_access_control","google_storage_object_acl","google_storage_transfer_agent_pool","google_tags_tag_binding","google_tags_tag_key","google_tags_tag_value","google_tpu_node","google_vertex_ai_dataset","google_vertex_ai_featurestore","google_vertex_ai_featurestore_entitytype","google_vertex_ai_tensorboard","google_vpc_access_connector","google_workflows_workflow"] \ No newline at end of file diff --git a/config/redis/config.go b/config/redis/config.go index 7a9048a01..d21c82bd1 100644 --- a/config/redis/config.go +++ b/config/redis/config.go @@ -4,7 +4,15 @@ package redis -import "github.com/crossplane/upjet/pkg/config" +import ( + "strconv" + + "github.com/crossplane/crossplane-runtime/pkg/fieldpath" + "github.com/crossplane/upjet/pkg/config" + "github.com/pkg/errors" + + "github.com/upbound/provider-gcp/config/common" +) // Configure configures individual resources by adding custom // ResourceConfigurators. @@ -19,4 +27,40 @@ func Configure(p *config.Provider) { return conn, nil } }) + + p.AddResourceConfigurator("google_redis_cluster", func(r *config.Resource) { + r.MarkAsRequired("region") + r.UseAsync = true + r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]any) (map[string][]byte, error) { + conn := map[string][]byte{} + + address, err := common.GetField(attr, "discovery_endpoints[0].address") + if err != nil { + return nil, err + } + conn["address"] = []byte(address) + + port, err := GetFloat(attr, "discovery_endpoints[0].port") + if err != nil { + return nil, err + } + conn["port"] = []byte(strconv.FormatFloat(port, 'f', -1, 64)) + + return conn, nil + } + }) +} + +// GetFloat value of the supplied field path. +func GetFloat(from map[string]interface{}, path string) (float64, error) { + v, err := fieldpath.Pave(from).GetValue(path) + if err != nil { + return 0, err + } + + f, ok := v.(float64) + if !ok { + return 0, errors.Errorf("%s: not a (float64) number", path) + } + return f, nil } diff --git a/examples-generated/redis/v1beta1/cluster.yaml b/examples-generated/redis/v1beta1/cluster.yaml new file mode 100644 index 000000000..ede766320 --- /dev/null +++ b/examples-generated/redis/v1beta1/cluster.yaml @@ -0,0 +1,78 @@ +apiVersion: redis.gcp.upbound.io/v1beta1 +kind: Cluster +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: cluster-ha + name: cluster-ha +spec: + forProvider: + authorizationMode: AUTH_MODE_DISABLED + nodeType: REDIS_SHARED_CORE_NANO + pscConfigs: + - networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + redisConfigs: + maxmemory-policy: volatile-ttl + region: us-central1 + replicaCount: 1 + shardCount: 3 + transitEncryptionMode: TRANSIT_ENCRYPTION_MODE_DISABLED + zoneDistributionConfig: + - mode: MULTI_ZONE + +--- + +apiVersion: compute.gcp.upbound.io/v1beta1 +kind: Network +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: producer_net + name: producer-net +spec: + forProvider: + autoCreateSubnetworks: false + +--- + +apiVersion: compute.gcp.upbound.io/v1beta2 +kind: Subnetwork +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: producer_subnet + name: producer-subnet +spec: + forProvider: + ipCidrRange: 10.0.0.248/29 + networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + region: us-central1 + +--- + +apiVersion: networkconnectivity.gcp.upbound.io/v1beta1 +kind: ServiceConnectionPolicy +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: default + name: default +spec: + forProvider: + description: my basic service connection policy + location: us-central1 + networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + pscConfig: + - subnetworksRefs: + - name: producer_subnet + serviceClass: gcp-memorystore-redis diff --git a/examples/redis/v1beta1/cluster.yaml b/examples/redis/v1beta1/cluster.yaml new file mode 100644 index 000000000..417f10d01 --- /dev/null +++ b/examples/redis/v1beta1/cluster.yaml @@ -0,0 +1,78 @@ +apiVersion: redis.gcp.upbound.io/v1beta1 +kind: Cluster +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: cluster-ha + name: cluster-ha +spec: + forProvider: + authorizationMode: AUTH_MODE_DISABLED + nodeType: REDIS_SHARED_CORE_NANO + pscConfigs: + - networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + redisConfigs: + maxmemory-policy: volatile-ttl + region: us-central1 + replicaCount: 1 + shardCount: 3 + transitEncryptionMode: TRANSIT_ENCRYPTION_MODE_DISABLED + zoneDistributionConfig: + mode: MULTI_ZONE + +--- + +apiVersion: compute.gcp.upbound.io/v1beta1 +kind: Network +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: producer_net + name: producer-net +spec: + forProvider: + autoCreateSubnetworks: false + +--- + +apiVersion: compute.gcp.upbound.io/v1beta2 +kind: Subnetwork +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: producer_subnet + name: producer-subnet +spec: + forProvider: + ipCidrRange: 10.0.0.248/29 + networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + region: us-central1 + +--- + +apiVersion: networkconnectivity.gcp.upbound.io/v1beta1 +kind: ServiceConnectionPolicy +metadata: + annotations: + meta.upbound.io/example-id: redis/v1beta1/cluster + labels: + testing.upbound.io/example-name: default + name: default +spec: + forProvider: + description: my basic service connection policy + location: us-central1 + networkSelector: + matchLabels: + testing.upbound.io/example-name: producer_net + pscConfig: + subnetworksRefs: + - name: producer-subnet + serviceClass: gcp-memorystore-redis diff --git a/internal/controller/redis/cluster/zz_controller.go b/internal/controller/redis/cluster/zz_controller.go new file mode 100755 index 000000000..6159d654f --- /dev/null +++ b/internal/controller/redis/cluster/zz_controller.go @@ -0,0 +1,92 @@ +// SPDX-FileCopyrightText: 2024 The Crossplane Authors +// +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by upjet. DO NOT EDIT. + +package cluster + +import ( + "time" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/ratelimiter" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + xpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + "github.com/crossplane/crossplane-runtime/pkg/statemetrics" + tjcontroller "github.com/crossplane/upjet/pkg/controller" + "github.com/crossplane/upjet/pkg/controller/handler" + "github.com/crossplane/upjet/pkg/metrics" + "github.com/pkg/errors" + ctrl "sigs.k8s.io/controller-runtime" + + v1beta1 "github.com/upbound/provider-gcp/apis/redis/v1beta1" + features "github.com/upbound/provider-gcp/internal/features" +) + +// Setup adds a controller that reconciles Cluster managed resources. +func Setup(mgr ctrl.Manager, o tjcontroller.Options) error { + name := managed.ControllerName(v1beta1.Cluster_GroupVersionKind.String()) + var initializers managed.InitializerChain + initializers = append(initializers, managed.NewNameAsExternalName(mgr.GetClient())) + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.SecretStoreConfigGVK != nil { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), *o.SecretStoreConfigGVK, connection.WithTLSConfig(o.ESSOptions.TLSConfig))) + } + eventHandler := handler.NewEventHandler(handler.WithLogger(o.Logger.WithValues("gvk", v1beta1.Cluster_GroupVersionKind))) + ac := tjcontroller.NewAPICallbacks(mgr, xpresource.ManagedKind(v1beta1.Cluster_GroupVersionKind), tjcontroller.WithEventHandler(eventHandler), tjcontroller.WithStatusUpdates(false)) + opts := []managed.ReconcilerOption{ + managed.WithExternalConnecter( + tjcontroller.NewTerraformPluginSDKAsyncConnector(mgr.GetClient(), o.OperationTrackerStore, o.SetupFn, o.Provider.Resources["google_redis_cluster"], + tjcontroller.WithTerraformPluginSDKAsyncLogger(o.Logger), + tjcontroller.WithTerraformPluginSDKAsyncConnectorEventHandler(eventHandler), + tjcontroller.WithTerraformPluginSDKAsyncCallbackProvider(ac), + tjcontroller.WithTerraformPluginSDKAsyncMetricRecorder(metrics.NewMetricRecorder(v1beta1.Cluster_GroupVersionKind, mgr, o.PollInterval)), + tjcontroller.WithTerraformPluginSDKAsyncManagementPolicies(o.Features.Enabled(features.EnableBetaManagementPolicies)))), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithFinalizer(tjcontroller.NewOperationTrackerFinalizer(o.OperationTrackerStore, xpresource.NewAPIFinalizer(mgr.GetClient(), managed.FinalizerName))), + managed.WithTimeout(3 * time.Minute), + managed.WithInitializers(initializers), + managed.WithConnectionPublishers(cps...), + managed.WithPollInterval(o.PollInterval), + } + if o.PollJitter != 0 { + opts = append(opts, managed.WithPollJitterHook(o.PollJitter)) + } + if o.Features.Enabled(features.EnableBetaManagementPolicies) { + opts = append(opts, managed.WithManagementPolicies()) + } + if o.MetricOptions != nil { + opts = append(opts, managed.WithMetricRecorder(o.MetricOptions.MRMetrics)) + } + + // register webhooks for the kind v1beta1.Cluster + // if they're enabled. + if o.StartWebhooks { + if err := ctrl.NewWebhookManagedBy(mgr). + For(&v1beta1.Cluster{}). + Complete(); err != nil { + return errors.Wrap(err, "cannot register webhook for the kind v1beta1.Cluster") + } + } + + if o.MetricOptions != nil && o.MetricOptions.MRStateMetrics != nil { + stateMetricsRecorder := statemetrics.NewMRStateRecorder( + mgr.GetClient(), o.Logger, o.MetricOptions.MRStateMetrics, &v1beta1.ClusterList{}, o.MetricOptions.PollStateMetricInterval, + ) + if err := mgr.Add(stateMetricsRecorder); err != nil { + return errors.Wrap(err, "cannot register MR state metrics recorder for kind v1beta1.ClusterList") + } + } + + r := managed.NewReconciler(mgr, xpresource.ManagedKind(v1beta1.Cluster_GroupVersionKind), opts...) + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + WithEventFilter(xpresource.DesiredStateChanged()). + Watches(&v1beta1.Cluster{}, eventHandler). + Complete(ratelimiter.NewReconciler(name, r, o.GlobalRateLimiter)) +} diff --git a/internal/controller/zz_monolith_setup.go b/internal/controller/zz_monolith_setup.go index 9e705b9a5..918c44345 100755 --- a/internal/controller/zz_monolith_setup.go +++ b/internal/controller/zz_monolith_setup.go @@ -327,6 +327,7 @@ import ( subscriptioniammember "github.com/upbound/provider-gcp/internal/controller/pubsub/subscriptioniammember" topic "github.com/upbound/provider-gcp/internal/controller/pubsub/topic" topiciammember "github.com/upbound/provider-gcp/internal/controller/pubsub/topiciammember" + clusterredis "github.com/upbound/provider-gcp/internal/controller/redis/cluster" instanceredis "github.com/upbound/provider-gcp/internal/controller/redis/instance" secret "github.com/upbound/provider-gcp/internal/controller/secretmanager/secret" secretiammember "github.com/upbound/provider-gcp/internal/controller/secretmanager/secretiammember" @@ -689,6 +690,7 @@ func Setup_monolith(mgr ctrl.Manager, o controller.Options) error { subscriptioniammember.Setup, topic.Setup, topiciammember.Setup, + clusterredis.Setup, instanceredis.Setup, secret.Setup, secretiammember.Setup, diff --git a/internal/controller/zz_redis_setup.go b/internal/controller/zz_redis_setup.go index 30161b6b2..bca5dbcdc 100755 --- a/internal/controller/zz_redis_setup.go +++ b/internal/controller/zz_redis_setup.go @@ -9,6 +9,7 @@ import ( "github.com/crossplane/upjet/pkg/controller" + cluster "github.com/upbound/provider-gcp/internal/controller/redis/cluster" instance "github.com/upbound/provider-gcp/internal/controller/redis/instance" ) @@ -16,6 +17,7 @@ import ( // the supplied manager. func Setup_redis(mgr ctrl.Manager, o controller.Options) error { for _, setup := range []func(ctrl.Manager, controller.Options) error{ + cluster.Setup, instance.Setup, } { if err := setup(mgr, o); err != nil { diff --git a/package/crds/redis.gcp.upbound.io_clusters.yaml b/package/crds/redis.gcp.upbound.io_clusters.yaml new file mode 100644 index 000000000..fcb58b097 --- /dev/null +++ b/package/crds/redis.gcp.upbound.io_clusters.yaml @@ -0,0 +1,807 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.14.0 + name: clusters.redis.gcp.upbound.io +spec: + group: redis.gcp.upbound.io + names: + categories: + - crossplane + - managed + - gcp + kind: Cluster + listKind: ClusterList + plural: clusters + singular: cluster + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + - jsonPath: .metadata.creationTimestamp + name: AGE + type: date + name: v1beta1 + schema: + openAPIV3Schema: + description: Cluster is the Schema for the Clusters API. A Google Cloud Redis + Cluster instance. + properties: + apiVersion: + description: |- + APIVersion defines the versioned schema of this representation of an object. + Servers should convert recognized schemas to the latest internal value, and + may reject unrecognized values. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources + type: string + kind: + description: |- + Kind is a string value representing the REST resource this object represents. + Servers may infer this from the endpoint the client submits requests to. + Cannot be updated. + In CamelCase. + More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds + type: string + metadata: + type: object + spec: + description: ClusterSpec defines the desired state of Cluster + properties: + deletionPolicy: + default: Delete + description: |- + DeletionPolicy specifies what will happen to the underlying external + when this managed resource is deleted - either "Delete" or "Orphan" the + external resource. + This field is planned to be deprecated in favor of the ManagementPolicies + field in a future release. Currently, both could be set independently and + non-default values would be honored if the feature flag is enabled. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + enum: + - Orphan + - Delete + type: string + forProvider: + properties: + authorizationMode: + description: |- + Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + Default value is AUTH_MODE_DISABLED. + Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + type: string + nodeType: + description: |- + The nodeType for the Redis cluster. + If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + type: string + project: + description: |- + The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + type: string + pscConfigs: + description: |- + Required. Each PscConfig configures the consumer network where two + network addresses will be designated to the cluster for client access. + Currently, only one PscConfig is supported. + Structure is documented below. + items: + properties: + network: + description: |- + Required. The consumer network where the network address of + the discovery endpoint will be reserved, in the form of + projects/{network_project_id_or_number}/global/networks/{network_id}. + type: string + networkRef: + description: Reference to a Network in compute to populate + network. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + networkSelector: + description: Selector for a Network in compute to populate + network. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching + labels is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + type: object + type: array + redisConfigs: + additionalProperties: + type: string + description: |- + Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + Please check Memorystore documentation for the list of supported parameters: + https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + type: object + x-kubernetes-map-type: granular + region: + description: The name of the region of the Redis cluster. + type: string + replicaCount: + description: Optional. The number of replica nodes per shard. + type: number + shardCount: + description: Required. Number of shards for the Redis cluster. + type: number + transitEncryptionMode: + description: |- + Optional. The in-transit encryption for the Redis cluster. + If not provided, encryption is disabled for the cluster. + Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + type: string + zoneDistributionConfig: + description: |- + Immutable. Zone distribution config for Memorystore Redis cluster. + Structure is documented below. + properties: + mode: + description: |- + Immutable. The mode for zone distribution for Memorystore Redis cluster. + If not provided, MULTI_ZONE will be used as default + Possible values are: MULTI_ZONE, SINGLE_ZONE. + type: string + zone: + description: Immutable. The zone for single zone Memorystore + Redis cluster. + type: string + type: object + required: + - region + type: object + initProvider: + description: |- + THIS IS A BETA FIELD. It will be honored + unless the Management Policies feature flag is disabled. + InitProvider holds the same fields as ForProvider, with the exception + of Identifier and other resource reference fields. The fields that are + in InitProvider are merged into ForProvider when the resource is created. + The same fields are also added to the terraform ignore_changes hook, to + avoid updating them after creation. This is useful for fields that are + required on creation, but we do not desire to update them after creation, + for example because of an external controller is managing them, like an + autoscaler. + properties: + authorizationMode: + description: |- + Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + Default value is AUTH_MODE_DISABLED. + Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + type: string + nodeType: + description: |- + The nodeType for the Redis cluster. + If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + type: string + project: + description: |- + The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + type: string + pscConfigs: + description: |- + Required. Each PscConfig configures the consumer network where two + network addresses will be designated to the cluster for client access. + Currently, only one PscConfig is supported. + Structure is documented below. + items: + properties: + network: + description: |- + Required. The consumer network where the network address of + the discovery endpoint will be reserved, in the form of + projects/{network_project_id_or_number}/global/networks/{network_id}. + type: string + networkRef: + description: Reference to a Network in compute to populate + network. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + networkSelector: + description: Selector for a Network in compute to populate + network. + properties: + matchControllerRef: + description: |- + MatchControllerRef ensures an object with the same controller reference + as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching + labels is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + type: object + type: array + redisConfigs: + additionalProperties: + type: string + description: |- + Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + Please check Memorystore documentation for the list of supported parameters: + https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + type: object + x-kubernetes-map-type: granular + replicaCount: + description: Optional. The number of replica nodes per shard. + type: number + shardCount: + description: Required. Number of shards for the Redis cluster. + type: number + transitEncryptionMode: + description: |- + Optional. The in-transit encryption for the Redis cluster. + If not provided, encryption is disabled for the cluster. + Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + type: string + zoneDistributionConfig: + description: |- + Immutable. Zone distribution config for Memorystore Redis cluster. + Structure is documented below. + properties: + mode: + description: |- + Immutable. The mode for zone distribution for Memorystore Redis cluster. + If not provided, MULTI_ZONE will be used as default + Possible values are: MULTI_ZONE, SINGLE_ZONE. + type: string + zone: + description: Immutable. The zone for single zone Memorystore + Redis cluster. + type: string + type: object + type: object + managementPolicies: + default: + - '*' + description: |- + THIS IS A BETA FIELD. It is on by default but can be opted out + through a Crossplane feature flag. + ManagementPolicies specify the array of actions Crossplane is allowed to + take on the managed and external resources. + This field is planned to replace the DeletionPolicy field in a future + release. Currently, both could be set independently and non-default + values would be honored if the feature flag is enabled. If both are + custom, the DeletionPolicy field will be ignored. + See the design doc for more information: https://github.com/crossplane/crossplane/blob/499895a25d1a1a0ba1604944ef98ac7a1a71f197/design/design-doc-observe-only-resources.md?plain=1#L223 + and this one: https://github.com/crossplane/crossplane/blob/444267e84783136daa93568b364a5f01228cacbe/design/one-pager-ignore-changes.md + items: + description: |- + A ManagementAction represents an action that the Crossplane controllers + can take on an external resource. + enum: + - Observe + - Create + - Update + - Delete + - LateInitialize + - '*' + type: string + type: array + providerConfigRef: + default: + name: default + description: |- + ProviderConfigReference specifies how the provider that will be used to + create, observe, update, and delete this managed resource should be + configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: |- + PublishConnectionDetailsTo specifies the connection secret config which + contains a name, metadata and a reference to secret store config to + which any connection details for this managed resource should be written. + Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: |- + SecretStoreConfigRef specifies which secret store config should be used + for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: |- + Resolution specifies whether resolution of this reference is required. + The default is 'Required', which means the reconcile will fail if the + reference cannot be resolved. 'Optional' means this reference will be + a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: |- + Resolve specifies when this reference should be resolved. The default + is 'IfNotPresent', which will attempt to resolve the reference only when + the corresponding field is not present. Use 'Always' to resolve the + reference on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: |- + Annotations are the annotations to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.annotations". + - It is up to Secret Store implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: |- + Labels are the labels/tags to be added to connection secret. + - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store types. + type: object + type: + description: |- + Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: |- + WriteConnectionSecretToReference specifies the namespace and name of a + Secret to which any connection details for this managed resource should + be written. Connection details frequently include the endpoint, username, + and password required to connect to the managed resource. + This field is planned to be replaced in a future release in favor of + PublishConnectionDetailsTo. Currently, both could be set independently + and connection details would be published to both without affecting + each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + x-kubernetes-validations: + - message: spec.forProvider.pscConfigs is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.pscConfigs) + || (has(self.initProvider) && has(self.initProvider.pscConfigs))' + - message: spec.forProvider.shardCount is a required parameter + rule: '!(''*'' in self.managementPolicies || ''Create'' in self.managementPolicies + || ''Update'' in self.managementPolicies) || has(self.forProvider.shardCount) + || (has(self.initProvider) && has(self.initProvider.shardCount))' + status: + description: ClusterStatus defines the observed state of Cluster. + properties: + atProvider: + properties: + authorizationMode: + description: |- + Optional. The authorization mode of the Redis cluster. If not provided, auth feature is disabled for the cluster. + Default value is AUTH_MODE_DISABLED. + Possible values are: AUTH_MODE_UNSPECIFIED, AUTH_MODE_IAM_AUTH, AUTH_MODE_DISABLED. + type: string + createTime: + description: |- + The timestamp associated with the cluster creation request. A timestamp in + RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional + digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z". + type: string + discoveryEndpoints: + description: |- + Output only. Endpoints created on each given network, + for Redis clients to connect to the cluster. + Currently only one endpoint is supported. + Structure is documented below. + items: + properties: + address: + description: Output only. Network address of the exposed + Redis endpoint used by clients to connect to the service. + type: string + port: + description: Output only. The port number of the exposed + Redis endpoint. + type: number + pscConfig: + description: |- + Output only. Customer configuration for where the endpoint + is created and accessed from. + Structure is documented below. + properties: + network: + description: The consumer network where the IP address + resides, in the form of projects/{projectId}/global/networks/{network_id}. + type: string + type: object + type: object + type: array + id: + description: an identifier for the resource with format projects/{{project}}/locations/{{region}}/clusters/{{name}} + type: string + nodeType: + description: |- + The nodeType for the Redis cluster. + If not provided, REDIS_HIGHMEM_MEDIUM will be used as default + Possible values are: REDIS_SHARED_CORE_NANO, REDIS_HIGHMEM_MEDIUM, REDIS_HIGHMEM_XLARGE, REDIS_STANDARD_SMALL. + type: string + preciseSizeGb: + description: Output only. Redis memory precise size in GB for + the entire cluster. + type: number + project: + description: |- + The ID of the project in which the resource belongs. + If it is not provided, the provider project is used. + type: string + pscConfigs: + description: |- + Required. Each PscConfig configures the consumer network where two + network addresses will be designated to the cluster for client access. + Currently, only one PscConfig is supported. + Structure is documented below. + items: + properties: + network: + description: |- + Required. The consumer network where the network address of + the discovery endpoint will be reserved, in the form of + projects/{network_project_id_or_number}/global/networks/{network_id}. + type: string + type: object + type: array + pscConnections: + description: |- + Output only. PSC connections for discovery of the cluster topology and accessing the cluster. + Structure is documented below. + items: + properties: + address: + description: Output only. The IP allocated on the consumer + network for the PSC forwarding rule. + type: string + forwardingRule: + description: 'Output only. The URI of the consumer side + forwarding rule. Example: projects/{projectNumOrId}/regions/us-east1/forwardingRules/{resourceId}.' + type: string + network: + description: The consumer network where the IP address resides, + in the form of projects/{projectId}/global/networks/{network_id}. + type: string + projectId: + description: Output only. The consumer projectId where the + forwarding rule is created from. + type: string + pscConnectionId: + description: Output only. The PSC connection id of the forwarding + rule connected to the service attachment. + type: string + type: object + type: array + redisConfigs: + additionalProperties: + type: string + description: |- + Configure Redis Cluster behavior using a subset of native Redis configuration parameters. + Please check Memorystore documentation for the list of supported parameters: + https://cloud.google.com/memorystore/docs/cluster/supported-instance-configurations + type: object + x-kubernetes-map-type: granular + region: + description: The name of the region of the Redis cluster. + type: string + replicaCount: + description: Optional. The number of replica nodes per shard. + type: number + shardCount: + description: Required. Number of shards for the Redis cluster. + type: number + sizeGb: + description: Output only. Redis memory size in GB for the entire + cluster. + type: number + state: + description: The current state of this cluster. Can be CREATING, + READY, UPDATING, DELETING and SUSPENDED + type: string + stateInfo: + description: |- + Output only. Additional information about the current state of the cluster. + Structure is documented below. + items: + properties: + updateInfo: + description: |- + A nested object resource + Structure is documented below. + properties: + targetReplicaCount: + description: Target number of replica nodes per shard. + type: number + targetShardCount: + description: Target number of shards for redis cluster. + type: number + type: object + type: object + type: array + transitEncryptionMode: + description: |- + Optional. The in-transit encryption for the Redis cluster. + If not provided, encryption is disabled for the cluster. + Default value is TRANSIT_ENCRYPTION_MODE_DISABLED. + Possible values are: TRANSIT_ENCRYPTION_MODE_UNSPECIFIED, TRANSIT_ENCRYPTION_MODE_DISABLED, TRANSIT_ENCRYPTION_MODE_SERVER_AUTHENTICATION. + type: string + uid: + description: System assigned, unique identifier for the cluster. + type: string + zoneDistributionConfig: + description: |- + Immutable. Zone distribution config for Memorystore Redis cluster. + Structure is documented below. + properties: + mode: + description: |- + Immutable. The mode for zone distribution for Memorystore Redis cluster. + If not provided, MULTI_ZONE will be used as default + Possible values are: MULTI_ZONE, SINGLE_ZONE. + type: string + zone: + description: Immutable. The zone for single zone Memorystore + Redis cluster. + type: string + type: object + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: |- + LastTransitionTime is the last time this condition transitioned from one + status to another. + format: date-time + type: string + message: + description: |- + A Message containing details about this condition's last transition from + one status to another, if any. + type: string + observedGeneration: + description: |- + ObservedGeneration represents the .metadata.generation that the condition was set based upon. + For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date + with respect to the current state of the instance. + format: int64 + type: integer + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: |- + Type of this condition. At most one of each condition type may apply to + a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + observedGeneration: + description: |- + ObservedGeneration is the latest metadata.generation + which resulted in either a ready state, or stalled due to error + it can not recover from without human intervention. + format: int64 + type: integer + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} From 9cc2c5136050db48598cf8b95c0ada15d4ae7b19 Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Fri, 25 Oct 2024 12:18:18 +0200 Subject: [PATCH 2/3] Put all discovery endpoints in AdditionalConnectionDetails Signed-off-by: Rickard von Essen --- config/redis/config.go | 45 +++++++++++++----------------------------- 1 file changed, 14 insertions(+), 31 deletions(-) diff --git a/config/redis/config.go b/config/redis/config.go index d21c82bd1..ba42b4669 100644 --- a/config/redis/config.go +++ b/config/redis/config.go @@ -5,13 +5,9 @@ package redis import ( - "strconv" + "fmt" - "github.com/crossplane/crossplane-runtime/pkg/fieldpath" "github.com/crossplane/upjet/pkg/config" - "github.com/pkg/errors" - - "github.com/upbound/provider-gcp/config/common" ) // Configure configures individual resources by adding custom @@ -33,34 +29,21 @@ func Configure(p *config.Provider) { r.UseAsync = true r.Sensitive.AdditionalConnectionDetailsFn = func(attr map[string]any) (map[string][]byte, error) { conn := map[string][]byte{} - - address, err := common.GetField(attr, "discovery_endpoints[0].address") - if err != nil { - return nil, err - } - conn["address"] = []byte(address) - - port, err := GetFloat(attr, "discovery_endpoints[0].port") - if err != nil { - return nil, err + if discoveryendpoints, ok := attr["discovery_endpoints"].([]any); ok { + for i, de := range discoveryendpoints { + if discoveryendpoints, ok := de.(map[string]any); ok && len(discoveryendpoints) > 0 { + if address, ok := discoveryendpoints["address"].(string); ok { + key := fmt.Sprintf("discovery_endpoints_%d_address", i) + conn[key] = []byte(address) + } + if port, ok := discoveryendpoints["port"].(float64); ok { + key := fmt.Sprintf("discovery_endpoints_%d_port", i) + conn[key] = []byte(fmt.Sprintf("%g", port)) + } + } + } } - conn["port"] = []byte(strconv.FormatFloat(port, 'f', -1, 64)) - return conn, nil } }) } - -// GetFloat value of the supplied field path. -func GetFloat(from map[string]interface{}, path string) (float64, error) { - v, err := fieldpath.Pave(from).GetValue(path) - if err != nil { - return 0, err - } - - f, ok := v.(float64) - if !ok { - return 0, errors.Errorf("%s: not a (float64) number", path) - } - return f, nil -} From e8f9838a2696593460cb68faad048f50a5453680 Mon Sep 17 00:00:00 2001 From: Rickard von Essen Date: Fri, 25 Oct 2024 21:04:43 +0200 Subject: [PATCH 3/3] Increase timeout to 30 min Signed-off-by: Rickard von Essen --- examples/redis/v1beta1/cluster.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/redis/v1beta1/cluster.yaml b/examples/redis/v1beta1/cluster.yaml index 417f10d01..94d1a936e 100644 --- a/examples/redis/v1beta1/cluster.yaml +++ b/examples/redis/v1beta1/cluster.yaml @@ -3,6 +3,7 @@ kind: Cluster metadata: annotations: meta.upbound.io/example-id: redis/v1beta1/cluster + uptest.upbound.io/timeout: "1800" labels: testing.upbound.io/example-name: cluster-ha name: cluster-ha