From d8cd6572f8343d7b2542ae37164467c8d42ea7b6 Mon Sep 17 00:00:00 2001 From: DCL Team Date: Thu, 14 Nov 2024 09:42:32 -0800 Subject: [PATCH] Automated DCL import. - f6148ff1d4427427e6b630030dd736249be5bd1e Automatic import from cloud_mmv2_dcl_20241114_0931_RC00 by DCL Team GitOrigin-RevId: f6148ff1d4427427e6b630030dd736249be5bd1e --- .../clouddeploy/alpha/delivery_pipeline.proto | 6 + python/proto/clouddeploy/alpha/target.proto | 16 + .../clouddeploy/beta/delivery_pipeline.proto | 6 + python/proto/clouddeploy/beta/target.proto | 16 + .../proto/clouddeploy/delivery_pipeline.proto | 6 + python/proto/clouddeploy/target.proto | 16 + .../clouddeploy/alpha/delivery_pipeline.py | 72 + .../alpha/delivery_pipeline_server.go | 31 + python/services/clouddeploy/alpha/target.py | 152 ++ .../clouddeploy/alpha/target_server.go | 85 + .../clouddeploy/beta/delivery_pipeline.py | 72 + .../beta/delivery_pipeline_server.go | 31 + python/services/clouddeploy/beta/target.py | 152 ++ .../clouddeploy/beta/target_server.go | 85 + .../services/clouddeploy/delivery_pipeline.py | 72 + .../clouddeploy/delivery_pipeline_server.go | 31 + python/services/clouddeploy/target.py | 152 ++ python/services/clouddeploy/target_server.go | 85 + .../clouddeploy/alpha/delivery_pipeline.go | 66 +- .../clouddeploy/alpha/delivery_pipeline.yaml | 41 + .../delivery_pipeline_alpha_yaml_embed.go | 6 +- .../alpha/delivery_pipeline_internal.go | 334 +++ .../alpha/delivery_pipeline_schema.go | 27 + services/google/clouddeploy/alpha/target.go | 225 +- services/google/clouddeploy/alpha/target.yaml | 69 + .../alpha/target_alpha_yaml_embed.go | 6 +- .../clouddeploy/alpha/target_internal.go | 1953 ++++++++++++----- .../google/clouddeploy/alpha/target_schema.go | 69 + .../clouddeploy/beta/delivery_pipeline.go | 66 +- .../clouddeploy/beta/delivery_pipeline.yaml | 41 + .../beta/delivery_pipeline_beta_yaml_embed.go | 6 +- .../beta/delivery_pipeline_internal.go | 334 +++ .../beta/delivery_pipeline_schema.go | 27 + services/google/clouddeploy/beta/target.go | 225 +- services/google/clouddeploy/beta/target.yaml | 69 + .../beta/target_beta_yaml_embed.go | 6 +- .../clouddeploy/beta/target_internal.go | 1953 ++++++++++++----- .../google/clouddeploy/beta/target_schema.go | 69 + .../google/clouddeploy/delivery_pipeline.go | 66 +- .../google/clouddeploy/delivery_pipeline.yaml | 41 + .../clouddeploy/delivery_pipeline_internal.go | 334 +++ .../clouddeploy/delivery_pipeline_schema.go | 27 + .../delivery_pipeline_yaml_embed.go | 6 +- services/google/clouddeploy/target.go | 225 +- services/google/clouddeploy/target.yaml | 69 + .../google/clouddeploy/target_internal.go | 1953 ++++++++++++----- services/google/clouddeploy/target_schema.go | 69 + .../google/clouddeploy/target_yaml_embed.go | 6 +- .../clouddeploy/alpha/delivery_pipeline.go | 37 + .../google/clouddeploy/alpha/target.go | 100 + .../clouddeploy/beta/delivery_pipeline.go | 37 + .../google/clouddeploy/beta/target.go | 100 + .../google/clouddeploy/delivery_pipeline.go | 37 + unstructured/google/clouddeploy/target.go | 100 + 54 files changed, 8127 insertions(+), 1758 deletions(-) diff --git a/python/proto/clouddeploy/alpha/delivery_pipeline.proto b/python/proto/clouddeploy/alpha/delivery_pipeline.proto index f1da53629..c38d83713 100755 --- a/python/proto/clouddeploy/alpha/delivery_pipeline.proto +++ b/python/proto/clouddeploy/alpha/delivery_pipeline.proto @@ -91,6 +91,12 @@ message ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntim string route_update_wait_time = 4; string stable_cutback_duration = 5; string pod_selector_label = 6; + ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations route_destinations = 7; +} + +message ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + repeated string destination_ids = 1; + bool propagate_service = 2; } message ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { diff --git a/python/proto/clouddeploy/alpha/target.proto b/python/proto/clouddeploy/alpha/target.proto index 458d21e8f..1a5f32520 100755 --- a/python/proto/clouddeploy/alpha/target.proto +++ b/python/proto/clouddeploy/alpha/target.proto @@ -49,6 +49,7 @@ message ClouddeployAlphaTarget { ClouddeployAlphaTargetMultiTarget multi_target = 17; map deploy_parameters = 18; ClouddeployAlphaTargetCustomTarget custom_target = 19; + map associated_entities = 20; } message ClouddeployAlphaTargetGke { @@ -82,6 +83,21 @@ message ClouddeployAlphaTargetCustomTarget { string custom_target_type = 1; } +message ClouddeployAlphaTargetAssociatedEntities { + repeated ClouddeployAlphaTargetAssociatedEntitiesGkeClusters gke_clusters = 1; + repeated ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters anthos_clusters = 2; +} + +message ClouddeployAlphaTargetAssociatedEntitiesGkeClusters { + string cluster = 1; + bool internal_ip = 2; + string proxy_url = 3; +} + +message ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters { + string membership = 1; +} + message ApplyClouddeployAlphaTargetRequest { ClouddeployAlphaTarget resource = 1; repeated LifecycleDirective lifecycle_directives = 2; diff --git a/python/proto/clouddeploy/beta/delivery_pipeline.proto b/python/proto/clouddeploy/beta/delivery_pipeline.proto index 907fd4559..45303e24b 100755 --- a/python/proto/clouddeploy/beta/delivery_pipeline.proto +++ b/python/proto/clouddeploy/beta/delivery_pipeline.proto @@ -91,6 +91,12 @@ message ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntime string route_update_wait_time = 4; string stable_cutback_duration = 5; string pod_selector_label = 6; + ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations route_destinations = 7; +} + +message ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + repeated string destination_ids = 1; + bool propagate_service = 2; } message ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { diff --git a/python/proto/clouddeploy/beta/target.proto b/python/proto/clouddeploy/beta/target.proto index 580acb2a0..86d3ba274 100755 --- a/python/proto/clouddeploy/beta/target.proto +++ b/python/proto/clouddeploy/beta/target.proto @@ -49,6 +49,7 @@ message ClouddeployBetaTarget { ClouddeployBetaTargetMultiTarget multi_target = 17; map deploy_parameters = 18; ClouddeployBetaTargetCustomTarget custom_target = 19; + map associated_entities = 20; } message ClouddeployBetaTargetGke { @@ -82,6 +83,21 @@ message ClouddeployBetaTargetCustomTarget { string custom_target_type = 1; } +message ClouddeployBetaTargetAssociatedEntities { + repeated ClouddeployBetaTargetAssociatedEntitiesGkeClusters gke_clusters = 1; + repeated ClouddeployBetaTargetAssociatedEntitiesAnthosClusters anthos_clusters = 2; +} + +message ClouddeployBetaTargetAssociatedEntitiesGkeClusters { + string cluster = 1; + bool internal_ip = 2; + string proxy_url = 3; +} + +message ClouddeployBetaTargetAssociatedEntitiesAnthosClusters { + string membership = 1; +} + message ApplyClouddeployBetaTargetRequest { ClouddeployBetaTarget resource = 1; repeated LifecycleDirective lifecycle_directives = 2; diff --git a/python/proto/clouddeploy/delivery_pipeline.proto b/python/proto/clouddeploy/delivery_pipeline.proto index dae9e683b..91b05f744 100755 --- a/python/proto/clouddeploy/delivery_pipeline.proto +++ b/python/proto/clouddeploy/delivery_pipeline.proto @@ -91,6 +91,12 @@ message ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConf string route_update_wait_time = 4; string stable_cutback_duration = 5; string pod_selector_label = 6; + ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations route_destinations = 7; +} + +message ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + repeated string destination_ids = 1; + bool propagate_service = 2; } message ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { diff --git a/python/proto/clouddeploy/target.proto b/python/proto/clouddeploy/target.proto index ee2a94d11..ea6c142f4 100755 --- a/python/proto/clouddeploy/target.proto +++ b/python/proto/clouddeploy/target.proto @@ -49,6 +49,7 @@ message ClouddeployTarget { ClouddeployTargetMultiTarget multi_target = 17; map deploy_parameters = 18; ClouddeployTargetCustomTarget custom_target = 19; + map associated_entities = 20; } message ClouddeployTargetGke { @@ -82,6 +83,21 @@ message ClouddeployTargetCustomTarget { string custom_target_type = 1; } +message ClouddeployTargetAssociatedEntities { + repeated ClouddeployTargetAssociatedEntitiesGkeClusters gke_clusters = 1; + repeated ClouddeployTargetAssociatedEntitiesAnthosClusters anthos_clusters = 2; +} + +message ClouddeployTargetAssociatedEntitiesGkeClusters { + string cluster = 1; + bool internal_ip = 2; + string proxy_url = 3; +} + +message ClouddeployTargetAssociatedEntitiesAnthosClusters { + string membership = 1; +} + message ApplyClouddeployTargetRequest { ClouddeployTarget resource = 1; repeated LifecycleDirective lifecycle_directives = 2; diff --git a/python/services/clouddeploy/alpha/delivery_pipeline.py b/python/services/clouddeploy/alpha/delivery_pipeline.py index 2c2d47261..14e2f7147 100755 --- a/python/services/clouddeploy/alpha/delivery_pipeline.py +++ b/python/services/clouddeploy/alpha/delivery_pipeline.py @@ -767,6 +767,7 @@ def __init__( route_update_wait_time: str = None, stable_cutback_duration: str = None, pod_selector_label: str = None, + route_destinations: dict = None, ): self.http_route = http_route self.service = service @@ -774,6 +775,7 @@ def __init__( self.route_update_wait_time = route_update_wait_time self.stable_cutback_duration = stable_cutback_duration self.pod_selector_label = pod_selector_label + self.route_destinations = route_destinations @classmethod def to_proto(self, resource): @@ -799,6 +801,16 @@ def to_proto(self, resource): ) if Primitive.to_proto(resource.pod_selector_label): res.pod_selector_label = Primitive.to_proto(resource.pod_selector_label) + if DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ): + res.route_destinations.CopyFrom( + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ) + ) + else: + res.ClearField("route_destinations") return res @classmethod @@ -817,6 +829,9 @@ def from_proto(self, resource): resource.stable_cutback_duration ), pod_selector_label=Primitive.from_proto(resource.pod_selector_label), + route_destinations=DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + resource.route_destinations + ), ) @@ -844,6 +859,63 @@ def from_proto(self, resources): ] +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + object +): + + def __init__(self, destination_ids: list = None, propagate_service: bool = None): + self.destination_ids = destination_ids + self.propagate_service = propagate_service + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = ( + delivery_pipeline_pb2.ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations() + ) + if Primitive.to_proto(resource.destination_ids): + res.destination_ids.extend(Primitive.to_proto(resource.destination_ids)) + if Primitive.to_proto(resource.propagate_service): + res.propagate_service = Primitive.to_proto(resource.propagate_service) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + destination_ids=Primitive.from_proto(resource.destination_ids), + propagate_service=Primitive.from_proto(resource.propagate_service), + ) + + +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsArray( + object +): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + i + ) + for i in resources + ] + + @classmethod + def from_proto(self, resources): + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + i + ) + for i in resources + ] + + class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking( object ): diff --git a/python/services/clouddeploy/alpha/delivery_pipeline_server.go b/python/services/clouddeploy/alpha/delivery_pipeline_server.go index 44aeb2d00..89583f6cf 100755 --- a/python/services/clouddeploy/alpha/delivery_pipeline_server.go +++ b/python/services/clouddeploy/alpha/delivery_pipeline_server.go @@ -152,6 +152,21 @@ func ProtoToClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRu RouteUpdateWaitTime: dcl.StringOrNil(p.GetRouteUpdateWaitTime()), StableCutbackDuration: dcl.StringOrNil(p.GetStableCutbackDuration()), PodSelectorLabel: dcl.StringOrNil(p.GetPodSelectorLabel()), + RouteDestinations: ProtoToClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p.GetRouteDestinations()), + } + return obj +} + +// ProtoToDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object from its proto representation. +func ProtoToClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p *alphapb.ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *alpha.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if p == nil { + return nil + } + obj := &alpha.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{ + PropagateService: dcl.Bool(p.GetPropagateService()), + } + for _, r := range p.GetDestinationIds() { + obj.DestinationIds = append(obj.DestinationIds, r) } return obj } @@ -495,6 +510,22 @@ func ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCo p.SetRouteUpdateWaitTime(dcl.ValueOrEmptyString(o.RouteUpdateWaitTime)) p.SetStableCutbackDuration(dcl.ValueOrEmptyString(o.StableCutbackDuration)) p.SetPodSelectorLabel(dcl.ValueOrEmptyString(o.PodSelectorLabel)) + p.SetRouteDestinations(ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o.RouteDestinations)) + return p +} + +// DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object to its proto representation. +func ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o *alpha.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *alphapb.ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if o == nil { + return nil + } + p := &alphapb.ClouddeployAlphaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + p.SetPropagateService(dcl.ValueOrEmptyBool(o.PropagateService)) + sDestinationIds := make([]string, len(o.DestinationIds)) + for i, r := range o.DestinationIds { + sDestinationIds[i] = r + } + p.SetDestinationIds(sDestinationIds) return p } diff --git a/python/services/clouddeploy/alpha/target.py b/python/services/clouddeploy/alpha/target.py index 7be6b99d2..265f460e3 100755 --- a/python/services/clouddeploy/alpha/target.py +++ b/python/services/clouddeploy/alpha/target.py @@ -40,6 +40,7 @@ def __init__( multi_target: dict = None, deploy_parameters: dict = None, custom_target: dict = None, + associated_entities: dict = None, service_account_file: str = "", ): @@ -58,6 +59,7 @@ def __init__( self.multi_target = multi_target self.deploy_parameters = deploy_parameters self.custom_target = custom_target + self.associated_entities = associated_entities self.service_account_file = service_account_file def apply(self): @@ -121,6 +123,11 @@ def apply(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + request.service_account_file = self.service_account_file response = stub.ApplyClouddeployAlphaTarget(request) @@ -145,6 +152,7 @@ def apply(self): self.multi_target = TargetMultiTarget.from_proto(response.multi_target) self.deploy_parameters = Primitive.from_proto(response.deploy_parameters) self.custom_target = TargetCustomTarget.from_proto(response.custom_target) + self.associated_entities = Primitive.from_proto(response.associated_entities) def delete(self): stub = target_pb2_grpc.ClouddeployAlphaTargetServiceStub(channel.Channel()) @@ -208,6 +216,11 @@ def delete(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + response = stub.DeleteClouddeployAlphaTarget(request) @classmethod @@ -269,6 +282,8 @@ def to_proto(self): ) else: resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + resource.associated_entities = Primitive.to_proto(self.associated_entities) return resource @@ -534,6 +549,143 @@ def from_proto(self, resources): return [TargetCustomTarget.from_proto(i) for i in resources] +class TargetAssociatedEntities(object): + + def __init__(self, gke_clusters: list = None, anthos_clusters: list = None): + self.gke_clusters = gke_clusters + self.anthos_clusters = anthos_clusters + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployAlphaTargetAssociatedEntities() + if TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters): + res.gke_clusters.extend( + TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters) + ) + if TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ): + res.anthos_clusters.extend( + TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ) + ) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntities( + gke_clusters=TargetAssociatedEntitiesGkeClustersArray.from_proto( + resource.gke_clusters + ), + anthos_clusters=TargetAssociatedEntitiesAnthosClustersArray.from_proto( + resource.anthos_clusters + ), + ) + + +class TargetAssociatedEntitiesArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntities.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntities.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesGkeClusters(object): + + def __init__( + self, cluster: str = None, internal_ip: bool = None, proxy_url: str = None + ): + self.cluster = cluster + self.internal_ip = internal_ip + self.proxy_url = proxy_url + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployAlphaTargetAssociatedEntitiesGkeClusters() + if Primitive.to_proto(resource.cluster): + res.cluster = Primitive.to_proto(resource.cluster) + if Primitive.to_proto(resource.internal_ip): + res.internal_ip = Primitive.to_proto(resource.internal_ip) + if Primitive.to_proto(resource.proxy_url): + res.proxy_url = Primitive.to_proto(resource.proxy_url) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesGkeClusters( + cluster=Primitive.from_proto(resource.cluster), + internal_ip=Primitive.from_proto(resource.internal_ip), + proxy_url=Primitive.from_proto(resource.proxy_url), + ) + + +class TargetAssociatedEntitiesGkeClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesGkeClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesGkeClusters.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesAnthosClusters(object): + + def __init__(self, membership: str = None): + self.membership = membership + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters() + if Primitive.to_proto(resource.membership): + res.membership = Primitive.to_proto(resource.membership) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesAnthosClusters( + membership=Primitive.from_proto(resource.membership), + ) + + +class TargetAssociatedEntitiesAnthosClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesAnthosClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesAnthosClusters.from_proto(i) for i in resources] + + class TargetExecutionConfigsUsagesEnum(object): @classmethod def to_proto(self, resource): diff --git a/python/services/clouddeploy/alpha/target_server.go b/python/services/clouddeploy/alpha/target_server.go index 5089bb536..c85fa7bf8 100755 --- a/python/services/clouddeploy/alpha/target_server.go +++ b/python/services/clouddeploy/alpha/target_server.go @@ -112,6 +112,45 @@ func ProtoToClouddeployAlphaTargetCustomTarget(p *alphapb.ClouddeployAlphaTarget return obj } +// ProtoToTargetAssociatedEntities converts a TargetAssociatedEntities object from its proto representation. +func ProtoToClouddeployAlphaTargetAssociatedEntities(p *alphapb.ClouddeployAlphaTargetAssociatedEntities) *alpha.TargetAssociatedEntities { + if p == nil { + return nil + } + obj := &alpha.TargetAssociatedEntities{} + for _, r := range p.GetGkeClusters() { + obj.GkeClusters = append(obj.GkeClusters, *ProtoToClouddeployAlphaTargetAssociatedEntitiesGkeClusters(r)) + } + for _, r := range p.GetAnthosClusters() { + obj.AnthosClusters = append(obj.AnthosClusters, *ProtoToClouddeployAlphaTargetAssociatedEntitiesAnthosClusters(r)) + } + return obj +} + +// ProtoToTargetAssociatedEntitiesGkeClusters converts a TargetAssociatedEntitiesGkeClusters object from its proto representation. +func ProtoToClouddeployAlphaTargetAssociatedEntitiesGkeClusters(p *alphapb.ClouddeployAlphaTargetAssociatedEntitiesGkeClusters) *alpha.TargetAssociatedEntitiesGkeClusters { + if p == nil { + return nil + } + obj := &alpha.TargetAssociatedEntitiesGkeClusters{ + Cluster: dcl.StringOrNil(p.GetCluster()), + InternalIP: dcl.Bool(p.GetInternalIp()), + ProxyUrl: dcl.StringOrNil(p.GetProxyUrl()), + } + return obj +} + +// ProtoToTargetAssociatedEntitiesAnthosClusters converts a TargetAssociatedEntitiesAnthosClusters object from its proto representation. +func ProtoToClouddeployAlphaTargetAssociatedEntitiesAnthosClusters(p *alphapb.ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters) *alpha.TargetAssociatedEntitiesAnthosClusters { + if p == nil { + return nil + } + obj := &alpha.TargetAssociatedEntitiesAnthosClusters{ + Membership: dcl.StringOrNil(p.GetMembership()), + } + return obj +} + // ProtoToTarget converts a Target resource from its proto representation. func ProtoToTarget(p *alphapb.ClouddeployAlphaTarget) *alpha.Target { obj := &alpha.Target{ @@ -223,6 +262,47 @@ func ClouddeployAlphaTargetCustomTargetToProto(o *alpha.TargetCustomTarget) *alp return p } +// TargetAssociatedEntitiesToProto converts a TargetAssociatedEntities object to its proto representation. +func ClouddeployAlphaTargetAssociatedEntitiesToProto(o *alpha.TargetAssociatedEntities) *alphapb.ClouddeployAlphaTargetAssociatedEntities { + if o == nil { + return nil + } + p := &alphapb.ClouddeployAlphaTargetAssociatedEntities{} + sGkeClusters := make([]*alphapb.ClouddeployAlphaTargetAssociatedEntitiesGkeClusters, len(o.GkeClusters)) + for i, r := range o.GkeClusters { + sGkeClusters[i] = ClouddeployAlphaTargetAssociatedEntitiesGkeClustersToProto(&r) + } + p.SetGkeClusters(sGkeClusters) + sAnthosClusters := make([]*alphapb.ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters, len(o.AnthosClusters)) + for i, r := range o.AnthosClusters { + sAnthosClusters[i] = ClouddeployAlphaTargetAssociatedEntitiesAnthosClustersToProto(&r) + } + p.SetAnthosClusters(sAnthosClusters) + return p +} + +// TargetAssociatedEntitiesGkeClustersToProto converts a TargetAssociatedEntitiesGkeClusters object to its proto representation. +func ClouddeployAlphaTargetAssociatedEntitiesGkeClustersToProto(o *alpha.TargetAssociatedEntitiesGkeClusters) *alphapb.ClouddeployAlphaTargetAssociatedEntitiesGkeClusters { + if o == nil { + return nil + } + p := &alphapb.ClouddeployAlphaTargetAssociatedEntitiesGkeClusters{} + p.SetCluster(dcl.ValueOrEmptyString(o.Cluster)) + p.SetInternalIp(dcl.ValueOrEmptyBool(o.InternalIP)) + p.SetProxyUrl(dcl.ValueOrEmptyString(o.ProxyUrl)) + return p +} + +// TargetAssociatedEntitiesAnthosClustersToProto converts a TargetAssociatedEntitiesAnthosClusters object to its proto representation. +func ClouddeployAlphaTargetAssociatedEntitiesAnthosClustersToProto(o *alpha.TargetAssociatedEntitiesAnthosClusters) *alphapb.ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters { + if o == nil { + return nil + } + p := &alphapb.ClouddeployAlphaTargetAssociatedEntitiesAnthosClusters{} + p.SetMembership(dcl.ValueOrEmptyString(o.Membership)) + return p +} + // TargetToProto converts a Target resource to its proto representation. func TargetToProto(resource *alpha.Target) *alphapb.ClouddeployAlphaTarget { p := &alphapb.ClouddeployAlphaTarget{} @@ -261,6 +341,11 @@ func TargetToProto(resource *alpha.Target) *alphapb.ClouddeployAlphaTarget { mDeployParameters[k] = r } p.SetDeployParameters(mDeployParameters) + mAssociatedEntities := make(map[string]*alphapb.ClouddeployAlphaTargetAssociatedEntities, len(resource.AssociatedEntities)) + for k, r := range resource.AssociatedEntities { + mAssociatedEntities[k] = ClouddeployAlphaTargetAssociatedEntitiesToProto(&r) + } + p.SetAssociatedEntities(mAssociatedEntities) return p } diff --git a/python/services/clouddeploy/beta/delivery_pipeline.py b/python/services/clouddeploy/beta/delivery_pipeline.py index 086d5443f..0988bb9b0 100755 --- a/python/services/clouddeploy/beta/delivery_pipeline.py +++ b/python/services/clouddeploy/beta/delivery_pipeline.py @@ -767,6 +767,7 @@ def __init__( route_update_wait_time: str = None, stable_cutback_duration: str = None, pod_selector_label: str = None, + route_destinations: dict = None, ): self.http_route = http_route self.service = service @@ -774,6 +775,7 @@ def __init__( self.route_update_wait_time = route_update_wait_time self.stable_cutback_duration = stable_cutback_duration self.pod_selector_label = pod_selector_label + self.route_destinations = route_destinations @classmethod def to_proto(self, resource): @@ -799,6 +801,16 @@ def to_proto(self, resource): ) if Primitive.to_proto(resource.pod_selector_label): res.pod_selector_label = Primitive.to_proto(resource.pod_selector_label) + if DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ): + res.route_destinations.CopyFrom( + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ) + ) + else: + res.ClearField("route_destinations") return res @classmethod @@ -817,6 +829,9 @@ def from_proto(self, resource): resource.stable_cutback_duration ), pod_selector_label=Primitive.from_proto(resource.pod_selector_label), + route_destinations=DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + resource.route_destinations + ), ) @@ -844,6 +859,63 @@ def from_proto(self, resources): ] +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + object +): + + def __init__(self, destination_ids: list = None, propagate_service: bool = None): + self.destination_ids = destination_ids + self.propagate_service = propagate_service + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = ( + delivery_pipeline_pb2.ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations() + ) + if Primitive.to_proto(resource.destination_ids): + res.destination_ids.extend(Primitive.to_proto(resource.destination_ids)) + if Primitive.to_proto(resource.propagate_service): + res.propagate_service = Primitive.to_proto(resource.propagate_service) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + destination_ids=Primitive.from_proto(resource.destination_ids), + propagate_service=Primitive.from_proto(resource.propagate_service), + ) + + +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsArray( + object +): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + i + ) + for i in resources + ] + + @classmethod + def from_proto(self, resources): + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + i + ) + for i in resources + ] + + class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking( object ): diff --git a/python/services/clouddeploy/beta/delivery_pipeline_server.go b/python/services/clouddeploy/beta/delivery_pipeline_server.go index a14e467c2..ba3530d0b 100755 --- a/python/services/clouddeploy/beta/delivery_pipeline_server.go +++ b/python/services/clouddeploy/beta/delivery_pipeline_server.go @@ -152,6 +152,21 @@ func ProtoToClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRun RouteUpdateWaitTime: dcl.StringOrNil(p.GetRouteUpdateWaitTime()), StableCutbackDuration: dcl.StringOrNil(p.GetStableCutbackDuration()), PodSelectorLabel: dcl.StringOrNil(p.GetPodSelectorLabel()), + RouteDestinations: ProtoToClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p.GetRouteDestinations()), + } + return obj +} + +// ProtoToDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object from its proto representation. +func ProtoToClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p *betapb.ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *beta.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if p == nil { + return nil + } + obj := &beta.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{ + PropagateService: dcl.Bool(p.GetPropagateService()), + } + for _, r := range p.GetDestinationIds() { + obj.DestinationIds = append(obj.DestinationIds, r) } return obj } @@ -495,6 +510,22 @@ func ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon p.SetRouteUpdateWaitTime(dcl.ValueOrEmptyString(o.RouteUpdateWaitTime)) p.SetStableCutbackDuration(dcl.ValueOrEmptyString(o.StableCutbackDuration)) p.SetPodSelectorLabel(dcl.ValueOrEmptyString(o.PodSelectorLabel)) + p.SetRouteDestinations(ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o.RouteDestinations)) + return p +} + +// DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object to its proto representation. +func ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o *beta.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *betapb.ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if o == nil { + return nil + } + p := &betapb.ClouddeployBetaDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + p.SetPropagateService(dcl.ValueOrEmptyBool(o.PropagateService)) + sDestinationIds := make([]string, len(o.DestinationIds)) + for i, r := range o.DestinationIds { + sDestinationIds[i] = r + } + p.SetDestinationIds(sDestinationIds) return p } diff --git a/python/services/clouddeploy/beta/target.py b/python/services/clouddeploy/beta/target.py index cfec40279..08512c8e5 100755 --- a/python/services/clouddeploy/beta/target.py +++ b/python/services/clouddeploy/beta/target.py @@ -40,6 +40,7 @@ def __init__( multi_target: dict = None, deploy_parameters: dict = None, custom_target: dict = None, + associated_entities: dict = None, service_account_file: str = "", ): @@ -58,6 +59,7 @@ def __init__( self.multi_target = multi_target self.deploy_parameters = deploy_parameters self.custom_target = custom_target + self.associated_entities = associated_entities self.service_account_file = service_account_file def apply(self): @@ -121,6 +123,11 @@ def apply(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + request.service_account_file = self.service_account_file response = stub.ApplyClouddeployBetaTarget(request) @@ -145,6 +152,7 @@ def apply(self): self.multi_target = TargetMultiTarget.from_proto(response.multi_target) self.deploy_parameters = Primitive.from_proto(response.deploy_parameters) self.custom_target = TargetCustomTarget.from_proto(response.custom_target) + self.associated_entities = Primitive.from_proto(response.associated_entities) def delete(self): stub = target_pb2_grpc.ClouddeployBetaTargetServiceStub(channel.Channel()) @@ -208,6 +216,11 @@ def delete(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + response = stub.DeleteClouddeployBetaTarget(request) @classmethod @@ -269,6 +282,8 @@ def to_proto(self): ) else: resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + resource.associated_entities = Primitive.to_proto(self.associated_entities) return resource @@ -534,6 +549,143 @@ def from_proto(self, resources): return [TargetCustomTarget.from_proto(i) for i in resources] +class TargetAssociatedEntities(object): + + def __init__(self, gke_clusters: list = None, anthos_clusters: list = None): + self.gke_clusters = gke_clusters + self.anthos_clusters = anthos_clusters + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployBetaTargetAssociatedEntities() + if TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters): + res.gke_clusters.extend( + TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters) + ) + if TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ): + res.anthos_clusters.extend( + TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ) + ) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntities( + gke_clusters=TargetAssociatedEntitiesGkeClustersArray.from_proto( + resource.gke_clusters + ), + anthos_clusters=TargetAssociatedEntitiesAnthosClustersArray.from_proto( + resource.anthos_clusters + ), + ) + + +class TargetAssociatedEntitiesArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntities.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntities.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesGkeClusters(object): + + def __init__( + self, cluster: str = None, internal_ip: bool = None, proxy_url: str = None + ): + self.cluster = cluster + self.internal_ip = internal_ip + self.proxy_url = proxy_url + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployBetaTargetAssociatedEntitiesGkeClusters() + if Primitive.to_proto(resource.cluster): + res.cluster = Primitive.to_proto(resource.cluster) + if Primitive.to_proto(resource.internal_ip): + res.internal_ip = Primitive.to_proto(resource.internal_ip) + if Primitive.to_proto(resource.proxy_url): + res.proxy_url = Primitive.to_proto(resource.proxy_url) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesGkeClusters( + cluster=Primitive.from_proto(resource.cluster), + internal_ip=Primitive.from_proto(resource.internal_ip), + proxy_url=Primitive.from_proto(resource.proxy_url), + ) + + +class TargetAssociatedEntitiesGkeClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesGkeClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesGkeClusters.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesAnthosClusters(object): + + def __init__(self, membership: str = None): + self.membership = membership + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployBetaTargetAssociatedEntitiesAnthosClusters() + if Primitive.to_proto(resource.membership): + res.membership = Primitive.to_proto(resource.membership) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesAnthosClusters( + membership=Primitive.from_proto(resource.membership), + ) + + +class TargetAssociatedEntitiesAnthosClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesAnthosClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesAnthosClusters.from_proto(i) for i in resources] + + class TargetExecutionConfigsUsagesEnum(object): @classmethod def to_proto(self, resource): diff --git a/python/services/clouddeploy/beta/target_server.go b/python/services/clouddeploy/beta/target_server.go index 745ad0c7f..b444f7b97 100755 --- a/python/services/clouddeploy/beta/target_server.go +++ b/python/services/clouddeploy/beta/target_server.go @@ -112,6 +112,45 @@ func ProtoToClouddeployBetaTargetCustomTarget(p *betapb.ClouddeployBetaTargetCus return obj } +// ProtoToTargetAssociatedEntities converts a TargetAssociatedEntities object from its proto representation. +func ProtoToClouddeployBetaTargetAssociatedEntities(p *betapb.ClouddeployBetaTargetAssociatedEntities) *beta.TargetAssociatedEntities { + if p == nil { + return nil + } + obj := &beta.TargetAssociatedEntities{} + for _, r := range p.GetGkeClusters() { + obj.GkeClusters = append(obj.GkeClusters, *ProtoToClouddeployBetaTargetAssociatedEntitiesGkeClusters(r)) + } + for _, r := range p.GetAnthosClusters() { + obj.AnthosClusters = append(obj.AnthosClusters, *ProtoToClouddeployBetaTargetAssociatedEntitiesAnthosClusters(r)) + } + return obj +} + +// ProtoToTargetAssociatedEntitiesGkeClusters converts a TargetAssociatedEntitiesGkeClusters object from its proto representation. +func ProtoToClouddeployBetaTargetAssociatedEntitiesGkeClusters(p *betapb.ClouddeployBetaTargetAssociatedEntitiesGkeClusters) *beta.TargetAssociatedEntitiesGkeClusters { + if p == nil { + return nil + } + obj := &beta.TargetAssociatedEntitiesGkeClusters{ + Cluster: dcl.StringOrNil(p.GetCluster()), + InternalIP: dcl.Bool(p.GetInternalIp()), + ProxyUrl: dcl.StringOrNil(p.GetProxyUrl()), + } + return obj +} + +// ProtoToTargetAssociatedEntitiesAnthosClusters converts a TargetAssociatedEntitiesAnthosClusters object from its proto representation. +func ProtoToClouddeployBetaTargetAssociatedEntitiesAnthosClusters(p *betapb.ClouddeployBetaTargetAssociatedEntitiesAnthosClusters) *beta.TargetAssociatedEntitiesAnthosClusters { + if p == nil { + return nil + } + obj := &beta.TargetAssociatedEntitiesAnthosClusters{ + Membership: dcl.StringOrNil(p.GetMembership()), + } + return obj +} + // ProtoToTarget converts a Target resource from its proto representation. func ProtoToTarget(p *betapb.ClouddeployBetaTarget) *beta.Target { obj := &beta.Target{ @@ -223,6 +262,47 @@ func ClouddeployBetaTargetCustomTargetToProto(o *beta.TargetCustomTarget) *betap return p } +// TargetAssociatedEntitiesToProto converts a TargetAssociatedEntities object to its proto representation. +func ClouddeployBetaTargetAssociatedEntitiesToProto(o *beta.TargetAssociatedEntities) *betapb.ClouddeployBetaTargetAssociatedEntities { + if o == nil { + return nil + } + p := &betapb.ClouddeployBetaTargetAssociatedEntities{} + sGkeClusters := make([]*betapb.ClouddeployBetaTargetAssociatedEntitiesGkeClusters, len(o.GkeClusters)) + for i, r := range o.GkeClusters { + sGkeClusters[i] = ClouddeployBetaTargetAssociatedEntitiesGkeClustersToProto(&r) + } + p.SetGkeClusters(sGkeClusters) + sAnthosClusters := make([]*betapb.ClouddeployBetaTargetAssociatedEntitiesAnthosClusters, len(o.AnthosClusters)) + for i, r := range o.AnthosClusters { + sAnthosClusters[i] = ClouddeployBetaTargetAssociatedEntitiesAnthosClustersToProto(&r) + } + p.SetAnthosClusters(sAnthosClusters) + return p +} + +// TargetAssociatedEntitiesGkeClustersToProto converts a TargetAssociatedEntitiesGkeClusters object to its proto representation. +func ClouddeployBetaTargetAssociatedEntitiesGkeClustersToProto(o *beta.TargetAssociatedEntitiesGkeClusters) *betapb.ClouddeployBetaTargetAssociatedEntitiesGkeClusters { + if o == nil { + return nil + } + p := &betapb.ClouddeployBetaTargetAssociatedEntitiesGkeClusters{} + p.SetCluster(dcl.ValueOrEmptyString(o.Cluster)) + p.SetInternalIp(dcl.ValueOrEmptyBool(o.InternalIP)) + p.SetProxyUrl(dcl.ValueOrEmptyString(o.ProxyUrl)) + return p +} + +// TargetAssociatedEntitiesAnthosClustersToProto converts a TargetAssociatedEntitiesAnthosClusters object to its proto representation. +func ClouddeployBetaTargetAssociatedEntitiesAnthosClustersToProto(o *beta.TargetAssociatedEntitiesAnthosClusters) *betapb.ClouddeployBetaTargetAssociatedEntitiesAnthosClusters { + if o == nil { + return nil + } + p := &betapb.ClouddeployBetaTargetAssociatedEntitiesAnthosClusters{} + p.SetMembership(dcl.ValueOrEmptyString(o.Membership)) + return p +} + // TargetToProto converts a Target resource to its proto representation. func TargetToProto(resource *beta.Target) *betapb.ClouddeployBetaTarget { p := &betapb.ClouddeployBetaTarget{} @@ -261,6 +341,11 @@ func TargetToProto(resource *beta.Target) *betapb.ClouddeployBetaTarget { mDeployParameters[k] = r } p.SetDeployParameters(mDeployParameters) + mAssociatedEntities := make(map[string]*betapb.ClouddeployBetaTargetAssociatedEntities, len(resource.AssociatedEntities)) + for k, r := range resource.AssociatedEntities { + mAssociatedEntities[k] = ClouddeployBetaTargetAssociatedEntitiesToProto(&r) + } + p.SetAssociatedEntities(mAssociatedEntities) return p } diff --git a/python/services/clouddeploy/delivery_pipeline.py b/python/services/clouddeploy/delivery_pipeline.py index 942a641ac..d8898145d 100755 --- a/python/services/clouddeploy/delivery_pipeline.py +++ b/python/services/clouddeploy/delivery_pipeline.py @@ -765,6 +765,7 @@ def __init__( route_update_wait_time: str = None, stable_cutback_duration: str = None, pod_selector_label: str = None, + route_destinations: dict = None, ): self.http_route = http_route self.service = service @@ -772,6 +773,7 @@ def __init__( self.route_update_wait_time = route_update_wait_time self.stable_cutback_duration = stable_cutback_duration self.pod_selector_label = pod_selector_label + self.route_destinations = route_destinations @classmethod def to_proto(self, resource): @@ -797,6 +799,16 @@ def to_proto(self, resource): ) if Primitive.to_proto(resource.pod_selector_label): res.pod_selector_label = Primitive.to_proto(resource.pod_selector_label) + if DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ): + res.route_destinations.CopyFrom( + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + resource.route_destinations + ) + ) + else: + res.ClearField("route_destinations") return res @classmethod @@ -815,6 +827,9 @@ def from_proto(self, resource): resource.stable_cutback_duration ), pod_selector_label=Primitive.from_proto(resource.pod_selector_label), + route_destinations=DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + resource.route_destinations + ), ) @@ -842,6 +857,63 @@ def from_proto(self, resources): ] +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + object +): + + def __init__(self, destination_ids: list = None, propagate_service: bool = None): + self.destination_ids = destination_ids + self.propagate_service = propagate_service + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = ( + delivery_pipeline_pb2.ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations() + ) + if Primitive.to_proto(resource.destination_ids): + res.destination_ids.extend(Primitive.to_proto(resource.destination_ids)) + if Primitive.to_proto(resource.propagate_service): + res.propagate_service = Primitive.to_proto(resource.propagate_service) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations( + destination_ids=Primitive.from_proto(resource.destination_ids), + propagate_service=Primitive.from_proto(resource.propagate_service), + ) + + +class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsArray( + object +): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.to_proto( + i + ) + for i in resources + ] + + @classmethod + def from_proto(self, resources): + return [ + DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations.from_proto( + i + ) + for i in resources + ] + + class DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking( object ): diff --git a/python/services/clouddeploy/delivery_pipeline_server.go b/python/services/clouddeploy/delivery_pipeline_server.go index ff4d12d5c..30f4788a1 100755 --- a/python/services/clouddeploy/delivery_pipeline_server.go +++ b/python/services/clouddeploy/delivery_pipeline_server.go @@ -152,6 +152,21 @@ func ProtoToClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntime RouteUpdateWaitTime: dcl.StringOrNil(p.GetRouteUpdateWaitTime()), StableCutbackDuration: dcl.StringOrNil(p.GetStableCutbackDuration()), PodSelectorLabel: dcl.StringOrNil(p.GetPodSelectorLabel()), + RouteDestinations: ProtoToClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p.GetRouteDestinations()), + } + return obj +} + +// ProtoToDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object from its proto representation. +func ProtoToClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(p *clouddeploypb.ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if p == nil { + return nil + } + obj := &clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{ + PropagateService: dcl.Bool(p.GetPropagateService()), + } + for _, r := range p.GetDestinationIds() { + obj.DestinationIds = append(obj.DestinationIds, r) } return obj } @@ -495,6 +510,22 @@ func ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigK p.SetRouteUpdateWaitTime(dcl.ValueOrEmptyString(o.RouteUpdateWaitTime)) p.SetStableCutbackDuration(dcl.ValueOrEmptyString(o.StableCutbackDuration)) p.SetPodSelectorLabel(dcl.ValueOrEmptyString(o.PodSelectorLabel)) + p.SetRouteDestinations(ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o.RouteDestinations)) + return p +} + +// DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto converts a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations object to its proto representation. +func ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsToProto(o *clouddeploy.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *clouddeploypb.ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if o == nil { + return nil + } + p := &clouddeploypb.ClouddeployDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + p.SetPropagateService(dcl.ValueOrEmptyBool(o.PropagateService)) + sDestinationIds := make([]string, len(o.DestinationIds)) + for i, r := range o.DestinationIds { + sDestinationIds[i] = r + } + p.SetDestinationIds(sDestinationIds) return p } diff --git a/python/services/clouddeploy/target.py b/python/services/clouddeploy/target.py index c0af5ad65..22b2a1e12 100755 --- a/python/services/clouddeploy/target.py +++ b/python/services/clouddeploy/target.py @@ -40,6 +40,7 @@ def __init__( multi_target: dict = None, deploy_parameters: dict = None, custom_target: dict = None, + associated_entities: dict = None, service_account_file: str = "", ): @@ -58,6 +59,7 @@ def __init__( self.multi_target = multi_target self.deploy_parameters = deploy_parameters self.custom_target = custom_target + self.associated_entities = associated_entities self.service_account_file = service_account_file def apply(self): @@ -121,6 +123,11 @@ def apply(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + request.service_account_file = self.service_account_file response = stub.ApplyClouddeployTarget(request) @@ -145,6 +152,7 @@ def apply(self): self.multi_target = TargetMultiTarget.from_proto(response.multi_target) self.deploy_parameters = Primitive.from_proto(response.deploy_parameters) self.custom_target = TargetCustomTarget.from_proto(response.custom_target) + self.associated_entities = Primitive.from_proto(response.associated_entities) def delete(self): stub = target_pb2_grpc.ClouddeployTargetServiceStub(channel.Channel()) @@ -208,6 +216,11 @@ def delete(self): ) else: request.resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + request.resource.associated_entities = Primitive.to_proto( + self.associated_entities + ) + response = stub.DeleteClouddeployTarget(request) @classmethod @@ -269,6 +282,8 @@ def to_proto(self): ) else: resource.ClearField("custom_target") + if Primitive.to_proto(self.associated_entities): + resource.associated_entities = Primitive.to_proto(self.associated_entities) return resource @@ -534,6 +549,143 @@ def from_proto(self, resources): return [TargetCustomTarget.from_proto(i) for i in resources] +class TargetAssociatedEntities(object): + + def __init__(self, gke_clusters: list = None, anthos_clusters: list = None): + self.gke_clusters = gke_clusters + self.anthos_clusters = anthos_clusters + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployTargetAssociatedEntities() + if TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters): + res.gke_clusters.extend( + TargetAssociatedEntitiesGkeClustersArray.to_proto(resource.gke_clusters) + ) + if TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ): + res.anthos_clusters.extend( + TargetAssociatedEntitiesAnthosClustersArray.to_proto( + resource.anthos_clusters + ) + ) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntities( + gke_clusters=TargetAssociatedEntitiesGkeClustersArray.from_proto( + resource.gke_clusters + ), + anthos_clusters=TargetAssociatedEntitiesAnthosClustersArray.from_proto( + resource.anthos_clusters + ), + ) + + +class TargetAssociatedEntitiesArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntities.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntities.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesGkeClusters(object): + + def __init__( + self, cluster: str = None, internal_ip: bool = None, proxy_url: str = None + ): + self.cluster = cluster + self.internal_ip = internal_ip + self.proxy_url = proxy_url + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployTargetAssociatedEntitiesGkeClusters() + if Primitive.to_proto(resource.cluster): + res.cluster = Primitive.to_proto(resource.cluster) + if Primitive.to_proto(resource.internal_ip): + res.internal_ip = Primitive.to_proto(resource.internal_ip) + if Primitive.to_proto(resource.proxy_url): + res.proxy_url = Primitive.to_proto(resource.proxy_url) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesGkeClusters( + cluster=Primitive.from_proto(resource.cluster), + internal_ip=Primitive.from_proto(resource.internal_ip), + proxy_url=Primitive.from_proto(resource.proxy_url), + ) + + +class TargetAssociatedEntitiesGkeClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesGkeClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesGkeClusters.from_proto(i) for i in resources] + + +class TargetAssociatedEntitiesAnthosClusters(object): + + def __init__(self, membership: str = None): + self.membership = membership + + @classmethod + def to_proto(self, resource): + if not resource: + return None + + res = target_pb2.ClouddeployTargetAssociatedEntitiesAnthosClusters() + if Primitive.to_proto(resource.membership): + res.membership = Primitive.to_proto(resource.membership) + return res + + @classmethod + def from_proto(self, resource): + if not resource: + return None + + return TargetAssociatedEntitiesAnthosClusters( + membership=Primitive.from_proto(resource.membership), + ) + + +class TargetAssociatedEntitiesAnthosClustersArray(object): + @classmethod + def to_proto(self, resources): + if not resources: + return resources + return [TargetAssociatedEntitiesAnthosClusters.to_proto(i) for i in resources] + + @classmethod + def from_proto(self, resources): + return [TargetAssociatedEntitiesAnthosClusters.from_proto(i) for i in resources] + + class TargetExecutionConfigsUsagesEnum(object): @classmethod def to_proto(self, resource): diff --git a/python/services/clouddeploy/target_server.go b/python/services/clouddeploy/target_server.go index 9f47553b2..fd1df433e 100755 --- a/python/services/clouddeploy/target_server.go +++ b/python/services/clouddeploy/target_server.go @@ -112,6 +112,45 @@ func ProtoToClouddeployTargetCustomTarget(p *clouddeploypb.ClouddeployTargetCust return obj } +// ProtoToTargetAssociatedEntities converts a TargetAssociatedEntities object from its proto representation. +func ProtoToClouddeployTargetAssociatedEntities(p *clouddeploypb.ClouddeployTargetAssociatedEntities) *clouddeploy.TargetAssociatedEntities { + if p == nil { + return nil + } + obj := &clouddeploy.TargetAssociatedEntities{} + for _, r := range p.GetGkeClusters() { + obj.GkeClusters = append(obj.GkeClusters, *ProtoToClouddeployTargetAssociatedEntitiesGkeClusters(r)) + } + for _, r := range p.GetAnthosClusters() { + obj.AnthosClusters = append(obj.AnthosClusters, *ProtoToClouddeployTargetAssociatedEntitiesAnthosClusters(r)) + } + return obj +} + +// ProtoToTargetAssociatedEntitiesGkeClusters converts a TargetAssociatedEntitiesGkeClusters object from its proto representation. +func ProtoToClouddeployTargetAssociatedEntitiesGkeClusters(p *clouddeploypb.ClouddeployTargetAssociatedEntitiesGkeClusters) *clouddeploy.TargetAssociatedEntitiesGkeClusters { + if p == nil { + return nil + } + obj := &clouddeploy.TargetAssociatedEntitiesGkeClusters{ + Cluster: dcl.StringOrNil(p.GetCluster()), + InternalIP: dcl.Bool(p.GetInternalIp()), + ProxyUrl: dcl.StringOrNil(p.GetProxyUrl()), + } + return obj +} + +// ProtoToTargetAssociatedEntitiesAnthosClusters converts a TargetAssociatedEntitiesAnthosClusters object from its proto representation. +func ProtoToClouddeployTargetAssociatedEntitiesAnthosClusters(p *clouddeploypb.ClouddeployTargetAssociatedEntitiesAnthosClusters) *clouddeploy.TargetAssociatedEntitiesAnthosClusters { + if p == nil { + return nil + } + obj := &clouddeploy.TargetAssociatedEntitiesAnthosClusters{ + Membership: dcl.StringOrNil(p.GetMembership()), + } + return obj +} + // ProtoToTarget converts a Target resource from its proto representation. func ProtoToTarget(p *clouddeploypb.ClouddeployTarget) *clouddeploy.Target { obj := &clouddeploy.Target{ @@ -223,6 +262,47 @@ func ClouddeployTargetCustomTargetToProto(o *clouddeploy.TargetCustomTarget) *cl return p } +// TargetAssociatedEntitiesToProto converts a TargetAssociatedEntities object to its proto representation. +func ClouddeployTargetAssociatedEntitiesToProto(o *clouddeploy.TargetAssociatedEntities) *clouddeploypb.ClouddeployTargetAssociatedEntities { + if o == nil { + return nil + } + p := &clouddeploypb.ClouddeployTargetAssociatedEntities{} + sGkeClusters := make([]*clouddeploypb.ClouddeployTargetAssociatedEntitiesGkeClusters, len(o.GkeClusters)) + for i, r := range o.GkeClusters { + sGkeClusters[i] = ClouddeployTargetAssociatedEntitiesGkeClustersToProto(&r) + } + p.SetGkeClusters(sGkeClusters) + sAnthosClusters := make([]*clouddeploypb.ClouddeployTargetAssociatedEntitiesAnthosClusters, len(o.AnthosClusters)) + for i, r := range o.AnthosClusters { + sAnthosClusters[i] = ClouddeployTargetAssociatedEntitiesAnthosClustersToProto(&r) + } + p.SetAnthosClusters(sAnthosClusters) + return p +} + +// TargetAssociatedEntitiesGkeClustersToProto converts a TargetAssociatedEntitiesGkeClusters object to its proto representation. +func ClouddeployTargetAssociatedEntitiesGkeClustersToProto(o *clouddeploy.TargetAssociatedEntitiesGkeClusters) *clouddeploypb.ClouddeployTargetAssociatedEntitiesGkeClusters { + if o == nil { + return nil + } + p := &clouddeploypb.ClouddeployTargetAssociatedEntitiesGkeClusters{} + p.SetCluster(dcl.ValueOrEmptyString(o.Cluster)) + p.SetInternalIp(dcl.ValueOrEmptyBool(o.InternalIP)) + p.SetProxyUrl(dcl.ValueOrEmptyString(o.ProxyUrl)) + return p +} + +// TargetAssociatedEntitiesAnthosClustersToProto converts a TargetAssociatedEntitiesAnthosClusters object to its proto representation. +func ClouddeployTargetAssociatedEntitiesAnthosClustersToProto(o *clouddeploy.TargetAssociatedEntitiesAnthosClusters) *clouddeploypb.ClouddeployTargetAssociatedEntitiesAnthosClusters { + if o == nil { + return nil + } + p := &clouddeploypb.ClouddeployTargetAssociatedEntitiesAnthosClusters{} + p.SetMembership(dcl.ValueOrEmptyString(o.Membership)) + return p +} + // TargetToProto converts a Target resource to its proto representation. func TargetToProto(resource *clouddeploy.Target) *clouddeploypb.ClouddeployTarget { p := &clouddeploypb.ClouddeployTarget{} @@ -261,6 +341,11 @@ func TargetToProto(resource *clouddeploy.Target) *clouddeploypb.ClouddeployTarge mDeployParameters[k] = r } p.SetDeployParameters(mDeployParameters) + mAssociatedEntities := make(map[string]*clouddeploypb.ClouddeployTargetAssociatedEntities, len(resource.AssociatedEntities)) + for k, r := range resource.AssociatedEntities { + mAssociatedEntities[k] = ClouddeployTargetAssociatedEntitiesToProto(&r) + } + p.SetAssociatedEntities(mAssociatedEntities) return p } diff --git a/services/google/clouddeploy/alpha/delivery_pipeline.go b/services/google/clouddeploy/alpha/delivery_pipeline.go index 474b50735..9f82aaa3d 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline.go +++ b/services/google/clouddeploy/alpha/delivery_pipeline.go @@ -490,13 +490,14 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet } type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh struct { - empty bool `json:"-"` - HttpRoute *string `json:"httpRoute"` - Service *string `json:"service"` - Deployment *string `json:"deployment"` - RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` - StableCutbackDuration *string `json:"stableCutbackDuration"` - PodSelectorLabel *string `json:"podSelectorLabel"` + empty bool `json:"-"` + HttpRoute *string `json:"httpRoute"` + Service *string `json:"service"` + Deployment *string `json:"deployment"` + RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` + StableCutbackDuration *string `json:"stableCutbackDuration"` + PodSelectorLabel *string `json:"podSelectorLabel"` + RouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations `json:"routeDestinations"` } type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh @@ -526,6 +527,8 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet r.PodSelectorLabel = res.PodSelectorLabel + r.RouteDestinations = res.RouteDestinations + } return nil } @@ -550,6 +553,55 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet return fmt.Sprintf("%x", hash) } +type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations struct { + empty bool `json:"-"` + DestinationIds []string `json:"destinationIds"` + PropagateService *bool `json:"propagateService"` +} + +type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) UnmarshalJSON(data []byte) error { + var res jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } else { + + r.DestinationIds = res.DestinationIds + + r.PropagateService = res.PropagateService + + } + return nil +} + +// This object is used to assert a desired state where this DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{empty: true} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) Empty() bool { + return r.empty +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) String() string { + return dcl.SprintResource(r) +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking struct { empty bool `json:"-"` Service *string `json:"service"` diff --git a/services/google/clouddeploy/alpha/delivery_pipeline.yaml b/services/google/clouddeploy/alpha/delivery_pipeline.yaml index 23c63a403..2773a9053 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline.yaml +++ b/services/google/clouddeploy/alpha/delivery_pipeline.yaml @@ -544,6 +544,47 @@ components: selecting Pods for the Deployment and Service resources. This label must already be present in both resources. + routeDestinations: + type: object + x-dcl-go-name: RouteDestinations + x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + description: Optional. Route destinations + allow configuring the Gateway API HTTPRoute + to be deployed to additional clusters. This + option is available for multi-cluster service + mesh set ups that require the route to exist + in the clusters that call the service. If + unspecified, the HTTPRoute will only be + deployed to the Target cluster. + required: + - destinationIds + properties: + destinationIds: + type: array + x-dcl-go-name: DestinationIds + description: Required. The clusters where + the Gateway API HTTPRoute resource will + be deployed to. Valid entries include + the associated entities IDs configured + in the Target resource and "@self" to + include the Target cluster. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + propagateService: + type: boolean + x-dcl-go-name: PropagateService + description: Optional. Whether to propagate + the Kubernetes Service to the route + destination clusters. The Service will + always be deployed to the Target cluster + even if the HTTPRoute is not. This option + may be used to facilitiate successful + DNS lookup in the route destination + clusters. Can only be set to true if + destinations are specified. routeUpdateWaitTime: type: string x-dcl-go-name: RouteUpdateWaitTime diff --git a/services/google/clouddeploy/alpha/delivery_pipeline_alpha_yaml_embed.go b/services/google/clouddeploy/alpha/delivery_pipeline_alpha_yaml_embed.go index ae99fd398..d5f493114 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline_alpha_yaml_embed.go +++ b/services/google/clouddeploy/alpha/delivery_pipeline_alpha_yaml_embed.go @@ -17,7 +17,7 @@ package alpha // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/alpha/delivery_pipeline.yaml -var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") +var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeDestinations:\n type: object\n x-dcl-go-name: RouteDestinations\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations\n description: Optional. Route destinations\n allow configuring the Gateway API HTTPRoute\n to be deployed to additional clusters. This\n option is available for multi-cluster service\n mesh set ups that require the route to exist\n in the clusters that call the service. If\n unspecified, the HTTPRoute will only be\n deployed to the Target cluster.\n required:\n - destinationIds\n properties:\n destinationIds:\n type: array\n x-dcl-go-name: DestinationIds\n description: Required. The clusters where\n the Gateway API HTTPRoute resource will\n be deployed to. Valid entries include\n the associated entities IDs configured\n in the Target resource and \"@self\" to\n include the Target cluster.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n propagateService:\n type: boolean\n x-dcl-go-name: PropagateService\n description: Optional. Whether to propagate\n the Kubernetes Service to the route\n destination clusters. The Service will\n always be deployed to the Target cluster\n even if the HTTPRoute is not. This option\n may be used to facilitiate successful\n DNS lookup in the route destination\n clusters. Can only be set to true if\n destinations are specified.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") -// 36151 bytes -// MD5: ff459f48fb76c99e0104adec32956cb6 +// 39271 bytes +// MD5: fb938761986f76f4a57bb5452ac3b884 diff --git a/services/google/clouddeploy/alpha/delivery_pipeline_internal.go b/services/google/clouddeploy/alpha/delivery_pipeline_internal.go index 370234ee4..113171857 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/alpha/delivery_pipeline_internal.go @@ -154,6 +154,17 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet if err := dcl.Required(r, "deployment"); err != nil { return err } + if !dcl.IsEmptyValueIndirect(r.RouteDestinations) { + if err := r.RouteDestinations.validate(); err != nil { + return err + } + } + return nil +} +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) validate() error { + if err := dcl.Required(r, "destinationIds"); err != nil { + return err + } return nil } func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) validate() error { @@ -1992,6 +2003,7 @@ func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig } else { cDes.PodSelectorLabel = des.PodSelectorLabel } + cDes.RouteDestinations = canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des.RouteDestinations, initial.RouteDestinations, opts...) return cDes } @@ -2056,6 +2068,7 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon if dcl.StringCanonicalize(des.PodSelectorLabel, nw.PodSelectorLabel) { nw.PodSelectorLabel = des.PodSelectorLabel } + nw.RouteDestinations = canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, des.RouteDestinations, nw.RouteDestinations) return nw } @@ -2106,6 +2119,132 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return items } +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.StringArrayCanonicalize(des.DestinationIds, initial.DestinationIds) { + cDes.DestinationIds = initial.DestinationIds + } else { + cDes.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, initial.PropagateService) || dcl.IsZeroValue(des.PropagateService) { + cDes.PropagateService = initial.PropagateService + } else { + cDes.PropagateService = des.PropagateService + } + + return cDes +} + +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(des, initial []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for _, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for i, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, des, nw *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DestinationIds, nw.DestinationIds) { + nw.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, nw.PropagateService) { + nw.PropagateService = des.PropagateService + } + + return nw +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSet(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &n)) + } + + return items +} + func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { if des == nil { return initial @@ -4371,6 +4510,49 @@ func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber } diffs = append(diffs, ds...) } + + if ds, err := dcl.Diff(desired.RouteDestinations, actual.RouteDestinations, dcl.DiffInfo{ObjectFunction: compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle, EmptyObject: EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("RouteDestinations")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + desiredNotPointer, ok := d.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations or *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + actualNotPointer, ok := a.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DestinationIds, actual.DestinationIds, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("DestinationIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PropagateService, actual.PropagateService, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("PropagateService")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } return diffs, nil } @@ -6257,6 +6439,11 @@ func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubern if v := f.PodSelectorLabel; !dcl.IsEmptyValueIndirect(v) { m["podSelectorLabel"] = v } + if v, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, f.RouteDestinations, res); err != nil { + return nil, fmt.Errorf("error expanding RouteDestinations into routeDestinations: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["routeDestinations"] = v + } return m, nil } @@ -6280,6 +6467,125 @@ func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber r.RouteUpdateWaitTime = dcl.FlattenString(m["routeUpdateWaitTime"]) r.StableCutbackDuration = dcl.FlattenString(m["stableCutbackDuration"]) r.PodSelectorLabel = dcl.FlattenString(m["podSelectorLabel"]) + r.RouteDestinations = flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, m["routeDestinations"], res) + + return r +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, f map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, f []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, i interface{}, res *DeliveryPipeline) map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make(map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + for k, item := range a { + items[k] = *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, i interface{}, res *DeliveryPipeline) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.([]interface{}) + if !ok { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(a)) + for _, item := range a { + items = append(items, *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations expands an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, f *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DestinationIds; v != nil { + m["destinationIds"] = v + } + if v := f.PropagateService; !dcl.IsEmptyValueIndirect(v) { + m["propagateService"] = v + } + + return m, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations flattens an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, i interface{}, res *DeliveryPipeline) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } + r.DestinationIds = dcl.FlattenStringSlice(m["destinationIds"]) + r.PropagateService = dcl.FlattenBool(m["propagateService"]) return r } @@ -8258,6 +8564,20 @@ func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { @@ -8565,6 +8885,20 @@ func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { diff --git a/services/google/clouddeploy/alpha/delivery_pipeline_schema.go b/services/google/clouddeploy/alpha/delivery_pipeline_schema.go index 1487ecf9e..cbc94f51d 100755 --- a/services/google/clouddeploy/alpha/delivery_pipeline_schema.go +++ b/services/google/clouddeploy/alpha/delivery_pipeline_schema.go @@ -589,6 +589,33 @@ func DCLDeliveryPipelineSchema() *dcl.Schema { GoName: "PodSelectorLabel", Description: "Optional. The label to use when selecting Pods for the Deployment and Service resources. This label must already be present in both resources.", }, + "routeDestinations": &dcl.Property{ + Type: "object", + GoName: "RouteDestinations", + GoType: "DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", + Description: "Optional. Route destinations allow configuring the Gateway API HTTPRoute to be deployed to additional clusters. This option is available for multi-cluster service mesh set ups that require the route to exist in the clusters that call the service. If unspecified, the HTTPRoute will only be deployed to the Target cluster.", + Required: []string{ + "destinationIds", + }, + Properties: map[string]*dcl.Property{ + "destinationIds": &dcl.Property{ + Type: "array", + GoName: "DestinationIds", + Description: "Required. The clusters where the Gateway API HTTPRoute resource will be deployed to. Valid entries include the associated entities IDs configured in the Target resource and \"@self\" to include the Target cluster.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "propagateService": &dcl.Property{ + Type: "boolean", + GoName: "PropagateService", + Description: "Optional. Whether to propagate the Kubernetes Service to the route destination clusters. The Service will always be deployed to the Target cluster even if the HTTPRoute is not. This option may be used to facilitiate successful DNS lookup in the route destination clusters. Can only be set to true if destinations are specified.", + }, + }, + }, "routeUpdateWaitTime": &dcl.Property{ Type: "string", GoName: "RouteUpdateWaitTime", diff --git a/services/google/clouddeploy/alpha/target.go b/services/google/clouddeploy/alpha/target.go index db2cfe2f2..9051de017 100755 --- a/services/google/clouddeploy/alpha/target.go +++ b/services/google/clouddeploy/alpha/target.go @@ -26,25 +26,26 @@ import ( ) type Target struct { - Name *string `json:"name"` - TargetId *string `json:"targetId"` - Uid *string `json:"uid"` - Description *string `json:"description"` - Annotations map[string]string `json:"annotations"` - Labels map[string]string `json:"labels"` - RequireApproval *bool `json:"requireApproval"` - CreateTime *string `json:"createTime"` - UpdateTime *string `json:"updateTime"` - Gke *TargetGke `json:"gke"` - AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` - Etag *string `json:"etag"` - ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` - Project *string `json:"project"` - Location *string `json:"location"` - Run *TargetRun `json:"run"` - MultiTarget *TargetMultiTarget `json:"multiTarget"` - DeployParameters map[string]string `json:"deployParameters"` - CustomTarget *TargetCustomTarget `json:"customTarget"` + Name *string `json:"name"` + TargetId *string `json:"targetId"` + Uid *string `json:"uid"` + Description *string `json:"description"` + Annotations map[string]string `json:"annotations"` + Labels map[string]string `json:"labels"` + RequireApproval *bool `json:"requireApproval"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + Gke *TargetGke `json:"gke"` + AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` + Etag *string `json:"etag"` + ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` + Project *string `json:"project"` + Location *string `json:"location"` + Run *TargetRun `json:"run"` + MultiTarget *TargetMultiTarget `json:"multiTarget"` + DeployParameters map[string]string `json:"deployParameters"` + CustomTarget *TargetCustomTarget `json:"customTarget"` + AssociatedEntities map[string]TargetAssociatedEntities `json:"associatedEntities"` } func (r *Target) String() string { @@ -375,6 +376,153 @@ func (r *TargetCustomTarget) HashCode() string { return fmt.Sprintf("%x", hash) } +type TargetAssociatedEntities struct { + empty bool `json:"-"` + GkeClusters []TargetAssociatedEntitiesGkeClusters `json:"gkeClusters"` + AnthosClusters []TargetAssociatedEntitiesAnthosClusters `json:"anthosClusters"` +} + +type jsonTargetAssociatedEntities TargetAssociatedEntities + +func (r *TargetAssociatedEntities) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntities + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntities + } else { + + r.GkeClusters = res.GkeClusters + + r.AnthosClusters = res.AnthosClusters + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntities is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntities *TargetAssociatedEntities = &TargetAssociatedEntities{empty: true} + +func (r *TargetAssociatedEntities) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntities) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntities) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesGkeClusters struct { + empty bool `json:"-"` + Cluster *string `json:"cluster"` + InternalIP *bool `json:"internalIP"` + ProxyUrl *string `json:"proxyUrl"` +} + +type jsonTargetAssociatedEntitiesGkeClusters TargetAssociatedEntitiesGkeClusters + +func (r *TargetAssociatedEntitiesGkeClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesGkeClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesGkeClusters + } else { + + r.Cluster = res.Cluster + + r.InternalIP = res.InternalIP + + r.ProxyUrl = res.ProxyUrl + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesGkeClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesGkeClusters *TargetAssociatedEntitiesGkeClusters = &TargetAssociatedEntitiesGkeClusters{empty: true} + +func (r *TargetAssociatedEntitiesGkeClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesGkeClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesGkeClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesAnthosClusters struct { + empty bool `json:"-"` + Membership *string `json:"membership"` +} + +type jsonTargetAssociatedEntitiesAnthosClusters TargetAssociatedEntitiesAnthosClusters + +func (r *TargetAssociatedEntitiesAnthosClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesAnthosClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesAnthosClusters + } else { + + r.Membership = res.Membership + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesAnthosClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesAnthosClusters *TargetAssociatedEntitiesAnthosClusters = &TargetAssociatedEntitiesAnthosClusters{empty: true} + +func (r *TargetAssociatedEntitiesAnthosClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesAnthosClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesAnthosClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + // Describe returns a simple description of this resource to ensure that automated tools // can identify it. func (r *Target) Describe() dcl.ServiceTypeVersion { @@ -391,25 +539,26 @@ func (r *Target) ID() (string, error) { } nr := r.urlNormalized() params := map[string]interface{}{ - "name": dcl.ValueOrEmptyString(nr.Name), - "target_id": dcl.ValueOrEmptyString(nr.TargetId), - "uid": dcl.ValueOrEmptyString(nr.Uid), - "description": dcl.ValueOrEmptyString(nr.Description), - "annotations": dcl.ValueOrEmptyString(nr.Annotations), - "labels": dcl.ValueOrEmptyString(nr.Labels), - "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), - "create_time": dcl.ValueOrEmptyString(nr.CreateTime), - "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), - "gke": dcl.ValueOrEmptyString(nr.Gke), - "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), - "etag": dcl.ValueOrEmptyString(nr.Etag), - "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "run": dcl.ValueOrEmptyString(nr.Run), - "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), - "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), - "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "name": dcl.ValueOrEmptyString(nr.Name), + "target_id": dcl.ValueOrEmptyString(nr.TargetId), + "uid": dcl.ValueOrEmptyString(nr.Uid), + "description": dcl.ValueOrEmptyString(nr.Description), + "annotations": dcl.ValueOrEmptyString(nr.Annotations), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "gke": dcl.ValueOrEmptyString(nr.Gke), + "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), + "etag": dcl.ValueOrEmptyString(nr.Etag), + "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "run": dcl.ValueOrEmptyString(nr.Run), + "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), + "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), + "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "associated_entities": dcl.ValueOrEmptyString(nr.AssociatedEntities), } return dcl.Nprintf("projects/{{project}}/locations/{{location}}/targets/{{name}}", params), nil } diff --git a/services/google/clouddeploy/alpha/target.yaml b/services/google/clouddeploy/alpha/target.yaml index a408c1642..6a30937ad 100755 --- a/services/google/clouddeploy/alpha/target.yaml +++ b/services/google/clouddeploy/alpha/target.yaml @@ -104,6 +104,75 @@ components: x-dcl-references: - resource: Gkehub/Membership field: selfLink + associatedEntities: + type: object + additionalProperties: + type: object + x-dcl-go-type: TargetAssociatedEntities + properties: + anthosClusters: + type: array + x-dcl-go-name: AnthosClusters + description: Optional. Information specifying Anthos clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters + properties: + membership: + type: string + x-dcl-go-name: Membership + description: Optional. Membership of the GKE Hub-registered + cluster to which to apply the Skaffold configuration. Format + is `projects/{project}/locations/{location}/memberships/{membership_name}`. + x-dcl-references: + - resource: Gkehub/Membership + field: selfLink + gkeClusters: + type: array + x-dcl-go-name: GkeClusters + description: Optional. Information specifying GKE clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesGkeClusters + properties: + cluster: + type: string + x-dcl-go-name: Cluster + description: Optional. Information specifying a GKE Cluster. + Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`. + x-dcl-references: + - resource: Container/Cluster + field: selfLink + internalIP: + type: boolean + x-dcl-go-name: InternalIP + description: Optional. If true, `cluster` is accessed using + the private IP address of the control plane endpoint. Otherwise, + the default IP address of the control plane endpoint is used. + The default IP address is the private IP address for clusters + with private control-plane endpoints and the public IP address + otherwise. Only specify this option when `cluster` is a [private + GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept). + proxyUrl: + type: string + x-dcl-go-name: ProxyUrl + description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) + to the Kubernetes server. + x-dcl-go-name: AssociatedEntities + description: 'Optional. Map of entity IDs to their associated entities. + Associated entities allows specifying places other than the deployment + target for specific features. For example, the Gateway API canary can + be configured to deploy the HTTPRoute to a different cluster(s) than the + deployment cluster using associated entities. An entity ID must consist + of lower-case letters, numbers, and hyphens, start with a letter and end + with a letter or a number, and have a max length of 63 characters. In + other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.' createTime: type: string format: date-time diff --git a/services/google/clouddeploy/alpha/target_alpha_yaml_embed.go b/services/google/clouddeploy/alpha/target_alpha_yaml_embed.go index d617940ca..626faea2e 100755 --- a/services/google/clouddeploy/alpha/target_alpha_yaml_embed.go +++ b/services/google/clouddeploy/alpha/target_alpha_yaml_embed.go @@ -17,7 +17,7 @@ package alpha // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/alpha/target.yaml -var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") +var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n associatedEntities:\n type: object\n additionalProperties:\n type: object\n x-dcl-go-type: TargetAssociatedEntities\n properties:\n anthosClusters:\n type: array\n x-dcl-go-name: AnthosClusters\n description: Optional. Information specifying Anthos clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Optional. Membership of the GKE Hub-registered\n cluster to which to apply the Skaffold configuration. Format\n is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n gkeClusters:\n type: array\n x-dcl-go-name: GkeClusters\n description: Optional. Information specifying GKE clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesGkeClusters\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Optional. Information specifying a GKE Cluster.\n Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using\n the private IP address of the control plane endpoint. Otherwise,\n the default IP address of the control plane endpoint is used.\n The default IP address is the private IP address for clusters\n with private control-plane endpoints and the public IP address\n otherwise. Only specify this option when `cluster` is a [private\n GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n x-dcl-go-name: AssociatedEntities\n description: 'Optional. Map of entity IDs to their associated entities.\n Associated entities allows specifying places other than the deployment\n target for specific features. For example, the Gateway API canary can\n be configured to deploy the HTTPRoute to a different cluster(s) than the\n deployment cluster using associated entities. An entity ID must consist\n of lower-case letters, numbers, and hyphens, start with a letter and end\n with a letter or a number, and have a max length of 63 characters. In\n other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") -// 13256 bytes -// MD5: 6af2eccf69e0aafa0d3498bc876d8a28 +// 17100 bytes +// MD5: 7db60317a50bbd142f17a887065f11f0 diff --git a/services/google/clouddeploy/alpha/target_internal.go b/services/google/clouddeploy/alpha/target_internal.go index 9aec4d745..ae03ef108 100755 --- a/services/google/clouddeploy/alpha/target_internal.go +++ b/services/google/clouddeploy/alpha/target_internal.go @@ -99,6 +99,15 @@ func (r *TargetCustomTarget) validate() error { } return nil } +func (r *TargetAssociatedEntities) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesGkeClusters) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesAnthosClusters) validate() error { + return nil +} func (r *Target) basePath() string { params := map[string]interface{}{} return dcl.Nprintf("https://clouddeploy.googleapis.com/v1/", params) @@ -224,6 +233,11 @@ func newUpdateTargetUpdateTargetRequest(ctx context.Context, f *Target, c *Clien } else if !dcl.IsEmptyValueIndirect(v) { req["customTarget"] = v } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["associatedEntities"] = v + } b, err := c.getTargetRaw(ctx, f) if err != nil { return nil, err @@ -665,6 +679,12 @@ func canonicalizeTargetDesiredState(rawDesired, rawInitial *Target, opts ...dcl. canonicalDesired.DeployParameters = rawDesired.DeployParameters } canonicalDesired.CustomTarget = canonicalizeTargetCustomTarget(rawDesired.CustomTarget, rawInitial.CustomTarget, opts...) + if dcl.IsZeroValue(rawDesired.AssociatedEntities) || (dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawInitial.AssociatedEntities)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.AssociatedEntities = rawInitial.AssociatedEntities + } else { + canonicalDesired.AssociatedEntities = rawDesired.AssociatedEntities + } if canonicalDesired.Gke != nil { // Check if anything else is set. @@ -813,6 +833,11 @@ func canonicalizeTargetNewState(c *Client, rawNew, rawDesired *Target) (*Target, rawNew.CustomTarget = canonicalizeNewTargetCustomTarget(c, rawDesired.CustomTarget, rawNew.CustomTarget) } + if dcl.IsEmptyValueIndirect(rawNew.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) { + rawNew.AssociatedEntities = rawDesired.AssociatedEntities + } else { + } + return rawNew, nil } @@ -1568,328 +1593,696 @@ func canonicalizeNewTargetCustomTargetSlice(c *Client, des, nw []TargetCustomTar return items } -// The differ returns a list of diffs, along with a list of operations that should be taken -// to remedy them. Right now, it does not attempt to consolidate operations - if several -// fields can be fixed with a patch update, it will perform the patch several times. -// Diffs on some fields will be ignored if the `desired` state has an empty (nil) -// value. This empty value indicates that the user does not care about the state for -// the field. Empty fields on the actual object will cause diffs. -// TODO(magic-modules-eng): for efficiency in some resources, add batching. -func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { - if desired == nil || actual == nil { - return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) +func canonicalizeTargetAssociatedEntities(des, initial *TargetAssociatedEntities, opts ...dcl.ApplyOption) *TargetAssociatedEntities { + if des == nil { + return initial } - - c.Config.Logger.Infof("Diff function called with desired state: %v", desired) - c.Config.Logger.Infof("Diff function called with actual state: %v", actual) - - var fn dcl.FieldName - var newDiffs []*dcl.FieldDiff - // New style diffs. - if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if des.empty { + return des } - if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) - } + cDes := &TargetAssociatedEntities{} - if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes.GkeClusters = canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des.GkeClusters, initial.GkeClusters, opts...) + cDes.AnthosClusters = canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des.AnthosClusters, initial.AnthosClusters, opts...) + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesSlice(des, initial []TargetAssociatedEntities, opts ...dcl.ApplyOption) []TargetAssociatedEntities { + if dcl.IsEmptyValueIndirect(des) { + return initial } - if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntities, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntities, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) +} + +func canonicalizeNewTargetAssociatedEntities(c *Client, des, nw *TargetAssociatedEntities) *TargetAssociatedEntities { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntities while comparing non-nil desired to nil actual. Returning desired object.") + return des } - newDiffs = append(newDiffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + nw.GkeClusters = canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c, des.GkeClusters, nw.GkeClusters) + nw.AnthosClusters = canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c, des.AnthosClusters, nw.AnthosClusters) + + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesSet(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntities + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - newDiffs = append(newDiffs, ds...) } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) - if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeNewTargetAssociatedEntitiesSlice(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw } - if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + var items []TargetAssociatedEntities + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &n)) } - if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeTargetAssociatedEntitiesGkeClusters(des, initial *TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial + } + if des.empty { + return des } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes := &TargetAssociatedEntitiesGkeClusters{} + + if dcl.IsZeroValue(des.Cluster) || (dcl.IsEmptyValueIndirect(des.Cluster) && dcl.IsEmptyValueIndirect(initial.Cluster)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Cluster = initial.Cluster + } else { + cDes.Cluster = des.Cluster + } + if dcl.BoolCanonicalize(des.InternalIP, initial.InternalIP) || dcl.IsZeroValue(des.InternalIP) { + cDes.InternalIP = initial.InternalIP + } else { + cDes.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, initial.ProxyUrl) || dcl.IsZeroValue(des.ProxyUrl) { + cDes.ProxyUrl = initial.ProxyUrl + } else { + cDes.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return cDes +} + +func canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des, initial []TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial } - if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if len(newDiffs) > 0 { - c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) - } - return newDiffs, nil } -func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff - desired, ok := d.(*TargetGke) - if !ok { - desiredNotPointer, ok := d.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) - } - desired = &desiredNotPointer - } - actual, ok := a.(*TargetGke) - if !ok { - actualNotPointer, ok := a.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke", a) - } - actual = &actualNotPointer +func canonicalizeNewTargetAssociatedEntitiesGkeClusters(c *Client, des, nw *TargetAssociatedEntitiesGkeClusters) *TargetAssociatedEntitiesGkeClusters { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesGkeClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - diffs = append(diffs, ds...) + if dcl.BoolCanonicalize(des.InternalIP, nw.InternalIP) { + nw.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, nw.ProxyUrl) { + nw.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSet(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesGkeClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesGkeClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - diffs = append(diffs, ds...) } - return diffs, nil + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items } -func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetAnthosCluster) - if !ok { - desiredNotPointer, ok := d.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesGkeClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &n)) + } + + return items +} + +func canonicalizeTargetAssociatedEntitiesAnthosClusters(des, initial *TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &TargetAssociatedEntitiesAnthosClusters{} + + if dcl.IsZeroValue(des.Membership) || (dcl.IsEmptyValueIndirect(des.Membership) && dcl.IsEmptyValueIndirect(initial.Membership)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Membership = initial.Membership + } else { + cDes.Membership = des.Membership + } + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des, initial []TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - desired = &desiredNotPointer + return items } - actual, ok := a.(*TargetAnthosCluster) - if !ok { - actualNotPointer, ok := a.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - actual = &actualNotPointer } + return items - if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c *Client, des, nw *TargetAssociatedEntitiesAnthosClusters) *TargetAssociatedEntitiesAnthosClusters { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesAnthosClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - return diffs, nil + + return nw } -func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSet(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetExecutionConfigs) - if !ok { - desiredNotPointer, ok := d.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesAnthosClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesAnthosClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - desired = &desiredNotPointer } - actual, ok := a.(*TargetExecutionConfigs) - if !ok { - actualNotPointer, ok := a.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesAnthosClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } - desired, ok := d.(*TargetRun) - if !ok { - desiredNotPointer, ok := d.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - desired = &desiredNotPointer + newDiffs = append(newDiffs, ds...) } - actual, ok := a.(*TargetRun) - if !ok { - actualNotPointer, ok := a.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun", a) + + if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.AssociatedEntities, actual.AssociatedEntities, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesNewStyle, EmptyObject: EmptyTargetAssociatedEntities, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AssociatedEntities")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetGke) + if !ok { + desiredNotPointer, ok := d.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetGke) + if !ok { + actualNotPointer, ok := a.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAnthosCluster) + if !ok { + desiredNotPointer, ok := d.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAnthosCluster) + if !ok { + actualNotPointer, ok := a.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetExecutionConfigs) + if !ok { + desiredNotPointer, ok := d.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetExecutionConfigs) + if !ok { + actualNotPointer, ok := a.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetRun) + if !ok { + desiredNotPointer, ok := d.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetRun) + if !ok { + actualNotPointer, ok := a.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { var diffs []*dcl.FieldDiff desired, ok := d.(*TargetMultiTarget) @@ -1938,189 +2331,673 @@ func compareTargetCustomTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*d actual = &actualNotPointer } - if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntities) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities or *TargetAssociatedEntities", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntities) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.GkeClusters, actual.GkeClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesGkeClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesGkeClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("GkeClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AnthosClusters, actual.AnthosClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesAnthosClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesAnthosClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesGkeClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters or *TargetAssociatedEntitiesGkeClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesAnthosClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters or *TargetAssociatedEntitiesAnthosClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Target) urlNormalized() *Target { + normalized := dcl.Copy(*r).(Target) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.TargetId = dcl.SelfLinkToName(r.TargetId) + normalized.Uid = dcl.SelfLinkToName(r.Uid) + normalized.Description = dcl.SelfLinkToName(r.Description) + normalized.Etag = dcl.SelfLinkToName(r.Etag) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *Target) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateTarget" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Target resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Target) marshal(c *Client) ([]byte, error) { + m, err := expandTarget(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Target: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalTarget decodes JSON responses into the Target resource schema. +func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapTarget(m, c, res) +} + +func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + + flattened := flattenTarget(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandTarget expands Target into a JSON request object. +func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.Description; dcl.ValueShouldBeSent(v) { + m["description"] = v + } + if v := f.Annotations; dcl.ValueShouldBeSent(v) { + m["annotations"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { + m["requireApproval"] = v + } + if v, err := expandTargetGke(c, f.Gke, res); err != nil { + return nil, fmt.Errorf("error expanding Gke into gke: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["gke"] = v + } + if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["anthosCluster"] = v + } + if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { + return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) + } else if v != nil { + m["executionConfigs"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := expandTargetRun(c, f.Run, res); err != nil { + return nil, fmt.Errorf("error expanding Run into run: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["run"] = v + } + if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { + return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["multiTarget"] = v + } + if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { + m["deployParameters"] = v + } + if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { + return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["customTarget"] = v + } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["associatedEntities"] = v + } + + return m, nil +} + +// flattenTarget flattens Target from a JSON request object into the +// Target type. +func flattenTarget(c *Client, i interface{}, res *Target) *Target { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Target{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.TargetId = dcl.FlattenString(m["targetId"]) + resultRes.Uid = dcl.FlattenString(m["uid"]) + resultRes.Description = dcl.FlattenString(m["description"]) + resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Gke = flattenTargetGke(c, m["gke"], res) + resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) + resultRes.Etag = dcl.FlattenString(m["etag"]) + resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.Run = flattenTargetRun(c, m["run"], res) + resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) + resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) + resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + resultRes.AssociatedEntities = flattenTargetAssociatedEntitiesMap(c, m["associatedEntities"], res) + + return resultRes +} + +// expandTargetGkeMap expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetGke{} + } + + if len(a) == 0 { + return map[string]TargetGke{} + } + + items := make(map[string]TargetGke) + for k, item := range a { + items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { + a, ok := i.([]interface{}) + if !ok { + return []TargetGke{} + } + + if len(a) == 0 { + return []TargetGke{} + } + + items := make([]TargetGke, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetGke expands an instance of TargetGke into a JSON +// request object. +func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v + } + + return m, nil +} + +// flattenTargetGke flattens an instance of TargetGke from a JSON +// response object. +func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetGke{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetGke + } + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + + return r +} + +// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetAnthosCluster{} + } + + if len(a) == 0 { + return map[string]TargetAnthosCluster{} + } + + items := make(map[string]TargetAnthosCluster) + for k, item := range a { + items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { + a, ok := i.([]interface{}) + if !ok { + return []TargetAnthosCluster{} + } + + if len(a) == 0 { + return []TargetAnthosCluster{} + } + + items := make([]TargetAnthosCluster, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v + } + + return m, nil +} + +// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetAnthosCluster{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetAnthosCluster + } + r.Membership = dcl.FlattenString(m["membership"]) + + return r +} + +// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) if err != nil { return nil, err } - diffs = append(diffs, ds...) + + items = append(items, i) } - return diffs, nil -} -// urlNormalized returns a copy of the resource struct with values normalized -// for URL substitutions. For instance, it converts long-form self-links to -// short-form so they can be substituted in. -func (r *Target) urlNormalized() *Target { - normalized := dcl.Copy(*r).(Target) - normalized.Name = dcl.SelfLinkToName(r.Name) - normalized.TargetId = dcl.SelfLinkToName(r.TargetId) - normalized.Uid = dcl.SelfLinkToName(r.Uid) - normalized.Description = dcl.SelfLinkToName(r.Description) - normalized.Etag = dcl.SelfLinkToName(r.Etag) - normalized.Project = dcl.SelfLinkToName(r.Project) - normalized.Location = dcl.SelfLinkToName(r.Location) - return &normalized + return items, nil } -func (r *Target) updateURL(userBasePath, updateName string) (string, error) { - nr := r.urlNormalized() - if updateName == "UpdateTarget" { - fields := map[string]interface{}{ - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "name": dcl.ValueOrEmptyString(nr.Name), - } - return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil - +// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetExecutionConfigs{} } - return "", fmt.Errorf("unknown update name: %s", updateName) -} + if len(a) == 0 { + return map[string]TargetExecutionConfigs{} + } -// marshal encodes the Target resource into JSON for a Create request, and -// performs transformations from the resource schema to the API schema if -// necessary. -func (r *Target) marshal(c *Client) ([]byte, error) { - m, err := expandTarget(c, r) - if err != nil { - return nil, fmt.Errorf("error marshalling Target: %w", err) + items := make(map[string]TargetExecutionConfigs) + for k, item := range a { + items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) } - return json.Marshal(m) + return items } -// unmarshalTarget decodes JSON responses into the Target resource schema. -func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { - var m map[string]interface{} - if err := json.Unmarshal(b, &m); err != nil { - return nil, err +// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { + a, ok := i.([]interface{}) + if !ok { + return []TargetExecutionConfigs{} } - return unmarshalMapTarget(m, c, res) -} -func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + if len(a) == 0 { + return []TargetExecutionConfigs{} + } - flattened := flattenTarget(c, m, res) - if flattened == nil { - return nil, fmt.Errorf("attempted to flatten empty json object") + items := make([]TargetExecutionConfigs, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) } - return flattened, nil + + return items } -// expandTarget expands Target into a JSON request object. -func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { - m := make(map[string]interface{}) - res := f - _ = res - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Name into name: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["name"] = v - } - if v := f.Description; dcl.ValueShouldBeSent(v) { - m["description"] = v - } - if v := f.Annotations; dcl.ValueShouldBeSent(v) { - m["annotations"] = v - } - if v := f.Labels; dcl.ValueShouldBeSent(v) { - m["labels"] = v - } - if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { - m["requireApproval"] = v - } - if v, err := expandTargetGke(c, f.Gke, res); err != nil { - return nil, fmt.Errorf("error expanding Gke into gke: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["gke"] = v - } - if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { - return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["anthosCluster"] = v - } - if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { - return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) - } else if v != nil { - m["executionConfigs"] = v +// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Project into project: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["project"] = v + + m := make(map[string]interface{}) + if v := f.Usages; v != nil { + m["usages"] = v } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Location into location: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { + m["workerPool"] = v } - if v, err := expandTargetRun(c, f.Run, res); err != nil { - return nil, fmt.Errorf("error expanding Run into run: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["run"] = v + if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { + m["serviceAccount"] = v } - if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { - return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["multiTarget"] = v + if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { + m["artifactStorage"] = v } - if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { - m["deployParameters"] = v + if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { + m["executionTimeout"] = v } - if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { - return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["customTarget"] = v + if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { + m["verbose"] = v } return m, nil } -// flattenTarget flattens Target from a JSON request object into the -// Target type. -func flattenTarget(c *Client, i interface{}, res *Target) *Target { +// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { m, ok := i.(map[string]interface{}) if !ok { return nil } - if len(m) == 0 { - return nil - } - resultRes := &Target{} - resultRes.Name = dcl.FlattenString(m["name"]) - resultRes.TargetId = dcl.FlattenString(m["targetId"]) - resultRes.Uid = dcl.FlattenString(m["uid"]) - resultRes.Description = dcl.FlattenString(m["description"]) - resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) - resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) - resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) - resultRes.CreateTime = dcl.FlattenString(m["createTime"]) - resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) - resultRes.Gke = flattenTargetGke(c, m["gke"], res) - resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) - resultRes.Etag = dcl.FlattenString(m["etag"]) - resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) - resultRes.Project = dcl.FlattenString(m["project"]) - resultRes.Location = dcl.FlattenString(m["location"]) - resultRes.Run = flattenTargetRun(c, m["run"], res) - resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) - resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) - resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + r := &TargetExecutionConfigs{} - return resultRes + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetExecutionConfigs + } + r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) + r.WorkerPool = dcl.FlattenString(m["workerPool"]) + r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) + r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) + r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) + r.Verbose = dcl.FlattenBool(m["verbose"]) + + return r } -// expandTargetGkeMap expands the contents of TargetGke into a JSON +// expandTargetRunMap expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2132,16 +3009,16 @@ func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[str return items, nil } -// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// expandTargetRunSlice expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { +func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2152,97 +3029,89 @@ func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]i return items, nil } -// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// flattenTargetRunMap flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { +func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetGke{} + return map[string]TargetRun{} } if len(a) == 0 { - return map[string]TargetGke{} + return map[string]TargetRun{} } - items := make(map[string]TargetGke) + items := make(map[string]TargetRun) for k, item := range a { - items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) } return items } -// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// flattenTargetRunSlice flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { +func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { a, ok := i.([]interface{}) if !ok { - return []TargetGke{} + return []TargetRun{} } if len(a) == 0 { - return []TargetGke{} + return []TargetRun{} } - items := make([]TargetGke, 0, len(a)) + items := make([]TargetRun, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) } return items } -// expandTargetGke expands an instance of TargetGke into a JSON +// expandTargetRun expands an instance of TargetRun into a JSON // request object. -func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { - m["cluster"] = v - } - if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { - m["internalIp"] = v - } - if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { - m["proxyUrl"] = v + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v } return m, nil } -// flattenTargetGke flattens an instance of TargetGke from a JSON +// flattenTargetRun flattens an instance of TargetRun from a JSON // response object. -func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { +func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetGke{} + r := &TargetRun{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetGke + return EmptyTargetRun } - r.Cluster = dcl.FlattenString(m["cluster"]) - r.InternalIP = dcl.FlattenBool(m["internalIp"]) - r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + r.Location = dcl.FlattenString(m["location"]) return r } -// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2254,16 +3123,16 @@ func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, r return items, nil } -// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { +func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2274,89 +3143,89 @@ func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Tar return items, nil } -// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { +func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } if len(a) == 0 { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } - items := make(map[string]TargetAnthosCluster) + items := make(map[string]TargetMultiTarget) for k, item := range a { - items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { +func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { a, ok := i.([]interface{}) if !ok { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } if len(a) == 0 { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } - items := make([]TargetAnthosCluster, 0, len(a)) + items := make([]TargetMultiTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { - m["membership"] = v + if v := f.TargetIds; v != nil { + m["targetIds"] = v } return m, nil } -// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { +func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetAnthosCluster{} + r := &TargetMultiTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetAnthosCluster + return EmptyTargetMultiTarget } - r.Membership = dcl.FlattenString(m["membership"]) + r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) return r } -// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { +func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2368,16 +3237,16 @@ func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConf return items, nil } -// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { +func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2388,109 +3257,89 @@ func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, re return items, nil } -// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { +func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } if len(a) == 0 { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } - items := make(map[string]TargetExecutionConfigs) + items := make(map[string]TargetCustomTarget) for k, item := range a { - items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { +func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { a, ok := i.([]interface{}) if !ok { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } if len(a) == 0 { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } - items := make([]TargetExecutionConfigs, 0, len(a)) + items := make([]TargetCustomTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { - if f == nil { +func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Usages; v != nil { - m["usages"] = v - } - if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { - m["workerPool"] = v - } - if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { - m["serviceAccount"] = v - } - if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { - m["artifactStorage"] = v - } - if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { - m["executionTimeout"] = v - } - if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { - m["verbose"] = v + if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { + m["customTargetType"] = v } return m, nil } -// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { +func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetExecutionConfigs{} + r := &TargetCustomTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetExecutionConfigs + return EmptyTargetCustomTarget } - r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) - r.WorkerPool = dcl.FlattenString(m["workerPool"]) - r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) - r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) - r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) - r.Verbose = dcl.FlattenBool(m["verbose"]) + r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) return r } -// expandTargetRunMap expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesMap expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesMap(c *Client, f map[string]TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2502,16 +3351,16 @@ func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[str return items, nil } -// expandTargetRunSlice expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesSlice expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesSlice(c *Client, f []TargetAssociatedEntities, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2522,89 +3371,97 @@ func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]i return items, nil } -// flattenTargetRunMap flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesMap flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { +func flattenTargetAssociatedEntitiesMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntities { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } if len(a) == 0 { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } - items := make(map[string]TargetRun) + items := make(map[string]TargetAssociatedEntities) for k, item := range a { - items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res) } return items } -// flattenTargetRunSlice flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesSlice flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { +func flattenTargetAssociatedEntitiesSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntities { a, ok := i.([]interface{}) if !ok { - return []TargetRun{} + return []TargetAssociatedEntities{} } if len(a) == 0 { - return []TargetRun{} + return []TargetAssociatedEntities{} } - items := make([]TargetRun, 0, len(a)) + items := make([]TargetAssociatedEntities, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res)) } return items } -// expandTargetRun expands an instance of TargetRun into a JSON +// expandTargetAssociatedEntities expands an instance of TargetAssociatedEntities into a JSON // request object. -func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntities(c *Client, f *TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Location; !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v, err := expandTargetAssociatedEntitiesGkeClustersSlice(c, f.GkeClusters, res); err != nil { + return nil, fmt.Errorf("error expanding GkeClusters into gkeClusters: %w", err) + } else if v != nil { + m["gkeClusters"] = v + } + if v, err := expandTargetAssociatedEntitiesAnthosClustersSlice(c, f.AnthosClusters, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosClusters into anthosClusters: %w", err) + } else if v != nil { + m["anthosClusters"] = v } return m, nil } -// flattenTargetRun flattens an instance of TargetRun from a JSON +// flattenTargetAssociatedEntities flattens an instance of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { +func flattenTargetAssociatedEntities(c *Client, i interface{}, res *Target) *TargetAssociatedEntities { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetRun{} + r := &TargetAssociatedEntities{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetRun + return EmptyTargetAssociatedEntities } - r.Location = dcl.FlattenString(m["location"]) + r.GkeClusters = flattenTargetAssociatedEntitiesGkeClustersSlice(c, m["gkeClusters"], res) + r.AnthosClusters = flattenTargetAssociatedEntitiesAnthosClustersSlice(c, m["anthosClusters"], res) return r } -// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersMap expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersMap(c *Client, f map[string]TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2616,16 +3473,16 @@ func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res * return items, nil } -// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersSlice expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersSlice(c *Client, f []TargetAssociatedEntitiesGkeClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2636,89 +3493,97 @@ func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) return items, nil } -// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersMap flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesGkeClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } - items := make(map[string]TargetMultiTarget) + items := make(map[string]TargetAssociatedEntitiesGkeClusters) for k, item := range a { - items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersSlice flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesGkeClusters { a, ok := i.([]interface{}) if !ok { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } - items := make([]TargetMultiTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClusters expands an instance of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesGkeClusters(c *Client, f *TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.TargetIds; v != nil { - m["targetIds"] = v + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v } return m, nil } -// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClusters flattens an instance of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesGkeClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetMultiTarget{} + r := &TargetAssociatedEntitiesGkeClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetMultiTarget + return EmptyTargetAssociatedEntitiesGkeClusters } - r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) return r } -// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersMap expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersMap(c *Client, f map[string]TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2730,16 +3595,16 @@ func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res return items, nil } -// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersSlice expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersSlice(c *Client, f []TargetAssociatedEntitiesAnthosClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2750,75 +3615,75 @@ func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Targe return items, nil } -// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersMap flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesAnthosClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } - items := make(map[string]TargetCustomTarget) + items := make(map[string]TargetAssociatedEntitiesAnthosClusters) for k, item := range a { - items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersSlice flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesAnthosClusters { a, ok := i.([]interface{}) if !ok { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } - items := make([]TargetCustomTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClusters expands an instance of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesAnthosClusters(c *Client, f *TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { - m["customTargetType"] = v + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v } return m, nil } -// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClusters flattens an instance of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesAnthosClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetCustomTarget{} + r := &TargetAssociatedEntitiesAnthosClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetCustomTarget + return EmptyTargetAssociatedEntitiesAnthosClusters } - r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) + r.Membership = dcl.FlattenString(m["membership"]) return r } @@ -3043,6 +3908,15 @@ func extractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) error { func extractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func extractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func extractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func extractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} func postReadExtractTargetFields(r *Target) error { vGke := r.Gke @@ -3120,3 +3994,12 @@ func postReadExtractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) err func postReadExtractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func postReadExtractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} diff --git a/services/google/clouddeploy/alpha/target_schema.go b/services/google/clouddeploy/alpha/target_schema.go index 030f8929e..fa1ab6bb8 100755 --- a/services/google/clouddeploy/alpha/target_schema.go +++ b/services/google/clouddeploy/alpha/target_schema.go @@ -146,6 +146,75 @@ func DCLTargetSchema() *dcl.Schema { }, }, }, + "associatedEntities": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntities", + Properties: map[string]*dcl.Property{ + "anthosClusters": &dcl.Property{ + Type: "array", + GoName: "AnthosClusters", + Description: "Optional. Information specifying Anthos clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesAnthosClusters", + Properties: map[string]*dcl.Property{ + "membership": &dcl.Property{ + Type: "string", + GoName: "Membership", + Description: "Optional. Membership of the GKE Hub-registered cluster to which to apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Gkehub/Membership", + Field: "selfLink", + }, + }, + }, + }, + }, + }, + "gkeClusters": &dcl.Property{ + Type: "array", + GoName: "GkeClusters", + Description: "Optional. Information specifying GKE clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesGkeClusters", + Properties: map[string]*dcl.Property{ + "cluster": &dcl.Property{ + Type: "string", + GoName: "Cluster", + Description: "Optional. Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Container/Cluster", + Field: "selfLink", + }, + }, + }, + "internalIP": &dcl.Property{ + Type: "boolean", + GoName: "InternalIP", + Description: "Optional. If true, `cluster` is accessed using the private IP address of the control plane endpoint. Otherwise, the default IP address of the control plane endpoint is used. The default IP address is the private IP address for clusters with private control-plane endpoints and the public IP address otherwise. Only specify this option when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).", + }, + "proxyUrl": &dcl.Property{ + Type: "string", + GoName: "ProxyUrl", + Description: "Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) to the Kubernetes server.", + }, + }, + }, + }, + }, + }, + GoName: "AssociatedEntities", + Description: "Optional. Map of entity IDs to their associated entities. Associated entities allows specifying places other than the deployment target for specific features. For example, the Gateway API canary can be configured to deploy the HTTPRoute to a different cluster(s) than the deployment cluster using associated entities. An entity ID must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.", + }, "createTime": &dcl.Property{ Type: "string", Format: "date-time", diff --git a/services/google/clouddeploy/beta/delivery_pipeline.go b/services/google/clouddeploy/beta/delivery_pipeline.go index 3789b12f6..fff224dae 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline.go +++ b/services/google/clouddeploy/beta/delivery_pipeline.go @@ -490,13 +490,14 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet } type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh struct { - empty bool `json:"-"` - HttpRoute *string `json:"httpRoute"` - Service *string `json:"service"` - Deployment *string `json:"deployment"` - RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` - StableCutbackDuration *string `json:"stableCutbackDuration"` - PodSelectorLabel *string `json:"podSelectorLabel"` + empty bool `json:"-"` + HttpRoute *string `json:"httpRoute"` + Service *string `json:"service"` + Deployment *string `json:"deployment"` + RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` + StableCutbackDuration *string `json:"stableCutbackDuration"` + PodSelectorLabel *string `json:"podSelectorLabel"` + RouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations `json:"routeDestinations"` } type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh @@ -526,6 +527,8 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet r.PodSelectorLabel = res.PodSelectorLabel + r.RouteDestinations = res.RouteDestinations + } return nil } @@ -550,6 +553,55 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet return fmt.Sprintf("%x", hash) } +type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations struct { + empty bool `json:"-"` + DestinationIds []string `json:"destinationIds"` + PropagateService *bool `json:"propagateService"` +} + +type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) UnmarshalJSON(data []byte) error { + var res jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } else { + + r.DestinationIds = res.DestinationIds + + r.PropagateService = res.PropagateService + + } + return nil +} + +// This object is used to assert a desired state where this DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{empty: true} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) Empty() bool { + return r.empty +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) String() string { + return dcl.SprintResource(r) +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking struct { empty bool `json:"-"` Service *string `json:"service"` diff --git a/services/google/clouddeploy/beta/delivery_pipeline.yaml b/services/google/clouddeploy/beta/delivery_pipeline.yaml index 23c63a403..2773a9053 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline.yaml +++ b/services/google/clouddeploy/beta/delivery_pipeline.yaml @@ -544,6 +544,47 @@ components: selecting Pods for the Deployment and Service resources. This label must already be present in both resources. + routeDestinations: + type: object + x-dcl-go-name: RouteDestinations + x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + description: Optional. Route destinations + allow configuring the Gateway API HTTPRoute + to be deployed to additional clusters. This + option is available for multi-cluster service + mesh set ups that require the route to exist + in the clusters that call the service. If + unspecified, the HTTPRoute will only be + deployed to the Target cluster. + required: + - destinationIds + properties: + destinationIds: + type: array + x-dcl-go-name: DestinationIds + description: Required. The clusters where + the Gateway API HTTPRoute resource will + be deployed to. Valid entries include + the associated entities IDs configured + in the Target resource and "@self" to + include the Target cluster. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + propagateService: + type: boolean + x-dcl-go-name: PropagateService + description: Optional. Whether to propagate + the Kubernetes Service to the route + destination clusters. The Service will + always be deployed to the Target cluster + even if the HTTPRoute is not. This option + may be used to facilitiate successful + DNS lookup in the route destination + clusters. Can only be set to true if + destinations are specified. routeUpdateWaitTime: type: string x-dcl-go-name: RouteUpdateWaitTime diff --git a/services/google/clouddeploy/beta/delivery_pipeline_beta_yaml_embed.go b/services/google/clouddeploy/beta/delivery_pipeline_beta_yaml_embed.go index 1cf90daea..e969df7f1 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline_beta_yaml_embed.go +++ b/services/google/clouddeploy/beta/delivery_pipeline_beta_yaml_embed.go @@ -17,7 +17,7 @@ package beta // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/beta/delivery_pipeline.yaml -var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") +var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeDestinations:\n type: object\n x-dcl-go-name: RouteDestinations\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations\n description: Optional. Route destinations\n allow configuring the Gateway API HTTPRoute\n to be deployed to additional clusters. This\n option is available for multi-cluster service\n mesh set ups that require the route to exist\n in the clusters that call the service. If\n unspecified, the HTTPRoute will only be\n deployed to the Target cluster.\n required:\n - destinationIds\n properties:\n destinationIds:\n type: array\n x-dcl-go-name: DestinationIds\n description: Required. The clusters where\n the Gateway API HTTPRoute resource will\n be deployed to. Valid entries include\n the associated entities IDs configured\n in the Target resource and \"@self\" to\n include the Target cluster.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n propagateService:\n type: boolean\n x-dcl-go-name: PropagateService\n description: Optional. Whether to propagate\n the Kubernetes Service to the route\n destination clusters. The Service will\n always be deployed to the Target cluster\n even if the HTTPRoute is not. This option\n may be used to facilitiate successful\n DNS lookup in the route destination\n clusters. Can only be set to true if\n destinations are specified.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") -// 36151 bytes -// MD5: ff459f48fb76c99e0104adec32956cb6 +// 39271 bytes +// MD5: fb938761986f76f4a57bb5452ac3b884 diff --git a/services/google/clouddeploy/beta/delivery_pipeline_internal.go b/services/google/clouddeploy/beta/delivery_pipeline_internal.go index 9fdfa738f..cbcd4e483 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/beta/delivery_pipeline_internal.go @@ -154,6 +154,17 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet if err := dcl.Required(r, "deployment"); err != nil { return err } + if !dcl.IsEmptyValueIndirect(r.RouteDestinations) { + if err := r.RouteDestinations.validate(); err != nil { + return err + } + } + return nil +} +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) validate() error { + if err := dcl.Required(r, "destinationIds"); err != nil { + return err + } return nil } func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) validate() error { @@ -1992,6 +2003,7 @@ func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig } else { cDes.PodSelectorLabel = des.PodSelectorLabel } + cDes.RouteDestinations = canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des.RouteDestinations, initial.RouteDestinations, opts...) return cDes } @@ -2056,6 +2068,7 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon if dcl.StringCanonicalize(des.PodSelectorLabel, nw.PodSelectorLabel) { nw.PodSelectorLabel = des.PodSelectorLabel } + nw.RouteDestinations = canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, des.RouteDestinations, nw.RouteDestinations) return nw } @@ -2106,6 +2119,132 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return items } +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.StringArrayCanonicalize(des.DestinationIds, initial.DestinationIds) { + cDes.DestinationIds = initial.DestinationIds + } else { + cDes.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, initial.PropagateService) || dcl.IsZeroValue(des.PropagateService) { + cDes.PropagateService = initial.PropagateService + } else { + cDes.PropagateService = des.PropagateService + } + + return cDes +} + +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(des, initial []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for _, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for i, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, des, nw *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DestinationIds, nw.DestinationIds) { + nw.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, nw.PropagateService) { + nw.PropagateService = des.PropagateService + } + + return nw +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSet(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &n)) + } + + return items +} + func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { if des == nil { return initial @@ -4371,6 +4510,49 @@ func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber } diffs = append(diffs, ds...) } + + if ds, err := dcl.Diff(desired.RouteDestinations, actual.RouteDestinations, dcl.DiffInfo{ObjectFunction: compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle, EmptyObject: EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("RouteDestinations")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + desiredNotPointer, ok := d.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations or *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + actualNotPointer, ok := a.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DestinationIds, actual.DestinationIds, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("DestinationIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PropagateService, actual.PropagateService, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("PropagateService")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } return diffs, nil } @@ -6257,6 +6439,11 @@ func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubern if v := f.PodSelectorLabel; !dcl.IsEmptyValueIndirect(v) { m["podSelectorLabel"] = v } + if v, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, f.RouteDestinations, res); err != nil { + return nil, fmt.Errorf("error expanding RouteDestinations into routeDestinations: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["routeDestinations"] = v + } return m, nil } @@ -6280,6 +6467,125 @@ func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber r.RouteUpdateWaitTime = dcl.FlattenString(m["routeUpdateWaitTime"]) r.StableCutbackDuration = dcl.FlattenString(m["stableCutbackDuration"]) r.PodSelectorLabel = dcl.FlattenString(m["podSelectorLabel"]) + r.RouteDestinations = flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, m["routeDestinations"], res) + + return r +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, f map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, f []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, i interface{}, res *DeliveryPipeline) map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make(map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + for k, item := range a { + items[k] = *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, i interface{}, res *DeliveryPipeline) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.([]interface{}) + if !ok { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(a)) + for _, item := range a { + items = append(items, *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations expands an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, f *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DestinationIds; v != nil { + m["destinationIds"] = v + } + if v := f.PropagateService; !dcl.IsEmptyValueIndirect(v) { + m["propagateService"] = v + } + + return m, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations flattens an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, i interface{}, res *DeliveryPipeline) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } + r.DestinationIds = dcl.FlattenStringSlice(m["destinationIds"]) + r.PropagateService = dcl.FlattenBool(m["propagateService"]) return r } @@ -8258,6 +8564,20 @@ func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { @@ -8565,6 +8885,20 @@ func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { diff --git a/services/google/clouddeploy/beta/delivery_pipeline_schema.go b/services/google/clouddeploy/beta/delivery_pipeline_schema.go index afa06dc6e..af9dfd90d 100755 --- a/services/google/clouddeploy/beta/delivery_pipeline_schema.go +++ b/services/google/clouddeploy/beta/delivery_pipeline_schema.go @@ -589,6 +589,33 @@ func DCLDeliveryPipelineSchema() *dcl.Schema { GoName: "PodSelectorLabel", Description: "Optional. The label to use when selecting Pods for the Deployment and Service resources. This label must already be present in both resources.", }, + "routeDestinations": &dcl.Property{ + Type: "object", + GoName: "RouteDestinations", + GoType: "DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", + Description: "Optional. Route destinations allow configuring the Gateway API HTTPRoute to be deployed to additional clusters. This option is available for multi-cluster service mesh set ups that require the route to exist in the clusters that call the service. If unspecified, the HTTPRoute will only be deployed to the Target cluster.", + Required: []string{ + "destinationIds", + }, + Properties: map[string]*dcl.Property{ + "destinationIds": &dcl.Property{ + Type: "array", + GoName: "DestinationIds", + Description: "Required. The clusters where the Gateway API HTTPRoute resource will be deployed to. Valid entries include the associated entities IDs configured in the Target resource and \"@self\" to include the Target cluster.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "propagateService": &dcl.Property{ + Type: "boolean", + GoName: "PropagateService", + Description: "Optional. Whether to propagate the Kubernetes Service to the route destination clusters. The Service will always be deployed to the Target cluster even if the HTTPRoute is not. This option may be used to facilitiate successful DNS lookup in the route destination clusters. Can only be set to true if destinations are specified.", + }, + }, + }, "routeUpdateWaitTime": &dcl.Property{ Type: "string", GoName: "RouteUpdateWaitTime", diff --git a/services/google/clouddeploy/beta/target.go b/services/google/clouddeploy/beta/target.go index 1af5ff295..533ac5f5f 100755 --- a/services/google/clouddeploy/beta/target.go +++ b/services/google/clouddeploy/beta/target.go @@ -26,25 +26,26 @@ import ( ) type Target struct { - Name *string `json:"name"` - TargetId *string `json:"targetId"` - Uid *string `json:"uid"` - Description *string `json:"description"` - Annotations map[string]string `json:"annotations"` - Labels map[string]string `json:"labels"` - RequireApproval *bool `json:"requireApproval"` - CreateTime *string `json:"createTime"` - UpdateTime *string `json:"updateTime"` - Gke *TargetGke `json:"gke"` - AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` - Etag *string `json:"etag"` - ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` - Project *string `json:"project"` - Location *string `json:"location"` - Run *TargetRun `json:"run"` - MultiTarget *TargetMultiTarget `json:"multiTarget"` - DeployParameters map[string]string `json:"deployParameters"` - CustomTarget *TargetCustomTarget `json:"customTarget"` + Name *string `json:"name"` + TargetId *string `json:"targetId"` + Uid *string `json:"uid"` + Description *string `json:"description"` + Annotations map[string]string `json:"annotations"` + Labels map[string]string `json:"labels"` + RequireApproval *bool `json:"requireApproval"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + Gke *TargetGke `json:"gke"` + AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` + Etag *string `json:"etag"` + ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` + Project *string `json:"project"` + Location *string `json:"location"` + Run *TargetRun `json:"run"` + MultiTarget *TargetMultiTarget `json:"multiTarget"` + DeployParameters map[string]string `json:"deployParameters"` + CustomTarget *TargetCustomTarget `json:"customTarget"` + AssociatedEntities map[string]TargetAssociatedEntities `json:"associatedEntities"` } func (r *Target) String() string { @@ -375,6 +376,153 @@ func (r *TargetCustomTarget) HashCode() string { return fmt.Sprintf("%x", hash) } +type TargetAssociatedEntities struct { + empty bool `json:"-"` + GkeClusters []TargetAssociatedEntitiesGkeClusters `json:"gkeClusters"` + AnthosClusters []TargetAssociatedEntitiesAnthosClusters `json:"anthosClusters"` +} + +type jsonTargetAssociatedEntities TargetAssociatedEntities + +func (r *TargetAssociatedEntities) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntities + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntities + } else { + + r.GkeClusters = res.GkeClusters + + r.AnthosClusters = res.AnthosClusters + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntities is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntities *TargetAssociatedEntities = &TargetAssociatedEntities{empty: true} + +func (r *TargetAssociatedEntities) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntities) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntities) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesGkeClusters struct { + empty bool `json:"-"` + Cluster *string `json:"cluster"` + InternalIP *bool `json:"internalIP"` + ProxyUrl *string `json:"proxyUrl"` +} + +type jsonTargetAssociatedEntitiesGkeClusters TargetAssociatedEntitiesGkeClusters + +func (r *TargetAssociatedEntitiesGkeClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesGkeClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesGkeClusters + } else { + + r.Cluster = res.Cluster + + r.InternalIP = res.InternalIP + + r.ProxyUrl = res.ProxyUrl + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesGkeClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesGkeClusters *TargetAssociatedEntitiesGkeClusters = &TargetAssociatedEntitiesGkeClusters{empty: true} + +func (r *TargetAssociatedEntitiesGkeClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesGkeClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesGkeClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesAnthosClusters struct { + empty bool `json:"-"` + Membership *string `json:"membership"` +} + +type jsonTargetAssociatedEntitiesAnthosClusters TargetAssociatedEntitiesAnthosClusters + +func (r *TargetAssociatedEntitiesAnthosClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesAnthosClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesAnthosClusters + } else { + + r.Membership = res.Membership + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesAnthosClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesAnthosClusters *TargetAssociatedEntitiesAnthosClusters = &TargetAssociatedEntitiesAnthosClusters{empty: true} + +func (r *TargetAssociatedEntitiesAnthosClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesAnthosClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesAnthosClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + // Describe returns a simple description of this resource to ensure that automated tools // can identify it. func (r *Target) Describe() dcl.ServiceTypeVersion { @@ -391,25 +539,26 @@ func (r *Target) ID() (string, error) { } nr := r.urlNormalized() params := map[string]interface{}{ - "name": dcl.ValueOrEmptyString(nr.Name), - "target_id": dcl.ValueOrEmptyString(nr.TargetId), - "uid": dcl.ValueOrEmptyString(nr.Uid), - "description": dcl.ValueOrEmptyString(nr.Description), - "annotations": dcl.ValueOrEmptyString(nr.Annotations), - "labels": dcl.ValueOrEmptyString(nr.Labels), - "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), - "create_time": dcl.ValueOrEmptyString(nr.CreateTime), - "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), - "gke": dcl.ValueOrEmptyString(nr.Gke), - "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), - "etag": dcl.ValueOrEmptyString(nr.Etag), - "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "run": dcl.ValueOrEmptyString(nr.Run), - "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), - "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), - "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "name": dcl.ValueOrEmptyString(nr.Name), + "target_id": dcl.ValueOrEmptyString(nr.TargetId), + "uid": dcl.ValueOrEmptyString(nr.Uid), + "description": dcl.ValueOrEmptyString(nr.Description), + "annotations": dcl.ValueOrEmptyString(nr.Annotations), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "gke": dcl.ValueOrEmptyString(nr.Gke), + "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), + "etag": dcl.ValueOrEmptyString(nr.Etag), + "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "run": dcl.ValueOrEmptyString(nr.Run), + "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), + "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), + "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "associated_entities": dcl.ValueOrEmptyString(nr.AssociatedEntities), } return dcl.Nprintf("projects/{{project}}/locations/{{location}}/targets/{{name}}", params), nil } diff --git a/services/google/clouddeploy/beta/target.yaml b/services/google/clouddeploy/beta/target.yaml index a408c1642..6a30937ad 100755 --- a/services/google/clouddeploy/beta/target.yaml +++ b/services/google/clouddeploy/beta/target.yaml @@ -104,6 +104,75 @@ components: x-dcl-references: - resource: Gkehub/Membership field: selfLink + associatedEntities: + type: object + additionalProperties: + type: object + x-dcl-go-type: TargetAssociatedEntities + properties: + anthosClusters: + type: array + x-dcl-go-name: AnthosClusters + description: Optional. Information specifying Anthos clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters + properties: + membership: + type: string + x-dcl-go-name: Membership + description: Optional. Membership of the GKE Hub-registered + cluster to which to apply the Skaffold configuration. Format + is `projects/{project}/locations/{location}/memberships/{membership_name}`. + x-dcl-references: + - resource: Gkehub/Membership + field: selfLink + gkeClusters: + type: array + x-dcl-go-name: GkeClusters + description: Optional. Information specifying GKE clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesGkeClusters + properties: + cluster: + type: string + x-dcl-go-name: Cluster + description: Optional. Information specifying a GKE Cluster. + Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`. + x-dcl-references: + - resource: Container/Cluster + field: selfLink + internalIP: + type: boolean + x-dcl-go-name: InternalIP + description: Optional. If true, `cluster` is accessed using + the private IP address of the control plane endpoint. Otherwise, + the default IP address of the control plane endpoint is used. + The default IP address is the private IP address for clusters + with private control-plane endpoints and the public IP address + otherwise. Only specify this option when `cluster` is a [private + GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept). + proxyUrl: + type: string + x-dcl-go-name: ProxyUrl + description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) + to the Kubernetes server. + x-dcl-go-name: AssociatedEntities + description: 'Optional. Map of entity IDs to their associated entities. + Associated entities allows specifying places other than the deployment + target for specific features. For example, the Gateway API canary can + be configured to deploy the HTTPRoute to a different cluster(s) than the + deployment cluster using associated entities. An entity ID must consist + of lower-case letters, numbers, and hyphens, start with a letter and end + with a letter or a number, and have a max length of 63 characters. In + other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.' createTime: type: string format: date-time diff --git a/services/google/clouddeploy/beta/target_beta_yaml_embed.go b/services/google/clouddeploy/beta/target_beta_yaml_embed.go index 2ce095c1d..c565fa90d 100755 --- a/services/google/clouddeploy/beta/target_beta_yaml_embed.go +++ b/services/google/clouddeploy/beta/target_beta_yaml_embed.go @@ -17,7 +17,7 @@ package beta // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/beta/target.yaml -var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") +var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n associatedEntities:\n type: object\n additionalProperties:\n type: object\n x-dcl-go-type: TargetAssociatedEntities\n properties:\n anthosClusters:\n type: array\n x-dcl-go-name: AnthosClusters\n description: Optional. Information specifying Anthos clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Optional. Membership of the GKE Hub-registered\n cluster to which to apply the Skaffold configuration. Format\n is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n gkeClusters:\n type: array\n x-dcl-go-name: GkeClusters\n description: Optional. Information specifying GKE clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesGkeClusters\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Optional. Information specifying a GKE Cluster.\n Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using\n the private IP address of the control plane endpoint. Otherwise,\n the default IP address of the control plane endpoint is used.\n The default IP address is the private IP address for clusters\n with private control-plane endpoints and the public IP address\n otherwise. Only specify this option when `cluster` is a [private\n GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n x-dcl-go-name: AssociatedEntities\n description: 'Optional. Map of entity IDs to their associated entities.\n Associated entities allows specifying places other than the deployment\n target for specific features. For example, the Gateway API canary can\n be configured to deploy the HTTPRoute to a different cluster(s) than the\n deployment cluster using associated entities. An entity ID must consist\n of lower-case letters, numbers, and hyphens, start with a letter and end\n with a letter or a number, and have a max length of 63 characters. In\n other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") -// 13256 bytes -// MD5: 6af2eccf69e0aafa0d3498bc876d8a28 +// 17100 bytes +// MD5: 7db60317a50bbd142f17a887065f11f0 diff --git a/services/google/clouddeploy/beta/target_internal.go b/services/google/clouddeploy/beta/target_internal.go index f72ba3149..a39b5584c 100755 --- a/services/google/clouddeploy/beta/target_internal.go +++ b/services/google/clouddeploy/beta/target_internal.go @@ -99,6 +99,15 @@ func (r *TargetCustomTarget) validate() error { } return nil } +func (r *TargetAssociatedEntities) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesGkeClusters) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesAnthosClusters) validate() error { + return nil +} func (r *Target) basePath() string { params := map[string]interface{}{} return dcl.Nprintf("https://clouddeploy.googleapis.com/v1/", params) @@ -224,6 +233,11 @@ func newUpdateTargetUpdateTargetRequest(ctx context.Context, f *Target, c *Clien } else if !dcl.IsEmptyValueIndirect(v) { req["customTarget"] = v } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["associatedEntities"] = v + } b, err := c.getTargetRaw(ctx, f) if err != nil { return nil, err @@ -665,6 +679,12 @@ func canonicalizeTargetDesiredState(rawDesired, rawInitial *Target, opts ...dcl. canonicalDesired.DeployParameters = rawDesired.DeployParameters } canonicalDesired.CustomTarget = canonicalizeTargetCustomTarget(rawDesired.CustomTarget, rawInitial.CustomTarget, opts...) + if dcl.IsZeroValue(rawDesired.AssociatedEntities) || (dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawInitial.AssociatedEntities)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.AssociatedEntities = rawInitial.AssociatedEntities + } else { + canonicalDesired.AssociatedEntities = rawDesired.AssociatedEntities + } if canonicalDesired.Gke != nil { // Check if anything else is set. @@ -813,6 +833,11 @@ func canonicalizeTargetNewState(c *Client, rawNew, rawDesired *Target) (*Target, rawNew.CustomTarget = canonicalizeNewTargetCustomTarget(c, rawDesired.CustomTarget, rawNew.CustomTarget) } + if dcl.IsEmptyValueIndirect(rawNew.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) { + rawNew.AssociatedEntities = rawDesired.AssociatedEntities + } else { + } + return rawNew, nil } @@ -1568,328 +1593,696 @@ func canonicalizeNewTargetCustomTargetSlice(c *Client, des, nw []TargetCustomTar return items } -// The differ returns a list of diffs, along with a list of operations that should be taken -// to remedy them. Right now, it does not attempt to consolidate operations - if several -// fields can be fixed with a patch update, it will perform the patch several times. -// Diffs on some fields will be ignored if the `desired` state has an empty (nil) -// value. This empty value indicates that the user does not care about the state for -// the field. Empty fields on the actual object will cause diffs. -// TODO(magic-modules-eng): for efficiency in some resources, add batching. -func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { - if desired == nil || actual == nil { - return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) +func canonicalizeTargetAssociatedEntities(des, initial *TargetAssociatedEntities, opts ...dcl.ApplyOption) *TargetAssociatedEntities { + if des == nil { + return initial } - - c.Config.Logger.Infof("Diff function called with desired state: %v", desired) - c.Config.Logger.Infof("Diff function called with actual state: %v", actual) - - var fn dcl.FieldName - var newDiffs []*dcl.FieldDiff - // New style diffs. - if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if des.empty { + return des } - if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) - } + cDes := &TargetAssociatedEntities{} - if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes.GkeClusters = canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des.GkeClusters, initial.GkeClusters, opts...) + cDes.AnthosClusters = canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des.AnthosClusters, initial.AnthosClusters, opts...) + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesSlice(des, initial []TargetAssociatedEntities, opts ...dcl.ApplyOption) []TargetAssociatedEntities { + if dcl.IsEmptyValueIndirect(des) { + return initial } - if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntities, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntities, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) +} + +func canonicalizeNewTargetAssociatedEntities(c *Client, des, nw *TargetAssociatedEntities) *TargetAssociatedEntities { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntities while comparing non-nil desired to nil actual. Returning desired object.") + return des } - newDiffs = append(newDiffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + nw.GkeClusters = canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c, des.GkeClusters, nw.GkeClusters) + nw.AnthosClusters = canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c, des.AnthosClusters, nw.AnthosClusters) + + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesSet(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntities + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - newDiffs = append(newDiffs, ds...) } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) - if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeNewTargetAssociatedEntitiesSlice(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw } - if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + var items []TargetAssociatedEntities + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &n)) } - if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeTargetAssociatedEntitiesGkeClusters(des, initial *TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial + } + if des.empty { + return des } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes := &TargetAssociatedEntitiesGkeClusters{} + + if dcl.IsZeroValue(des.Cluster) || (dcl.IsEmptyValueIndirect(des.Cluster) && dcl.IsEmptyValueIndirect(initial.Cluster)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Cluster = initial.Cluster + } else { + cDes.Cluster = des.Cluster + } + if dcl.BoolCanonicalize(des.InternalIP, initial.InternalIP) || dcl.IsZeroValue(des.InternalIP) { + cDes.InternalIP = initial.InternalIP + } else { + cDes.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, initial.ProxyUrl) || dcl.IsZeroValue(des.ProxyUrl) { + cDes.ProxyUrl = initial.ProxyUrl + } else { + cDes.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return cDes +} + +func canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des, initial []TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial } - if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if len(newDiffs) > 0 { - c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) - } - return newDiffs, nil } -func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff - desired, ok := d.(*TargetGke) - if !ok { - desiredNotPointer, ok := d.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) - } - desired = &desiredNotPointer - } - actual, ok := a.(*TargetGke) - if !ok { - actualNotPointer, ok := a.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke", a) - } - actual = &actualNotPointer +func canonicalizeNewTargetAssociatedEntitiesGkeClusters(c *Client, des, nw *TargetAssociatedEntitiesGkeClusters) *TargetAssociatedEntitiesGkeClusters { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesGkeClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - diffs = append(diffs, ds...) + if dcl.BoolCanonicalize(des.InternalIP, nw.InternalIP) { + nw.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, nw.ProxyUrl) { + nw.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSet(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesGkeClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesGkeClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - diffs = append(diffs, ds...) } - return diffs, nil + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items } -func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetAnthosCluster) - if !ok { - desiredNotPointer, ok := d.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesGkeClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &n)) + } + + return items +} + +func canonicalizeTargetAssociatedEntitiesAnthosClusters(des, initial *TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &TargetAssociatedEntitiesAnthosClusters{} + + if dcl.IsZeroValue(des.Membership) || (dcl.IsEmptyValueIndirect(des.Membership) && dcl.IsEmptyValueIndirect(initial.Membership)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Membership = initial.Membership + } else { + cDes.Membership = des.Membership + } + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des, initial []TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - desired = &desiredNotPointer + return items } - actual, ok := a.(*TargetAnthosCluster) - if !ok { - actualNotPointer, ok := a.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - actual = &actualNotPointer } + return items - if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c *Client, des, nw *TargetAssociatedEntitiesAnthosClusters) *TargetAssociatedEntitiesAnthosClusters { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesAnthosClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - return diffs, nil + + return nw } -func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSet(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetExecutionConfigs) - if !ok { - desiredNotPointer, ok := d.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesAnthosClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesAnthosClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - desired = &desiredNotPointer } - actual, ok := a.(*TargetExecutionConfigs) - if !ok { - actualNotPointer, ok := a.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesAnthosClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } - desired, ok := d.(*TargetRun) - if !ok { - desiredNotPointer, ok := d.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - desired = &desiredNotPointer + newDiffs = append(newDiffs, ds...) } - actual, ok := a.(*TargetRun) - if !ok { - actualNotPointer, ok := a.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun", a) + + if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.AssociatedEntities, actual.AssociatedEntities, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesNewStyle, EmptyObject: EmptyTargetAssociatedEntities, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AssociatedEntities")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetGke) + if !ok { + desiredNotPointer, ok := d.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetGke) + if !ok { + actualNotPointer, ok := a.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAnthosCluster) + if !ok { + desiredNotPointer, ok := d.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAnthosCluster) + if !ok { + actualNotPointer, ok := a.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetExecutionConfigs) + if !ok { + desiredNotPointer, ok := d.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetExecutionConfigs) + if !ok { + actualNotPointer, ok := a.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetRun) + if !ok { + desiredNotPointer, ok := d.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetRun) + if !ok { + actualNotPointer, ok := a.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { var diffs []*dcl.FieldDiff desired, ok := d.(*TargetMultiTarget) @@ -1938,189 +2331,673 @@ func compareTargetCustomTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*d actual = &actualNotPointer } - if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntities) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities or *TargetAssociatedEntities", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntities) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.GkeClusters, actual.GkeClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesGkeClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesGkeClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("GkeClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AnthosClusters, actual.AnthosClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesAnthosClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesAnthosClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesGkeClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters or *TargetAssociatedEntitiesGkeClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesAnthosClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters or *TargetAssociatedEntitiesAnthosClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Target) urlNormalized() *Target { + normalized := dcl.Copy(*r).(Target) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.TargetId = dcl.SelfLinkToName(r.TargetId) + normalized.Uid = dcl.SelfLinkToName(r.Uid) + normalized.Description = dcl.SelfLinkToName(r.Description) + normalized.Etag = dcl.SelfLinkToName(r.Etag) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *Target) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateTarget" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Target resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Target) marshal(c *Client) ([]byte, error) { + m, err := expandTarget(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Target: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalTarget decodes JSON responses into the Target resource schema. +func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapTarget(m, c, res) +} + +func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + + flattened := flattenTarget(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandTarget expands Target into a JSON request object. +func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.Description; dcl.ValueShouldBeSent(v) { + m["description"] = v + } + if v := f.Annotations; dcl.ValueShouldBeSent(v) { + m["annotations"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { + m["requireApproval"] = v + } + if v, err := expandTargetGke(c, f.Gke, res); err != nil { + return nil, fmt.Errorf("error expanding Gke into gke: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["gke"] = v + } + if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["anthosCluster"] = v + } + if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { + return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) + } else if v != nil { + m["executionConfigs"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := expandTargetRun(c, f.Run, res); err != nil { + return nil, fmt.Errorf("error expanding Run into run: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["run"] = v + } + if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { + return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["multiTarget"] = v + } + if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { + m["deployParameters"] = v + } + if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { + return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["customTarget"] = v + } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["associatedEntities"] = v + } + + return m, nil +} + +// flattenTarget flattens Target from a JSON request object into the +// Target type. +func flattenTarget(c *Client, i interface{}, res *Target) *Target { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Target{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.TargetId = dcl.FlattenString(m["targetId"]) + resultRes.Uid = dcl.FlattenString(m["uid"]) + resultRes.Description = dcl.FlattenString(m["description"]) + resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Gke = flattenTargetGke(c, m["gke"], res) + resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) + resultRes.Etag = dcl.FlattenString(m["etag"]) + resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.Run = flattenTargetRun(c, m["run"], res) + resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) + resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) + resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + resultRes.AssociatedEntities = flattenTargetAssociatedEntitiesMap(c, m["associatedEntities"], res) + + return resultRes +} + +// expandTargetGkeMap expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetGke{} + } + + if len(a) == 0 { + return map[string]TargetGke{} + } + + items := make(map[string]TargetGke) + for k, item := range a { + items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { + a, ok := i.([]interface{}) + if !ok { + return []TargetGke{} + } + + if len(a) == 0 { + return []TargetGke{} + } + + items := make([]TargetGke, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetGke expands an instance of TargetGke into a JSON +// request object. +func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v + } + + return m, nil +} + +// flattenTargetGke flattens an instance of TargetGke from a JSON +// response object. +func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetGke{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetGke + } + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + + return r +} + +// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetAnthosCluster{} + } + + if len(a) == 0 { + return map[string]TargetAnthosCluster{} + } + + items := make(map[string]TargetAnthosCluster) + for k, item := range a { + items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { + a, ok := i.([]interface{}) + if !ok { + return []TargetAnthosCluster{} + } + + if len(a) == 0 { + return []TargetAnthosCluster{} + } + + items := make([]TargetAnthosCluster, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v + } + + return m, nil +} + +// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetAnthosCluster{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetAnthosCluster + } + r.Membership = dcl.FlattenString(m["membership"]) + + return r +} + +// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) if err != nil { return nil, err } - diffs = append(diffs, ds...) + + items = append(items, i) } - return diffs, nil -} -// urlNormalized returns a copy of the resource struct with values normalized -// for URL substitutions. For instance, it converts long-form self-links to -// short-form so they can be substituted in. -func (r *Target) urlNormalized() *Target { - normalized := dcl.Copy(*r).(Target) - normalized.Name = dcl.SelfLinkToName(r.Name) - normalized.TargetId = dcl.SelfLinkToName(r.TargetId) - normalized.Uid = dcl.SelfLinkToName(r.Uid) - normalized.Description = dcl.SelfLinkToName(r.Description) - normalized.Etag = dcl.SelfLinkToName(r.Etag) - normalized.Project = dcl.SelfLinkToName(r.Project) - normalized.Location = dcl.SelfLinkToName(r.Location) - return &normalized + return items, nil } -func (r *Target) updateURL(userBasePath, updateName string) (string, error) { - nr := r.urlNormalized() - if updateName == "UpdateTarget" { - fields := map[string]interface{}{ - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "name": dcl.ValueOrEmptyString(nr.Name), - } - return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil - +// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetExecutionConfigs{} } - return "", fmt.Errorf("unknown update name: %s", updateName) -} + if len(a) == 0 { + return map[string]TargetExecutionConfigs{} + } -// marshal encodes the Target resource into JSON for a Create request, and -// performs transformations from the resource schema to the API schema if -// necessary. -func (r *Target) marshal(c *Client) ([]byte, error) { - m, err := expandTarget(c, r) - if err != nil { - return nil, fmt.Errorf("error marshalling Target: %w", err) + items := make(map[string]TargetExecutionConfigs) + for k, item := range a { + items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) } - return json.Marshal(m) + return items } -// unmarshalTarget decodes JSON responses into the Target resource schema. -func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { - var m map[string]interface{} - if err := json.Unmarshal(b, &m); err != nil { - return nil, err +// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { + a, ok := i.([]interface{}) + if !ok { + return []TargetExecutionConfigs{} } - return unmarshalMapTarget(m, c, res) -} -func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + if len(a) == 0 { + return []TargetExecutionConfigs{} + } - flattened := flattenTarget(c, m, res) - if flattened == nil { - return nil, fmt.Errorf("attempted to flatten empty json object") + items := make([]TargetExecutionConfigs, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) } - return flattened, nil + + return items } -// expandTarget expands Target into a JSON request object. -func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { - m := make(map[string]interface{}) - res := f - _ = res - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Name into name: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["name"] = v - } - if v := f.Description; dcl.ValueShouldBeSent(v) { - m["description"] = v - } - if v := f.Annotations; dcl.ValueShouldBeSent(v) { - m["annotations"] = v - } - if v := f.Labels; dcl.ValueShouldBeSent(v) { - m["labels"] = v - } - if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { - m["requireApproval"] = v - } - if v, err := expandTargetGke(c, f.Gke, res); err != nil { - return nil, fmt.Errorf("error expanding Gke into gke: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["gke"] = v - } - if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { - return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["anthosCluster"] = v - } - if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { - return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) - } else if v != nil { - m["executionConfigs"] = v +// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Project into project: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["project"] = v + + m := make(map[string]interface{}) + if v := f.Usages; v != nil { + m["usages"] = v } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Location into location: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { + m["workerPool"] = v } - if v, err := expandTargetRun(c, f.Run, res); err != nil { - return nil, fmt.Errorf("error expanding Run into run: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["run"] = v + if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { + m["serviceAccount"] = v } - if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { - return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["multiTarget"] = v + if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { + m["artifactStorage"] = v } - if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { - m["deployParameters"] = v + if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { + m["executionTimeout"] = v } - if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { - return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["customTarget"] = v + if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { + m["verbose"] = v } return m, nil } -// flattenTarget flattens Target from a JSON request object into the -// Target type. -func flattenTarget(c *Client, i interface{}, res *Target) *Target { +// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { m, ok := i.(map[string]interface{}) if !ok { return nil } - if len(m) == 0 { - return nil - } - resultRes := &Target{} - resultRes.Name = dcl.FlattenString(m["name"]) - resultRes.TargetId = dcl.FlattenString(m["targetId"]) - resultRes.Uid = dcl.FlattenString(m["uid"]) - resultRes.Description = dcl.FlattenString(m["description"]) - resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) - resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) - resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) - resultRes.CreateTime = dcl.FlattenString(m["createTime"]) - resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) - resultRes.Gke = flattenTargetGke(c, m["gke"], res) - resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) - resultRes.Etag = dcl.FlattenString(m["etag"]) - resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) - resultRes.Project = dcl.FlattenString(m["project"]) - resultRes.Location = dcl.FlattenString(m["location"]) - resultRes.Run = flattenTargetRun(c, m["run"], res) - resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) - resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) - resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + r := &TargetExecutionConfigs{} - return resultRes + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetExecutionConfigs + } + r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) + r.WorkerPool = dcl.FlattenString(m["workerPool"]) + r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) + r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) + r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) + r.Verbose = dcl.FlattenBool(m["verbose"]) + + return r } -// expandTargetGkeMap expands the contents of TargetGke into a JSON +// expandTargetRunMap expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2132,16 +3009,16 @@ func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[str return items, nil } -// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// expandTargetRunSlice expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { +func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2152,97 +3029,89 @@ func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]i return items, nil } -// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// flattenTargetRunMap flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { +func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetGke{} + return map[string]TargetRun{} } if len(a) == 0 { - return map[string]TargetGke{} + return map[string]TargetRun{} } - items := make(map[string]TargetGke) + items := make(map[string]TargetRun) for k, item := range a { - items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) } return items } -// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// flattenTargetRunSlice flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { +func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { a, ok := i.([]interface{}) if !ok { - return []TargetGke{} + return []TargetRun{} } if len(a) == 0 { - return []TargetGke{} + return []TargetRun{} } - items := make([]TargetGke, 0, len(a)) + items := make([]TargetRun, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) } return items } -// expandTargetGke expands an instance of TargetGke into a JSON +// expandTargetRun expands an instance of TargetRun into a JSON // request object. -func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { - m["cluster"] = v - } - if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { - m["internalIp"] = v - } - if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { - m["proxyUrl"] = v + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v } return m, nil } -// flattenTargetGke flattens an instance of TargetGke from a JSON +// flattenTargetRun flattens an instance of TargetRun from a JSON // response object. -func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { +func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetGke{} + r := &TargetRun{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetGke + return EmptyTargetRun } - r.Cluster = dcl.FlattenString(m["cluster"]) - r.InternalIP = dcl.FlattenBool(m["internalIp"]) - r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + r.Location = dcl.FlattenString(m["location"]) return r } -// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2254,16 +3123,16 @@ func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, r return items, nil } -// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { +func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2274,89 +3143,89 @@ func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Tar return items, nil } -// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { +func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } if len(a) == 0 { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } - items := make(map[string]TargetAnthosCluster) + items := make(map[string]TargetMultiTarget) for k, item := range a { - items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { +func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { a, ok := i.([]interface{}) if !ok { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } if len(a) == 0 { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } - items := make([]TargetAnthosCluster, 0, len(a)) + items := make([]TargetMultiTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { - m["membership"] = v + if v := f.TargetIds; v != nil { + m["targetIds"] = v } return m, nil } -// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { +func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetAnthosCluster{} + r := &TargetMultiTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetAnthosCluster + return EmptyTargetMultiTarget } - r.Membership = dcl.FlattenString(m["membership"]) + r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) return r } -// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { +func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2368,16 +3237,16 @@ func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConf return items, nil } -// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { +func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2388,109 +3257,89 @@ func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, re return items, nil } -// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { +func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } if len(a) == 0 { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } - items := make(map[string]TargetExecutionConfigs) + items := make(map[string]TargetCustomTarget) for k, item := range a { - items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { +func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { a, ok := i.([]interface{}) if !ok { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } if len(a) == 0 { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } - items := make([]TargetExecutionConfigs, 0, len(a)) + items := make([]TargetCustomTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { - if f == nil { +func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Usages; v != nil { - m["usages"] = v - } - if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { - m["workerPool"] = v - } - if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { - m["serviceAccount"] = v - } - if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { - m["artifactStorage"] = v - } - if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { - m["executionTimeout"] = v - } - if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { - m["verbose"] = v + if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { + m["customTargetType"] = v } return m, nil } -// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { +func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetExecutionConfigs{} + r := &TargetCustomTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetExecutionConfigs + return EmptyTargetCustomTarget } - r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) - r.WorkerPool = dcl.FlattenString(m["workerPool"]) - r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) - r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) - r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) - r.Verbose = dcl.FlattenBool(m["verbose"]) + r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) return r } -// expandTargetRunMap expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesMap expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesMap(c *Client, f map[string]TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2502,16 +3351,16 @@ func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[str return items, nil } -// expandTargetRunSlice expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesSlice expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesSlice(c *Client, f []TargetAssociatedEntities, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2522,89 +3371,97 @@ func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]i return items, nil } -// flattenTargetRunMap flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesMap flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { +func flattenTargetAssociatedEntitiesMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntities { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } if len(a) == 0 { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } - items := make(map[string]TargetRun) + items := make(map[string]TargetAssociatedEntities) for k, item := range a { - items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res) } return items } -// flattenTargetRunSlice flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesSlice flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { +func flattenTargetAssociatedEntitiesSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntities { a, ok := i.([]interface{}) if !ok { - return []TargetRun{} + return []TargetAssociatedEntities{} } if len(a) == 0 { - return []TargetRun{} + return []TargetAssociatedEntities{} } - items := make([]TargetRun, 0, len(a)) + items := make([]TargetAssociatedEntities, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res)) } return items } -// expandTargetRun expands an instance of TargetRun into a JSON +// expandTargetAssociatedEntities expands an instance of TargetAssociatedEntities into a JSON // request object. -func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntities(c *Client, f *TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Location; !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v, err := expandTargetAssociatedEntitiesGkeClustersSlice(c, f.GkeClusters, res); err != nil { + return nil, fmt.Errorf("error expanding GkeClusters into gkeClusters: %w", err) + } else if v != nil { + m["gkeClusters"] = v + } + if v, err := expandTargetAssociatedEntitiesAnthosClustersSlice(c, f.AnthosClusters, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosClusters into anthosClusters: %w", err) + } else if v != nil { + m["anthosClusters"] = v } return m, nil } -// flattenTargetRun flattens an instance of TargetRun from a JSON +// flattenTargetAssociatedEntities flattens an instance of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { +func flattenTargetAssociatedEntities(c *Client, i interface{}, res *Target) *TargetAssociatedEntities { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetRun{} + r := &TargetAssociatedEntities{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetRun + return EmptyTargetAssociatedEntities } - r.Location = dcl.FlattenString(m["location"]) + r.GkeClusters = flattenTargetAssociatedEntitiesGkeClustersSlice(c, m["gkeClusters"], res) + r.AnthosClusters = flattenTargetAssociatedEntitiesAnthosClustersSlice(c, m["anthosClusters"], res) return r } -// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersMap expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersMap(c *Client, f map[string]TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2616,16 +3473,16 @@ func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res * return items, nil } -// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersSlice expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersSlice(c *Client, f []TargetAssociatedEntitiesGkeClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2636,89 +3493,97 @@ func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) return items, nil } -// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersMap flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesGkeClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } - items := make(map[string]TargetMultiTarget) + items := make(map[string]TargetAssociatedEntitiesGkeClusters) for k, item := range a { - items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersSlice flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesGkeClusters { a, ok := i.([]interface{}) if !ok { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } - items := make([]TargetMultiTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClusters expands an instance of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesGkeClusters(c *Client, f *TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.TargetIds; v != nil { - m["targetIds"] = v + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v } return m, nil } -// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClusters flattens an instance of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesGkeClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetMultiTarget{} + r := &TargetAssociatedEntitiesGkeClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetMultiTarget + return EmptyTargetAssociatedEntitiesGkeClusters } - r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) return r } -// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersMap expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersMap(c *Client, f map[string]TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2730,16 +3595,16 @@ func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res return items, nil } -// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersSlice expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersSlice(c *Client, f []TargetAssociatedEntitiesAnthosClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2750,75 +3615,75 @@ func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Targe return items, nil } -// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersMap flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesAnthosClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } - items := make(map[string]TargetCustomTarget) + items := make(map[string]TargetAssociatedEntitiesAnthosClusters) for k, item := range a { - items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersSlice flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesAnthosClusters { a, ok := i.([]interface{}) if !ok { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } - items := make([]TargetCustomTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClusters expands an instance of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesAnthosClusters(c *Client, f *TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { - m["customTargetType"] = v + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v } return m, nil } -// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClusters flattens an instance of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesAnthosClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetCustomTarget{} + r := &TargetAssociatedEntitiesAnthosClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetCustomTarget + return EmptyTargetAssociatedEntitiesAnthosClusters } - r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) + r.Membership = dcl.FlattenString(m["membership"]) return r } @@ -3043,6 +3908,15 @@ func extractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) error { func extractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func extractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func extractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func extractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} func postReadExtractTargetFields(r *Target) error { vGke := r.Gke @@ -3120,3 +3994,12 @@ func postReadExtractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) err func postReadExtractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func postReadExtractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} diff --git a/services/google/clouddeploy/beta/target_schema.go b/services/google/clouddeploy/beta/target_schema.go index df073aa5c..894de2a75 100755 --- a/services/google/clouddeploy/beta/target_schema.go +++ b/services/google/clouddeploy/beta/target_schema.go @@ -146,6 +146,75 @@ func DCLTargetSchema() *dcl.Schema { }, }, }, + "associatedEntities": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntities", + Properties: map[string]*dcl.Property{ + "anthosClusters": &dcl.Property{ + Type: "array", + GoName: "AnthosClusters", + Description: "Optional. Information specifying Anthos clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesAnthosClusters", + Properties: map[string]*dcl.Property{ + "membership": &dcl.Property{ + Type: "string", + GoName: "Membership", + Description: "Optional. Membership of the GKE Hub-registered cluster to which to apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Gkehub/Membership", + Field: "selfLink", + }, + }, + }, + }, + }, + }, + "gkeClusters": &dcl.Property{ + Type: "array", + GoName: "GkeClusters", + Description: "Optional. Information specifying GKE clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesGkeClusters", + Properties: map[string]*dcl.Property{ + "cluster": &dcl.Property{ + Type: "string", + GoName: "Cluster", + Description: "Optional. Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Container/Cluster", + Field: "selfLink", + }, + }, + }, + "internalIP": &dcl.Property{ + Type: "boolean", + GoName: "InternalIP", + Description: "Optional. If true, `cluster` is accessed using the private IP address of the control plane endpoint. Otherwise, the default IP address of the control plane endpoint is used. The default IP address is the private IP address for clusters with private control-plane endpoints and the public IP address otherwise. Only specify this option when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).", + }, + "proxyUrl": &dcl.Property{ + Type: "string", + GoName: "ProxyUrl", + Description: "Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) to the Kubernetes server.", + }, + }, + }, + }, + }, + }, + GoName: "AssociatedEntities", + Description: "Optional. Map of entity IDs to their associated entities. Associated entities allows specifying places other than the deployment target for specific features. For example, the Gateway API canary can be configured to deploy the HTTPRoute to a different cluster(s) than the deployment cluster using associated entities. An entity ID must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.", + }, "createTime": &dcl.Property{ Type: "string", Format: "date-time", diff --git a/services/google/clouddeploy/delivery_pipeline.go b/services/google/clouddeploy/delivery_pipeline.go index 00fd8791a..9964c8b8a 100755 --- a/services/google/clouddeploy/delivery_pipeline.go +++ b/services/google/clouddeploy/delivery_pipeline.go @@ -490,13 +490,14 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet } type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh struct { - empty bool `json:"-"` - HttpRoute *string `json:"httpRoute"` - Service *string `json:"service"` - Deployment *string `json:"deployment"` - RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` - StableCutbackDuration *string `json:"stableCutbackDuration"` - PodSelectorLabel *string `json:"podSelectorLabel"` + empty bool `json:"-"` + HttpRoute *string `json:"httpRoute"` + Service *string `json:"service"` + Deployment *string `json:"deployment"` + RouteUpdateWaitTime *string `json:"routeUpdateWaitTime"` + StableCutbackDuration *string `json:"stableCutbackDuration"` + PodSelectorLabel *string `json:"podSelectorLabel"` + RouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations `json:"routeDestinations"` } type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh @@ -526,6 +527,8 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet r.PodSelectorLabel = res.PodSelectorLabel + r.RouteDestinations = res.RouteDestinations + } return nil } @@ -550,6 +553,55 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet return fmt.Sprintf("%x", hash) } +type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations struct { + empty bool `json:"-"` + DestinationIds []string `json:"destinationIds"` + PropagateService *bool `json:"propagateService"` +} + +type jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) UnmarshalJSON(data []byte) error { + var res jsonDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } else { + + r.DestinationIds = res.DestinationIds + + r.PropagateService = res.PropagateService + + } + return nil +} + +// This object is used to assert a desired state where this DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{empty: true} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) Empty() bool { + return r.empty +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) String() string { + return dcl.SprintResource(r) +} + +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + type DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking struct { empty bool `json:"-"` Service *string `json:"service"` diff --git a/services/google/clouddeploy/delivery_pipeline.yaml b/services/google/clouddeploy/delivery_pipeline.yaml index 23c63a403..2773a9053 100755 --- a/services/google/clouddeploy/delivery_pipeline.yaml +++ b/services/google/clouddeploy/delivery_pipeline.yaml @@ -544,6 +544,47 @@ components: selecting Pods for the Deployment and Service resources. This label must already be present in both resources. + routeDestinations: + type: object + x-dcl-go-name: RouteDestinations + x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + description: Optional. Route destinations + allow configuring the Gateway API HTTPRoute + to be deployed to additional clusters. This + option is available for multi-cluster service + mesh set ups that require the route to exist + in the clusters that call the service. If + unspecified, the HTTPRoute will only be + deployed to the Target cluster. + required: + - destinationIds + properties: + destinationIds: + type: array + x-dcl-go-name: DestinationIds + description: Required. The clusters where + the Gateway API HTTPRoute resource will + be deployed to. Valid entries include + the associated entities IDs configured + in the Target resource and "@self" to + include the Target cluster. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: string + x-dcl-go-type: string + propagateService: + type: boolean + x-dcl-go-name: PropagateService + description: Optional. Whether to propagate + the Kubernetes Service to the route + destination clusters. The Service will + always be deployed to the Target cluster + even if the HTTPRoute is not. This option + may be used to facilitiate successful + DNS lookup in the route destination + clusters. Can only be set to true if + destinations are specified. routeUpdateWaitTime: type: string x-dcl-go-name: RouteUpdateWaitTime diff --git a/services/google/clouddeploy/delivery_pipeline_internal.go b/services/google/clouddeploy/delivery_pipeline_internal.go index f863fc58d..b384ce6b8 100755 --- a/services/google/clouddeploy/delivery_pipeline_internal.go +++ b/services/google/clouddeploy/delivery_pipeline_internal.go @@ -154,6 +154,17 @@ func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernet if err := dcl.Required(r, "deployment"); err != nil { return err } + if !dcl.IsEmptyValueIndirect(r.RouteDestinations) { + if err := r.RouteDestinations.validate(); err != nil { + return err + } + } + return nil +} +func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) validate() error { + if err := dcl.Required(r, "destinationIds"); err != nil { + return err + } return nil } func (r *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) validate() error { @@ -1992,6 +2003,7 @@ func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig } else { cDes.PodSelectorLabel = des.PodSelectorLabel } + cDes.RouteDestinations = canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des.RouteDestinations, initial.RouteDestinations, opts...) return cDes } @@ -2056,6 +2068,7 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon if dcl.StringCanonicalize(des.PodSelectorLabel, nw.PodSelectorLabel) { nw.PodSelectorLabel = des.PodSelectorLabel } + nw.RouteDestinations = canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, des.RouteDestinations, nw.RouteDestinations) return nw } @@ -2106,6 +2119,132 @@ func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return items } +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.StringArrayCanonicalize(des.DestinationIds, initial.DestinationIds) { + cDes.DestinationIds = initial.DestinationIds + } else { + cDes.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, initial.PropagateService) || dcl.IsZeroValue(des.PropagateService) { + cDes.PropagateService = initial.PropagateService + } else { + cDes.PropagateService = des.PropagateService + } + + return cDes +} + +func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(des, initial []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, opts ...dcl.ApplyOption) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if dcl.IsEmptyValueIndirect(des) { + return initial + } + + if len(des) != len(initial) { + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for _, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(des)) + for i, d := range des { + cd := canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) + } + } + return items + +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, des, nw *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations while comparing non-nil desired to nil actual. Returning desired object.") + return des + } + return nil + } + + if dcl.StringArrayCanonicalize(des.DestinationIds, nw.DestinationIds) { + nw.DestinationIds = des.DestinationIds + } + if dcl.BoolCanonicalize(des.PropagateService, nw.PropagateService) { + nw.PropagateService = des.PropagateService + } + + return nw +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSet(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) + } + } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, des, nw []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &d, &n)) + } + + return items +} + func canonicalizeDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking(des, initial *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking, opts ...dcl.ApplyOption) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking { if des == nil { return initial @@ -4371,6 +4510,49 @@ func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber } diffs = append(diffs, ds...) } + + if ds, err := dcl.Diff(desired.RouteDestinations, actual.RouteDestinations, dcl.DiffInfo{ObjectFunction: compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle, EmptyObject: EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("RouteDestinations")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + desiredNotPointer, ok := d.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations or *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + actualNotPointer, ok := a.(DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + if !ok { + return nil, fmt.Errorf("obj %v is not a DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.DestinationIds, actual.DestinationIds, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("DestinationIds")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.PropagateService, actual.PropagateService, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateDeliveryPipelineUpdateDeliveryPipelineOperation")}, fn.AddNest("PropagateService")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } return diffs, nil } @@ -6257,6 +6439,11 @@ func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubern if v := f.PodSelectorLabel; !dcl.IsEmptyValueIndirect(v) { m["podSelectorLabel"] = v } + if v, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, f.RouteDestinations, res); err != nil { + return nil, fmt.Errorf("error expanding RouteDestinations into routeDestinations: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["routeDestinations"] = v + } return m, nil } @@ -6280,6 +6467,125 @@ func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber r.RouteUpdateWaitTime = dcl.FlattenString(m["routeUpdateWaitTime"]) r.StableCutbackDuration = dcl.FlattenString(m["stableCutbackDuration"]) r.PodSelectorLabel = dcl.FlattenString(m["podSelectorLabel"]) + r.RouteDestinations = flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, m["routeDestinations"], res) + + return r +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, f map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice expands the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, f []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsMap(c *Client, i interface{}, res *DeliveryPipeline) map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make(map[string]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) + for k, item := range a { + items[k] = *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice flattens the contents of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsSlice(c *Client, i interface{}, res *DeliveryPipeline) []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + a, ok := i.([]interface{}) + if !ok { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + if len(a) == 0 { + return []DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + + items := make([]DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, 0, len(a)) + for _, item := range a { + items = append(items, *flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations expands an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations into a JSON +// request object. +func expandDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, f *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, res *DeliveryPipeline) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.DestinationIds; v != nil { + m["destinationIds"] = v + } + if v := f.PropagateService; !dcl.IsEmptyValueIndirect(v) { + m["propagateService"] = v + } + + return m, nil +} + +// flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations flattens an instance of DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations from a JSON +// response object. +func flattenDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations(c *Client, i interface{}, res *DeliveryPipeline) *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } + r.DestinationIds = dcl.FlattenStringSlice(m["destinationIds"]) + r.PropagateService = dcl.FlattenBool(m["propagateService"]) return r } @@ -8258,6 +8564,20 @@ func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKuber return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { @@ -8565,6 +8885,20 @@ func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeCon return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh) error { + vRouteDestinations := o.RouteDestinations + if vRouteDestinations == nil { + // note: explicitly not the empty object. + vRouteDestinations = &DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + } + if err := extractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r, vRouteDestinations); err != nil { + return err + } + if !dcl.IsEmptyValueIndirect(vRouteDestinations) { + o.RouteDestinations = vRouteDestinations + } + return nil +} +func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations) error { return nil } func postReadExtractDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworkingFields(r *DeliveryPipeline, o *DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking) error { diff --git a/services/google/clouddeploy/delivery_pipeline_schema.go b/services/google/clouddeploy/delivery_pipeline_schema.go index b1a5b5847..5386a8e1a 100755 --- a/services/google/clouddeploy/delivery_pipeline_schema.go +++ b/services/google/clouddeploy/delivery_pipeline_schema.go @@ -589,6 +589,33 @@ func DCLDeliveryPipelineSchema() *dcl.Schema { GoName: "PodSelectorLabel", Description: "Optional. The label to use when selecting Pods for the Deployment and Service resources. This label must already be present in both resources.", }, + "routeDestinations": &dcl.Property{ + Type: "object", + GoName: "RouteDestinations", + GoType: "DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations", + Description: "Optional. Route destinations allow configuring the Gateway API HTTPRoute to be deployed to additional clusters. This option is available for multi-cluster service mesh set ups that require the route to exist in the clusters that call the service. If unspecified, the HTTPRoute will only be deployed to the Target cluster.", + Required: []string{ + "destinationIds", + }, + Properties: map[string]*dcl.Property{ + "destinationIds": &dcl.Property{ + Type: "array", + GoName: "DestinationIds", + Description: "Required. The clusters where the Gateway API HTTPRoute resource will be deployed to. Valid entries include the associated entities IDs configured in the Target resource and \"@self\" to include the Target cluster.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "string", + GoType: "string", + }, + }, + "propagateService": &dcl.Property{ + Type: "boolean", + GoName: "PropagateService", + Description: "Optional. Whether to propagate the Kubernetes Service to the route destination clusters. The Service will always be deployed to the Target cluster even if the HTTPRoute is not. This option may be used to facilitiate successful DNS lookup in the route destination clusters. Can only be set to true if destinations are specified.", + }, + }, + }, "routeUpdateWaitTime": &dcl.Property{ Type: "string", GoName: "RouteUpdateWaitTime", diff --git a/services/google/clouddeploy/delivery_pipeline_yaml_embed.go b/services/google/clouddeploy/delivery_pipeline_yaml_embed.go index 0616e0cb1..e1ee6a155 100755 --- a/services/google/clouddeploy/delivery_pipeline_yaml_embed.go +++ b/services/google/clouddeploy/delivery_pipeline_yaml_embed.go @@ -17,7 +17,7 @@ package clouddeploy // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/delivery_pipeline.yaml -var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") +var YAML_delivery_pipeline = []byte("info:\n title: Clouddeploy/DeliveryPipeline\n description: The Cloud Deploy `DeliveryPipeline` resource\n x-dcl-struct-name: DeliveryPipeline\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.deliveryPipelines\npaths:\n get:\n description: The function used to get information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n apply:\n description: The function used to apply information about a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n delete:\n description: The function used to delete a DeliveryPipeline\n parameters:\n - name: deliveryPipeline\n required: true\n description: A full instance of a DeliveryPipeline\n deleteAll:\n description: The function used to delete all DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many DeliveryPipeline\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n DeliveryPipeline:\n title: DeliveryPipeline\n x-dcl-id: projects/{{project}}/locations/{{location}}/deliveryPipelines/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: User annotations. These attributes can only be set and used\n by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n condition:\n type: object\n x-dcl-go-name: Condition\n x-dcl-go-type: DeliveryPipelineCondition\n readOnly: true\n description: Output only. Information around the state of the Delivery Pipeline.\n properties:\n pipelineReadyCondition:\n type: object\n x-dcl-go-name: PipelineReadyCondition\n x-dcl-go-type: DeliveryPipelineConditionPipelineReadyCondition\n description: Details around the Pipeline's overall status.\n properties:\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the Pipeline is in a valid state. Otherwise\n at least one condition in `PipelineCondition` is in an invalid\n state. Iterate over those conditions and see which condition(s)\n has status = false to find out what is wrong with the Pipeline.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsPresentCondition:\n type: object\n x-dcl-go-name: TargetsPresentCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsPresentCondition\n description: Details around targets enumerated in the pipeline.\n properties:\n missingTargets:\n type: array\n x-dcl-go-name: MissingTargets\n description: The list of Target names that are missing. For example,\n projects/{project_id}/locations/{location_name}/targets/{target_name}.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n x-dcl-references:\n - resource: Clouddeploy/Target\n field: selfLink\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if there aren't any missing Targets.\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n description: Last time the condition was updated.\n targetsTypeCondition:\n type: object\n x-dcl-go-name: TargetsTypeCondition\n x-dcl-go-type: DeliveryPipelineConditionTargetsTypeCondition\n description: Details on the whether the targets enumerated in the pipeline\n are of the same type.\n properties:\n errorDetails:\n type: string\n x-dcl-go-name: ErrorDetails\n description: Human readable error message.\n status:\n type: boolean\n x-dcl-go-name: Status\n description: True if the targets are all a comparable type. For\n example this is true if all targets are GKE clusters. This is\n false if some targets are Cloud Run targets and others are GKE\n clusters.\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the pipeline was created.\n x-kubernetes-immutable: true\n description:\n type: string\n x-dcl-go-name: Description\n description: Description of the `DeliveryPipeline`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: This checksum is computed by the server based on the value\n of other fields, and may be sent on update and delete requests to ensure\n the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Labels are attributes that can be set and used by both the\n user and by Google Cloud Deploy. Labels must meet the following constraints:\n * Keys and values can contain only lowercase letters, numeric characters,\n underscores, and dashes. * All characters must use UTF-8 encoding, and\n international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `DeliveryPipeline`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n serialPipeline:\n type: object\n x-dcl-go-name: SerialPipeline\n x-dcl-go-type: DeliveryPipelineSerialPipeline\n description: SerialPipeline defines a sequential set of stages for a `DeliveryPipeline`.\n properties:\n stages:\n type: array\n x-dcl-go-name: Stages\n description: Each stage specifies configuration for a `Target`. The\n ordering of this list defines the promotion flow.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStages\n properties:\n deployParameters:\n type: array\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for the target\n in this stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesDeployParameters\n required:\n - values\n properties:\n matchTargetLabels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: MatchTargetLabels\n description: Optional. Deploy parameters are applied to\n targets with match labels. If unspecified, deploy parameters\n are applied to all targets (including child targets of\n a multi-target).\n values:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Values\n description: Required. Values are deploy parameters in key-value\n pairs.\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering the manifest\n for this stage's `Target`.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n strategy:\n type: object\n x-dcl-go-name: Strategy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategy\n description: Optional. The strategy to use for a `Rollout` to\n this stage.\n properties:\n canary:\n type: object\n x-dcl-go-name: Canary\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanary\n description: Canary deployment strategy provides progressive\n percentage based deployments to a Target.\n properties:\n canaryDeployment:\n type: object\n x-dcl-go-name: CanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeployment\n description: Configures the progressive based deployment\n for a Target.\n x-dcl-conflicts:\n - customCanaryDeployment\n required:\n - percentages\n properties:\n percentages:\n type: array\n x-dcl-go-name: Percentages\n description: Required. The percentage based deployments\n that will occur as a part of a `Rollout`. List is\n expected in ascending order and each integer n is\n 0 <= n < 100.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: integer\n format: int64\n x-dcl-go-type: int64\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPostdeploy\n description: Optional. Configuration for the postdeploy\n job of the last phase. If this is not configured,\n postdeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCanaryDeploymentPredeploy\n description: Optional. Configuration for the predeploy\n job of the first phase. If this is not configured,\n predeploy job will not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution of\n the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after each\n percentage deployment.\n customCanaryDeployment:\n type: object\n x-dcl-go-name: CustomCanaryDeployment\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeployment\n description: Configures the progressive based deployment\n for a Target, but allows customizing at the phase level\n where a phase represents each of the percentage deployments.\n x-dcl-conflicts:\n - canaryDeployment\n required:\n - phaseConfigs\n properties:\n phaseConfigs:\n type: array\n x-dcl-go-name: PhaseConfigs\n description: Required. Configuration for each phase\n in the canary deployment in the order executed.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigs\n required:\n - phaseId\n - percentage\n properties:\n percentage:\n type: integer\n format: int64\n x-dcl-go-name: Percentage\n description: Required. Percentage deployment\n for the phase.\n phaseId:\n type: string\n x-dcl-go-name: PhaseId\n description: 'Required. The ID to assign to\n the `Rollout` phase. This value must consist\n of lower-case letters, numbers, and hyphens,\n start with a letter and end with a letter\n or a number, and have a max length of 63 characters.\n In other words, it must match the following\n regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPostdeploy\n description: Optional. Configuration for the\n postdeploy job of this phase. If this is not\n configured, postdeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the postdeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryCustomCanaryDeploymentPhaseConfigsPredeploy\n description: Optional. Configuration for the\n predeploy job of this phase. If this is not\n configured, predeploy job will not be present\n for this phase.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold\n custom actions to invoke during execution\n of the predeploy job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n profiles:\n type: array\n x-dcl-go-name: Profiles\n description: Skaffold profiles to use when rendering\n the manifest for this phase. These are in\n addition to the profiles list specified in\n the `DeliveryPipeline` stage.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to run verify tests after\n the deployment.\n runtimeConfig:\n type: object\n x-dcl-go-name: RuntimeConfig\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfig\n description: Optional. Runtime specific configurations\n for the deployment strategy. The runtime configuration\n is used to determine how Cloud Deploy will split traffic\n to enable a progressive deployment.\n properties:\n cloudRun:\n type: object\n x-dcl-go-name: CloudRun\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigCloudRun\n description: Cloud Run runtime configuration.\n x-dcl-conflicts:\n - kubernetes\n properties:\n automaticTrafficControl:\n type: boolean\n x-dcl-go-name: AutomaticTrafficControl\n description: Whether Cloud Deploy should update\n the traffic stanza in a Cloud Run Service on\n the user's behalf to facilitate traffic splitting.\n This is required to be true for CanaryDeployments,\n but optional for CustomCanaryDeployments.\n canaryRevisionTags:\n type: array\n x-dcl-go-name: CanaryRevisionTags\n description: Optional. A list of tags that are\n added to the canary revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n priorRevisionTags:\n type: array\n x-dcl-go-name: PriorRevisionTags\n description: Optional. A list of tags that are\n added to the prior revision while the canary\n phase is in progress.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n stableRevisionTags:\n type: array\n x-dcl-go-name: StableRevisionTags\n description: Optional. A list of tags that are\n added to the final stable revision when the\n stable phase is applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n kubernetes:\n type: object\n x-dcl-go-name: Kubernetes\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetes\n description: Kubernetes runtime configuration.\n x-dcl-conflicts:\n - cloudRun\n properties:\n gatewayServiceMesh:\n type: object\n x-dcl-go-name: GatewayServiceMesh\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh\n description: Kubernetes Gateway API service mesh\n configuration.\n x-dcl-conflicts:\n - serviceNetworking\n required:\n - httpRoute\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified HTTPRoute and Service.\n httpRoute:\n type: string\n x-dcl-go-name: HttpRoute\n description: Required. Name of the Gateway\n API HTTPRoute.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment and Service\n resources. This label must already be present\n in both resources.\n routeDestinations:\n type: object\n x-dcl-go-name: RouteDestinations\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations\n description: Optional. Route destinations\n allow configuring the Gateway API HTTPRoute\n to be deployed to additional clusters. This\n option is available for multi-cluster service\n mesh set ups that require the route to exist\n in the clusters that call the service. If\n unspecified, the HTTPRoute will only be\n deployed to the Target cluster.\n required:\n - destinationIds\n properties:\n destinationIds:\n type: array\n x-dcl-go-name: DestinationIds\n description: Required. The clusters where\n the Gateway API HTTPRoute resource will\n be deployed to. Valid entries include\n the associated entities IDs configured\n in the Target resource and \"@self\" to\n include the Target cluster.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n propagateService:\n type: boolean\n x-dcl-go-name: PropagateService\n description: Optional. Whether to propagate\n the Kubernetes Service to the route\n destination clusters. The Service will\n always be deployed to the Target cluster\n even if the HTTPRoute is not. This option\n may be used to facilitiate successful\n DNS lookup in the route destination\n clusters. Can only be set to true if\n destinations are specified.\n routeUpdateWaitTime:\n type: string\n x-dcl-go-name: RouteUpdateWaitTime\n description: Optional. The time to wait for\n route updates to propagate. The maximum\n configurable time is 3 hours, in seconds\n format. If unspecified, there is no wait\n time.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n stableCutbackDuration:\n type: string\n x-dcl-go-name: StableCutbackDuration\n description: Optional. The amount of time\n to migrate traffic back from the canary\n Service to the original Service during the\n stable phase deployment. If specified, must\n be between 15s and 3600s. If unspecified,\n there is no cutback time.\n serviceNetworking:\n type: object\n x-dcl-go-name: ServiceNetworking\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesServiceNetworking\n description: Kubernetes Service networking configuration.\n x-dcl-conflicts:\n - gatewayServiceMesh\n required:\n - service\n - deployment\n properties:\n deployment:\n type: string\n x-dcl-go-name: Deployment\n description: Required. Name of the Kubernetes\n Deployment whose traffic is managed by the\n specified Service.\n disablePodOverprovisioning:\n type: boolean\n x-dcl-go-name: DisablePodOverprovisioning\n description: Optional. Whether to disable\n Pod overprovisioning. If Pod overprovisioning\n is disabled then Cloud Deploy will limit\n the number of total Pods used for the deployment\n strategy to the number of Pods the Deployment\n has on the cluster.\n podSelectorLabel:\n type: string\n x-dcl-go-name: PodSelectorLabel\n description: Optional. The label to use when\n selecting Pods for the Deployment resource.\n This label must already be present in the\n Deployment.\n service:\n type: string\n x-dcl-go-name: Service\n description: Required. Name of the Kubernetes\n Service.\n standard:\n type: object\n x-dcl-go-name: Standard\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandard\n description: Standard deployment strategy executes a single\n deploy and allows verifying the deployment.\n properties:\n postdeploy:\n type: object\n x-dcl-go-name: Postdeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPostdeploy\n description: Optional. Configuration for the postdeploy\n job. If this is not configured, postdeploy job will\n not be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the postdeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n predeploy:\n type: object\n x-dcl-go-name: Predeploy\n x-dcl-go-type: DeliveryPipelineSerialPipelineStagesStrategyStandardPredeploy\n description: Optional. Configuration for the predeploy\n job. If this is not configured, predeploy job will not\n be present.\n properties:\n actions:\n type: array\n x-dcl-go-name: Actions\n description: Optional. A sequence of skaffold custom\n actions to invoke during execution of the predeploy\n job.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n verify:\n type: boolean\n x-dcl-go-name: Verify\n description: Whether to verify a deployment.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n description: The target_id to which this stage points. This field\n refers exclusively to the last segment of a target name. For\n example, this field would just be `my-target` (rather than `projects/project/locations/location/targets/my-target`).\n The location of the `Target` is inferred to be the same as the\n location of the `DeliveryPipeline` that contains this `Stage`.\n suspended:\n type: boolean\n x-dcl-go-name: Suspended\n description: When suspended, no new releases or rollouts can be created,\n but in-progress ones will complete.\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `DeliveryPipeline`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the pipeline was updated.\n x-kubernetes-immutable: true\n") -// 36151 bytes -// MD5: ff459f48fb76c99e0104adec32956cb6 +// 39271 bytes +// MD5: fb938761986f76f4a57bb5452ac3b884 diff --git a/services/google/clouddeploy/target.go b/services/google/clouddeploy/target.go index 955088ebc..688275484 100755 --- a/services/google/clouddeploy/target.go +++ b/services/google/clouddeploy/target.go @@ -26,25 +26,26 @@ import ( ) type Target struct { - Name *string `json:"name"` - TargetId *string `json:"targetId"` - Uid *string `json:"uid"` - Description *string `json:"description"` - Annotations map[string]string `json:"annotations"` - Labels map[string]string `json:"labels"` - RequireApproval *bool `json:"requireApproval"` - CreateTime *string `json:"createTime"` - UpdateTime *string `json:"updateTime"` - Gke *TargetGke `json:"gke"` - AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` - Etag *string `json:"etag"` - ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` - Project *string `json:"project"` - Location *string `json:"location"` - Run *TargetRun `json:"run"` - MultiTarget *TargetMultiTarget `json:"multiTarget"` - DeployParameters map[string]string `json:"deployParameters"` - CustomTarget *TargetCustomTarget `json:"customTarget"` + Name *string `json:"name"` + TargetId *string `json:"targetId"` + Uid *string `json:"uid"` + Description *string `json:"description"` + Annotations map[string]string `json:"annotations"` + Labels map[string]string `json:"labels"` + RequireApproval *bool `json:"requireApproval"` + CreateTime *string `json:"createTime"` + UpdateTime *string `json:"updateTime"` + Gke *TargetGke `json:"gke"` + AnthosCluster *TargetAnthosCluster `json:"anthosCluster"` + Etag *string `json:"etag"` + ExecutionConfigs []TargetExecutionConfigs `json:"executionConfigs"` + Project *string `json:"project"` + Location *string `json:"location"` + Run *TargetRun `json:"run"` + MultiTarget *TargetMultiTarget `json:"multiTarget"` + DeployParameters map[string]string `json:"deployParameters"` + CustomTarget *TargetCustomTarget `json:"customTarget"` + AssociatedEntities map[string]TargetAssociatedEntities `json:"associatedEntities"` } func (r *Target) String() string { @@ -375,6 +376,153 @@ func (r *TargetCustomTarget) HashCode() string { return fmt.Sprintf("%x", hash) } +type TargetAssociatedEntities struct { + empty bool `json:"-"` + GkeClusters []TargetAssociatedEntitiesGkeClusters `json:"gkeClusters"` + AnthosClusters []TargetAssociatedEntitiesAnthosClusters `json:"anthosClusters"` +} + +type jsonTargetAssociatedEntities TargetAssociatedEntities + +func (r *TargetAssociatedEntities) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntities + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntities + } else { + + r.GkeClusters = res.GkeClusters + + r.AnthosClusters = res.AnthosClusters + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntities is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntities *TargetAssociatedEntities = &TargetAssociatedEntities{empty: true} + +func (r *TargetAssociatedEntities) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntities) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntities) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesGkeClusters struct { + empty bool `json:"-"` + Cluster *string `json:"cluster"` + InternalIP *bool `json:"internalIP"` + ProxyUrl *string `json:"proxyUrl"` +} + +type jsonTargetAssociatedEntitiesGkeClusters TargetAssociatedEntitiesGkeClusters + +func (r *TargetAssociatedEntitiesGkeClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesGkeClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesGkeClusters + } else { + + r.Cluster = res.Cluster + + r.InternalIP = res.InternalIP + + r.ProxyUrl = res.ProxyUrl + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesGkeClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesGkeClusters *TargetAssociatedEntitiesGkeClusters = &TargetAssociatedEntitiesGkeClusters{empty: true} + +func (r *TargetAssociatedEntitiesGkeClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesGkeClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesGkeClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + +type TargetAssociatedEntitiesAnthosClusters struct { + empty bool `json:"-"` + Membership *string `json:"membership"` +} + +type jsonTargetAssociatedEntitiesAnthosClusters TargetAssociatedEntitiesAnthosClusters + +func (r *TargetAssociatedEntitiesAnthosClusters) UnmarshalJSON(data []byte) error { + var res jsonTargetAssociatedEntitiesAnthosClusters + if err := json.Unmarshal(data, &res); err != nil { + return err + } + + var m map[string]interface{} + json.Unmarshal(data, &m) + + if len(m) == 0 { + *r = *EmptyTargetAssociatedEntitiesAnthosClusters + } else { + + r.Membership = res.Membership + + } + return nil +} + +// This object is used to assert a desired state where this TargetAssociatedEntitiesAnthosClusters is +// empty. Go lacks global const objects, but this object should be treated +// as one. Modifying this object will have undesirable results. +var EmptyTargetAssociatedEntitiesAnthosClusters *TargetAssociatedEntitiesAnthosClusters = &TargetAssociatedEntitiesAnthosClusters{empty: true} + +func (r *TargetAssociatedEntitiesAnthosClusters) Empty() bool { + return r.empty +} + +func (r *TargetAssociatedEntitiesAnthosClusters) String() string { + return dcl.SprintResource(r) +} + +func (r *TargetAssociatedEntitiesAnthosClusters) HashCode() string { + // Placeholder for a more complex hash method that handles ordering, etc + // Hash resource body for easy comparison later + hash := sha256.Sum256([]byte(r.String())) + return fmt.Sprintf("%x", hash) +} + // Describe returns a simple description of this resource to ensure that automated tools // can identify it. func (r *Target) Describe() dcl.ServiceTypeVersion { @@ -391,25 +539,26 @@ func (r *Target) ID() (string, error) { } nr := r.urlNormalized() params := map[string]interface{}{ - "name": dcl.ValueOrEmptyString(nr.Name), - "target_id": dcl.ValueOrEmptyString(nr.TargetId), - "uid": dcl.ValueOrEmptyString(nr.Uid), - "description": dcl.ValueOrEmptyString(nr.Description), - "annotations": dcl.ValueOrEmptyString(nr.Annotations), - "labels": dcl.ValueOrEmptyString(nr.Labels), - "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), - "create_time": dcl.ValueOrEmptyString(nr.CreateTime), - "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), - "gke": dcl.ValueOrEmptyString(nr.Gke), - "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), - "etag": dcl.ValueOrEmptyString(nr.Etag), - "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "run": dcl.ValueOrEmptyString(nr.Run), - "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), - "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), - "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "name": dcl.ValueOrEmptyString(nr.Name), + "target_id": dcl.ValueOrEmptyString(nr.TargetId), + "uid": dcl.ValueOrEmptyString(nr.Uid), + "description": dcl.ValueOrEmptyString(nr.Description), + "annotations": dcl.ValueOrEmptyString(nr.Annotations), + "labels": dcl.ValueOrEmptyString(nr.Labels), + "require_approval": dcl.ValueOrEmptyString(nr.RequireApproval), + "create_time": dcl.ValueOrEmptyString(nr.CreateTime), + "update_time": dcl.ValueOrEmptyString(nr.UpdateTime), + "gke": dcl.ValueOrEmptyString(nr.Gke), + "anthos_cluster": dcl.ValueOrEmptyString(nr.AnthosCluster), + "etag": dcl.ValueOrEmptyString(nr.Etag), + "execution_configs": dcl.ValueOrEmptyString(nr.ExecutionConfigs), + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "run": dcl.ValueOrEmptyString(nr.Run), + "multi_target": dcl.ValueOrEmptyString(nr.MultiTarget), + "deploy_parameters": dcl.ValueOrEmptyString(nr.DeployParameters), + "custom_target": dcl.ValueOrEmptyString(nr.CustomTarget), + "associated_entities": dcl.ValueOrEmptyString(nr.AssociatedEntities), } return dcl.Nprintf("projects/{{project}}/locations/{{location}}/targets/{{name}}", params), nil } diff --git a/services/google/clouddeploy/target.yaml b/services/google/clouddeploy/target.yaml index a408c1642..6a30937ad 100755 --- a/services/google/clouddeploy/target.yaml +++ b/services/google/clouddeploy/target.yaml @@ -104,6 +104,75 @@ components: x-dcl-references: - resource: Gkehub/Membership field: selfLink + associatedEntities: + type: object + additionalProperties: + type: object + x-dcl-go-type: TargetAssociatedEntities + properties: + anthosClusters: + type: array + x-dcl-go-name: AnthosClusters + description: Optional. Information specifying Anthos clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters + properties: + membership: + type: string + x-dcl-go-name: Membership + description: Optional. Membership of the GKE Hub-registered + cluster to which to apply the Skaffold configuration. Format + is `projects/{project}/locations/{location}/memberships/{membership_name}`. + x-dcl-references: + - resource: Gkehub/Membership + field: selfLink + gkeClusters: + type: array + x-dcl-go-name: GkeClusters + description: Optional. Information specifying GKE clusters as associated + entities. + x-dcl-send-empty: true + x-dcl-list-type: list + items: + type: object + x-dcl-go-type: TargetAssociatedEntitiesGkeClusters + properties: + cluster: + type: string + x-dcl-go-name: Cluster + description: Optional. Information specifying a GKE Cluster. + Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`. + x-dcl-references: + - resource: Container/Cluster + field: selfLink + internalIP: + type: boolean + x-dcl-go-name: InternalIP + description: Optional. If true, `cluster` is accessed using + the private IP address of the control plane endpoint. Otherwise, + the default IP address of the control plane endpoint is used. + The default IP address is the private IP address for clusters + with private control-plane endpoints and the public IP address + otherwise. Only specify this option when `cluster` is a [private + GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept). + proxyUrl: + type: string + x-dcl-go-name: ProxyUrl + description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) + to the Kubernetes server. + x-dcl-go-name: AssociatedEntities + description: 'Optional. Map of entity IDs to their associated entities. + Associated entities allows specifying places other than the deployment + target for specific features. For example, the Gateway API canary can + be configured to deploy the HTTPRoute to a different cluster(s) than the + deployment cluster using associated entities. An entity ID must consist + of lower-case letters, numbers, and hyphens, start with a letter and end + with a letter or a number, and have a max length of 63 characters. In + other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.' createTime: type: string format: date-time diff --git a/services/google/clouddeploy/target_internal.go b/services/google/clouddeploy/target_internal.go index dc5d13c01..a18a7642f 100755 --- a/services/google/clouddeploy/target_internal.go +++ b/services/google/clouddeploy/target_internal.go @@ -99,6 +99,15 @@ func (r *TargetCustomTarget) validate() error { } return nil } +func (r *TargetAssociatedEntities) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesGkeClusters) validate() error { + return nil +} +func (r *TargetAssociatedEntitiesAnthosClusters) validate() error { + return nil +} func (r *Target) basePath() string { params := map[string]interface{}{} return dcl.Nprintf("https://clouddeploy.googleapis.com/v1/", params) @@ -224,6 +233,11 @@ func newUpdateTargetUpdateTargetRequest(ctx context.Context, f *Target, c *Clien } else if !dcl.IsEmptyValueIndirect(v) { req["customTarget"] = v } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + req["associatedEntities"] = v + } b, err := c.getTargetRaw(ctx, f) if err != nil { return nil, err @@ -665,6 +679,12 @@ func canonicalizeTargetDesiredState(rawDesired, rawInitial *Target, opts ...dcl. canonicalDesired.DeployParameters = rawDesired.DeployParameters } canonicalDesired.CustomTarget = canonicalizeTargetCustomTarget(rawDesired.CustomTarget, rawInitial.CustomTarget, opts...) + if dcl.IsZeroValue(rawDesired.AssociatedEntities) || (dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawInitial.AssociatedEntities)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + canonicalDesired.AssociatedEntities = rawInitial.AssociatedEntities + } else { + canonicalDesired.AssociatedEntities = rawDesired.AssociatedEntities + } if canonicalDesired.Gke != nil { // Check if anything else is set. @@ -813,6 +833,11 @@ func canonicalizeTargetNewState(c *Client, rawNew, rawDesired *Target) (*Target, rawNew.CustomTarget = canonicalizeNewTargetCustomTarget(c, rawDesired.CustomTarget, rawNew.CustomTarget) } + if dcl.IsEmptyValueIndirect(rawNew.AssociatedEntities) && dcl.IsEmptyValueIndirect(rawDesired.AssociatedEntities) { + rawNew.AssociatedEntities = rawDesired.AssociatedEntities + } else { + } + return rawNew, nil } @@ -1568,328 +1593,696 @@ func canonicalizeNewTargetCustomTargetSlice(c *Client, des, nw []TargetCustomTar return items } -// The differ returns a list of diffs, along with a list of operations that should be taken -// to remedy them. Right now, it does not attempt to consolidate operations - if several -// fields can be fixed with a patch update, it will perform the patch several times. -// Diffs on some fields will be ignored if the `desired` state has an empty (nil) -// value. This empty value indicates that the user does not care about the state for -// the field. Empty fields on the actual object will cause diffs. -// TODO(magic-modules-eng): for efficiency in some resources, add batching. -func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { - if desired == nil || actual == nil { - return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) +func canonicalizeTargetAssociatedEntities(des, initial *TargetAssociatedEntities, opts ...dcl.ApplyOption) *TargetAssociatedEntities { + if des == nil { + return initial } - - c.Config.Logger.Infof("Diff function called with desired state: %v", desired) - c.Config.Logger.Infof("Diff function called with actual state: %v", actual) - - var fn dcl.FieldName - var newDiffs []*dcl.FieldDiff - // New style diffs. - if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if des.empty { + return des } - if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) - } + cDes := &TargetAssociatedEntities{} - if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes.GkeClusters = canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des.GkeClusters, initial.GkeClusters, opts...) + cDes.AnthosClusters = canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des.AnthosClusters, initial.AnthosClusters, opts...) + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesSlice(des, initial []TargetAssociatedEntities, opts ...dcl.ApplyOption) []TargetAssociatedEntities { + if dcl.IsEmptyValueIndirect(des) { + return initial } - if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntities, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntities, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntities(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) +} + +func canonicalizeNewTargetAssociatedEntities(c *Client, des, nw *TargetAssociatedEntities) *TargetAssociatedEntities { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntities while comparing non-nil desired to nil actual. Returning desired object.") + return des } - newDiffs = append(newDiffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + nw.GkeClusters = canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c, des.GkeClusters, nw.GkeClusters) + nw.AnthosClusters = canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c, des.AnthosClusters, nw.AnthosClusters) + + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesSet(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntities + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - newDiffs = append(newDiffs, ds...) } + // Also include elements in nw that are not matched in des. + items = append(items, nw...) - if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeNewTargetAssociatedEntitiesSlice(c *Client, des, nw []TargetAssociatedEntities) []TargetAssociatedEntities { + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw } - if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + var items []TargetAssociatedEntities + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntities(c, &d, &n)) } - if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return items +} + +func canonicalizeTargetAssociatedEntitiesGkeClusters(des, initial *TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial + } + if des.empty { + return des } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + if initial == nil { + return des } - if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + cDes := &TargetAssociatedEntitiesGkeClusters{} + + if dcl.IsZeroValue(des.Cluster) || (dcl.IsEmptyValueIndirect(des.Cluster) && dcl.IsEmptyValueIndirect(initial.Cluster)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Cluster = initial.Cluster + } else { + cDes.Cluster = des.Cluster + } + if dcl.BoolCanonicalize(des.InternalIP, initial.InternalIP) || dcl.IsZeroValue(des.InternalIP) { + cDes.InternalIP = initial.InternalIP + } else { + cDes.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, initial.ProxyUrl) || dcl.IsZeroValue(des.ProxyUrl) { + cDes.ProxyUrl = initial.ProxyUrl + } else { + cDes.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - newDiffs = append(newDiffs, ds...) + return cDes +} + +func canonicalizeTargetAssociatedEntitiesGkeClustersSlice(des, initial []TargetAssociatedEntitiesGkeClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return initial } - if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - newDiffs = append(newDiffs, ds...) + return items } - if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesGkeClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - newDiffs = append(newDiffs, ds...) } + return items - if len(newDiffs) > 0 { - c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) - } - return newDiffs, nil } -func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff - desired, ok := d.(*TargetGke) - if !ok { - desiredNotPointer, ok := d.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) - } - desired = &desiredNotPointer - } - actual, ok := a.(*TargetGke) - if !ok { - actualNotPointer, ok := a.(TargetGke) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetGke", a) - } - actual = &actualNotPointer +func canonicalizeNewTargetAssociatedEntitiesGkeClusters(c *Client, des, nw *TargetAssociatedEntitiesGkeClusters) *TargetAssociatedEntitiesGkeClusters { + + if des == nil { + return nw } - if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesGkeClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err - } - diffs = append(diffs, ds...) + if dcl.BoolCanonicalize(des.InternalIP, nw.InternalIP) { + nw.InternalIP = des.InternalIP + } + if dcl.StringCanonicalize(des.ProxyUrl, nw.ProxyUrl) { + nw.ProxyUrl = des.ProxyUrl } - if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err + return nw +} + +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSet(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } + + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesGkeClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesGkeClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - diffs = append(diffs, ds...) } - return diffs, nil + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items } -func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesGkeClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesGkeClusters) []TargetAssociatedEntitiesGkeClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetAnthosCluster) - if !ok { - desiredNotPointer, ok := d.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesGkeClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesGkeClusters(c, &d, &n)) + } + + return items +} + +func canonicalizeTargetAssociatedEntitiesAnthosClusters(des, initial *TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) *TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + if des.empty { + return des + } + + if initial == nil { + return des + } + + cDes := &TargetAssociatedEntitiesAnthosClusters{} + + if dcl.IsZeroValue(des.Membership) || (dcl.IsEmptyValueIndirect(des.Membership) && dcl.IsEmptyValueIndirect(initial.Membership)) { + // Desired and initial values are equivalent, so set canonical desired value to initial value. + cDes.Membership = initial.Membership + } else { + cDes.Membership = des.Membership + } + + return cDes +} + +func canonicalizeTargetAssociatedEntitiesAnthosClustersSlice(des, initial []TargetAssociatedEntitiesAnthosClusters, opts ...dcl.ApplyOption) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return initial + } + + if len(des) != len(initial) { + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for _, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, nil, opts...) + if cd != nil { + items = append(items, *cd) + } } - desired = &desiredNotPointer + return items } - actual, ok := a.(*TargetAnthosCluster) - if !ok { - actualNotPointer, ok := a.(TargetAnthosCluster) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(des)) + for i, d := range des { + cd := canonicalizeTargetAssociatedEntitiesAnthosClusters(&d, &initial[i], opts...) + if cd != nil { + items = append(items, *cd) } - actual = &actualNotPointer } + return items - if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { - if err != nil { - return nil, err +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c *Client, des, nw *TargetAssociatedEntitiesAnthosClusters) *TargetAssociatedEntitiesAnthosClusters { + + if des == nil { + return nw + } + + if nw == nil { + if dcl.IsEmptyValueIndirect(des) { + c.Config.Logger.Info("Found explicitly empty value for TargetAssociatedEntitiesAnthosClusters while comparing non-nil desired to nil actual. Returning desired object.") + return des } - diffs = append(diffs, ds...) + return nil } - return diffs, nil + + return nw } -func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSet(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } - desired, ok := d.(*TargetExecutionConfigs) - if !ok { - desiredNotPointer, ok := d.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + // Find the elements in des that are also in nw and canonicalize them. Remove matched elements from nw. + var items []TargetAssociatedEntitiesAnthosClusters + for _, d := range des { + matchedIndex := -1 + for i, n := range nw { + if diffs, _ := compareTargetAssociatedEntitiesAnthosClustersNewStyle(&d, &n, dcl.FieldName{}); len(diffs) == 0 { + matchedIndex = i + break + } + } + if matchedIndex != -1 { + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &nw[matchedIndex])) + nw = append(nw[:matchedIndex], nw[matchedIndex+1:]...) } - desired = &desiredNotPointer } - actual, ok := a.(*TargetExecutionConfigs) - if !ok { - actualNotPointer, ok := a.(TargetExecutionConfigs) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + // Also include elements in nw that are not matched in des. + items = append(items, nw...) + + return items +} + +func canonicalizeNewTargetAssociatedEntitiesAnthosClustersSlice(c *Client, des, nw []TargetAssociatedEntitiesAnthosClusters) []TargetAssociatedEntitiesAnthosClusters { + if des == nil { + return nw + } + + // Lengths are unequal. A diff will occur later, so we shouldn't canonicalize. + // Return the original array. + if len(des) != len(nw) { + return nw + } + + var items []TargetAssociatedEntitiesAnthosClusters + for i, d := range des { + n := nw[i] + items = append(items, *canonicalizeNewTargetAssociatedEntitiesAnthosClusters(c, &d, &n)) + } + + return items +} + +// The differ returns a list of diffs, along with a list of operations that should be taken +// to remedy them. Right now, it does not attempt to consolidate operations - if several +// fields can be fixed with a patch update, it will perform the patch several times. +// Diffs on some fields will be ignored if the `desired` state has an empty (nil) +// value. This empty value indicates that the user does not care about the state for +// the field. Empty fields on the actual object will cause diffs. +// TODO(magic-modules-eng): for efficiency in some resources, add batching. +func diffTarget(c *Client, desired, actual *Target, opts ...dcl.ApplyOption) ([]*dcl.FieldDiff, error) { + if desired == nil || actual == nil { + return nil, fmt.Errorf("nil resource passed to diff - always a programming error: %#v, %#v", desired, actual) + } + + c.Config.Logger.Infof("Diff function called with desired state: %v", desired) + c.Config.Logger.Infof("Diff function called with actual state: %v", actual) + + var fn dcl.FieldName + var newDiffs []*dcl.FieldDiff + // New style diffs. + if ds, err := dcl.Diff(desired.Name, actual.Name, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Name")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.TargetId, actual.TargetId, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("TargetId")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Uid, actual.Uid, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Uid")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Description, actual.Description, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Description")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Annotations, actual.Annotations, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Annotations")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.Labels, actual.Labels, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Labels")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.RequireApproval, actual.RequireApproval, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("RequireApproval")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { - var diffs []*dcl.FieldDiff + if ds, err := dcl.Diff(desired.CreateTime, actual.CreateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("CreateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } - desired, ok := d.(*TargetRun) - if !ok { - desiredNotPointer, ok := d.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + if ds, err := dcl.Diff(desired.UpdateTime, actual.UpdateTime, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("UpdateTime")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - desired = &desiredNotPointer + newDiffs = append(newDiffs, ds...) } - actual, ok := a.(*TargetRun) - if !ok { - actualNotPointer, ok := a.(TargetRun) - if !ok { - return nil, fmt.Errorf("obj %v is not a TargetRun", a) + + if ds, err := dcl.Diff(desired.Gke, actual.Gke, dcl.DiffInfo{ObjectFunction: compareTargetGkeNewStyle, EmptyObject: EmptyTargetGke, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Gke")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err } - actual = &actualNotPointer + newDiffs = append(newDiffs, ds...) } - if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.AnthosCluster, actual.AnthosCluster, dcl.DiffInfo{ObjectFunction: compareTargetAnthosClusterNewStyle, EmptyObject: EmptyTargetAnthosCluster, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosCluster")); len(ds) != 0 || err != nil { if err != nil { return nil, err } - diffs = append(diffs, ds...) + newDiffs = append(newDiffs, ds...) } - return diffs, nil -} -func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + if ds, err := dcl.Diff(desired.Etag, actual.Etag, dcl.DiffInfo{OutputOnly: true, OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Etag")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionConfigs, actual.ExecutionConfigs, dcl.DiffInfo{ServerDefault: true, ObjectFunction: compareTargetExecutionConfigsNewStyle, EmptyObject: EmptyTargetExecutionConfigs, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionConfigs")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Project, actual.Project, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Project")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.Run, actual.Run, dcl.DiffInfo{ObjectFunction: compareTargetRunNewStyle, EmptyObject: EmptyTargetRun, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Run")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.MultiTarget, actual.MultiTarget, dcl.DiffInfo{ObjectFunction: compareTargetMultiTargetNewStyle, EmptyObject: EmptyTargetMultiTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("MultiTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.DeployParameters, actual.DeployParameters, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("DeployParameters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.CustomTarget, actual.CustomTarget, dcl.DiffInfo{ObjectFunction: compareTargetCustomTargetNewStyle, EmptyObject: EmptyTargetCustomTarget, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTarget")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if ds, err := dcl.Diff(desired.AssociatedEntities, actual.AssociatedEntities, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesNewStyle, EmptyObject: EmptyTargetAssociatedEntities, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AssociatedEntities")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + newDiffs = append(newDiffs, ds...) + } + + if len(newDiffs) > 0 { + c.Config.Logger.Infof("Diff function found diffs: %v", newDiffs) + } + return newDiffs, nil +} +func compareTargetGkeNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetGke) + if !ok { + desiredNotPointer, ok := d.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke or *TargetGke", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetGke) + if !ok { + actualNotPointer, ok := a.(TargetGke) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetGke", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAnthosClusterNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAnthosCluster) + if !ok { + desiredNotPointer, ok := d.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster or *TargetAnthosCluster", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAnthosCluster) + if !ok { + actualNotPointer, ok := a.(TargetAnthosCluster) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAnthosCluster", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetExecutionConfigsNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetExecutionConfigs) + if !ok { + desiredNotPointer, ok := d.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs or *TargetExecutionConfigs", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetExecutionConfigs) + if !ok { + actualNotPointer, ok := a.(TargetExecutionConfigs) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetExecutionConfigs", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Usages, actual.Usages, dcl.DiffInfo{Type: "EnumType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Usages")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.WorkerPool, actual.WorkerPool, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("WorkerPool")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ServiceAccount, actual.ServiceAccount, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ServiceAccount")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ArtifactStorage, actual.ArtifactStorage, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ArtifactStorage")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ExecutionTimeout, actual.ExecutionTimeout, dcl.DiffInfo{ServerDefault: true, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ExecutionTimeout")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.Verbose, actual.Verbose, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Verbose")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetRunNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetRun) + if !ok { + desiredNotPointer, ok := d.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun or *TargetRun", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetRun) + if !ok { + actualNotPointer, ok := a.(TargetRun) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetRun", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Location, actual.Location, dcl.DiffInfo{OperationSelector: dcl.RequiresRecreate()}, fn.AddNest("Location")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetMultiTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { var diffs []*dcl.FieldDiff desired, ok := d.(*TargetMultiTarget) @@ -1938,189 +2331,673 @@ func compareTargetCustomTargetNewStyle(d, a interface{}, fn dcl.FieldName) ([]*d actual = &actualNotPointer } - if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if ds, err := dcl.Diff(desired.CustomTargetType, actual.CustomTargetType, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("CustomTargetType")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntities) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities or *TargetAssociatedEntities", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntities) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntities) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntities", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.GkeClusters, actual.GkeClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesGkeClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesGkeClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("GkeClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.AnthosClusters, actual.AnthosClusters, dcl.DiffInfo{ObjectFunction: compareTargetAssociatedEntitiesAnthosClustersNewStyle, EmptyObject: EmptyTargetAssociatedEntitiesAnthosClusters, OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("AnthosClusters")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesGkeClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters or *TargetAssociatedEntitiesGkeClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesGkeClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesGkeClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesGkeClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Cluster, actual.Cluster, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Cluster")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.InternalIP, actual.InternalIP, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("InternalIp")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + + if ds, err := dcl.Diff(desired.ProxyUrl, actual.ProxyUrl, dcl.DiffInfo{OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("ProxyUrl")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +func compareTargetAssociatedEntitiesAnthosClustersNewStyle(d, a interface{}, fn dcl.FieldName) ([]*dcl.FieldDiff, error) { + var diffs []*dcl.FieldDiff + + desired, ok := d.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + desiredNotPointer, ok := d.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters or *TargetAssociatedEntitiesAnthosClusters", d) + } + desired = &desiredNotPointer + } + actual, ok := a.(*TargetAssociatedEntitiesAnthosClusters) + if !ok { + actualNotPointer, ok := a.(TargetAssociatedEntitiesAnthosClusters) + if !ok { + return nil, fmt.Errorf("obj %v is not a TargetAssociatedEntitiesAnthosClusters", a) + } + actual = &actualNotPointer + } + + if ds, err := dcl.Diff(desired.Membership, actual.Membership, dcl.DiffInfo{Type: "ReferenceType", OperationSelector: dcl.TriggersOperation("updateTargetUpdateTargetOperation")}, fn.AddNest("Membership")); len(ds) != 0 || err != nil { + if err != nil { + return nil, err + } + diffs = append(diffs, ds...) + } + return diffs, nil +} + +// urlNormalized returns a copy of the resource struct with values normalized +// for URL substitutions. For instance, it converts long-form self-links to +// short-form so they can be substituted in. +func (r *Target) urlNormalized() *Target { + normalized := dcl.Copy(*r).(Target) + normalized.Name = dcl.SelfLinkToName(r.Name) + normalized.TargetId = dcl.SelfLinkToName(r.TargetId) + normalized.Uid = dcl.SelfLinkToName(r.Uid) + normalized.Description = dcl.SelfLinkToName(r.Description) + normalized.Etag = dcl.SelfLinkToName(r.Etag) + normalized.Project = dcl.SelfLinkToName(r.Project) + normalized.Location = dcl.SelfLinkToName(r.Location) + return &normalized +} + +func (r *Target) updateURL(userBasePath, updateName string) (string, error) { + nr := r.urlNormalized() + if updateName == "UpdateTarget" { + fields := map[string]interface{}{ + "project": dcl.ValueOrEmptyString(nr.Project), + "location": dcl.ValueOrEmptyString(nr.Location), + "name": dcl.ValueOrEmptyString(nr.Name), + } + return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil + + } + + return "", fmt.Errorf("unknown update name: %s", updateName) +} + +// marshal encodes the Target resource into JSON for a Create request, and +// performs transformations from the resource schema to the API schema if +// necessary. +func (r *Target) marshal(c *Client) ([]byte, error) { + m, err := expandTarget(c, r) + if err != nil { + return nil, fmt.Errorf("error marshalling Target: %w", err) + } + + return json.Marshal(m) +} + +// unmarshalTarget decodes JSON responses into the Target resource schema. +func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { + var m map[string]interface{} + if err := json.Unmarshal(b, &m); err != nil { + return nil, err + } + return unmarshalMapTarget(m, c, res) +} + +func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + + flattened := flattenTarget(c, m, res) + if flattened == nil { + return nil, fmt.Errorf("attempted to flatten empty json object") + } + return flattened, nil +} + +// expandTarget expands Target into a JSON request object. +func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { + m := make(map[string]interface{}) + res := f + _ = res + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Name into name: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["name"] = v + } + if v := f.Description; dcl.ValueShouldBeSent(v) { + m["description"] = v + } + if v := f.Annotations; dcl.ValueShouldBeSent(v) { + m["annotations"] = v + } + if v := f.Labels; dcl.ValueShouldBeSent(v) { + m["labels"] = v + } + if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { + m["requireApproval"] = v + } + if v, err := expandTargetGke(c, f.Gke, res); err != nil { + return nil, fmt.Errorf("error expanding Gke into gke: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["gke"] = v + } + if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["anthosCluster"] = v + } + if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { + return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) + } else if v != nil { + m["executionConfigs"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Project into project: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["project"] = v + } + if v, err := dcl.EmptyValue(); err != nil { + return nil, fmt.Errorf("error expanding Location into location: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["location"] = v + } + if v, err := expandTargetRun(c, f.Run, res); err != nil { + return nil, fmt.Errorf("error expanding Run into run: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["run"] = v + } + if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { + return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["multiTarget"] = v + } + if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { + m["deployParameters"] = v + } + if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { + return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["customTarget"] = v + } + if v, err := expandTargetAssociatedEntitiesMap(c, f.AssociatedEntities, res); err != nil { + return nil, fmt.Errorf("error expanding AssociatedEntities into associatedEntities: %w", err) + } else if !dcl.IsEmptyValueIndirect(v) { + m["associatedEntities"] = v + } + + return m, nil +} + +// flattenTarget flattens Target from a JSON request object into the +// Target type. +func flattenTarget(c *Client, i interface{}, res *Target) *Target { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + if len(m) == 0 { + return nil + } + + resultRes := &Target{} + resultRes.Name = dcl.FlattenString(m["name"]) + resultRes.TargetId = dcl.FlattenString(m["targetId"]) + resultRes.Uid = dcl.FlattenString(m["uid"]) + resultRes.Description = dcl.FlattenString(m["description"]) + resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) + resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) + resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) + resultRes.CreateTime = dcl.FlattenString(m["createTime"]) + resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) + resultRes.Gke = flattenTargetGke(c, m["gke"], res) + resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) + resultRes.Etag = dcl.FlattenString(m["etag"]) + resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) + resultRes.Project = dcl.FlattenString(m["project"]) + resultRes.Location = dcl.FlattenString(m["location"]) + resultRes.Run = flattenTargetRun(c, m["run"], res) + resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) + resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) + resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + resultRes.AssociatedEntities = flattenTargetAssociatedEntitiesMap(c, m["associatedEntities"], res) + + return resultRes +} + +// expandTargetGkeMap expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// request object. +func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetGke(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetGke{} + } + + if len(a) == 0 { + return map[string]TargetGke{} + } + + items := make(map[string]TargetGke) + for k, item := range a { + items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// response object. +func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { + a, ok := i.([]interface{}) + if !ok { + return []TargetGke{} + } + + if len(a) == 0 { + return []TargetGke{} + } + + items := make([]TargetGke, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetGke expands an instance of TargetGke into a JSON +// request object. +func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v + } + + return m, nil +} + +// flattenTargetGke flattens an instance of TargetGke from a JSON +// response object. +func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetGke{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetGke + } + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + + return r +} + +// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetAnthosCluster(c, &item, res) + if err != nil { + return nil, err + } + + items = append(items, i) + } + + return items, nil +} + +// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetAnthosCluster{} + } + + if len(a) == 0 { + return map[string]TargetAnthosCluster{} + } + + items := make(map[string]TargetAnthosCluster) + for k, item := range a { + items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + } + + return items +} + +// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { + a, ok := i.([]interface{}) + if !ok { + return []TargetAnthosCluster{} + } + + if len(a) == 0 { + return []TargetAnthosCluster{} + } + + items := make([]TargetAnthosCluster, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + } + + return items +} + +// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// request object. +func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { + return nil, nil + } + + m := make(map[string]interface{}) + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v + } + + return m, nil +} + +// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// response object. +func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { + m, ok := i.(map[string]interface{}) + if !ok { + return nil + } + + r := &TargetAnthosCluster{} + + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetAnthosCluster + } + r.Membership = dcl.FlattenString(m["membership"]) + + return r +} + +// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := make(map[string]interface{}) + for k, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) + if err != nil { + return nil, err + } + if i != nil { + items[k] = i + } + } + + return items, nil +} + +// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { + if f == nil { + return nil, nil + } + + items := []map[string]interface{}{} + for _, item := range f { + i, err := expandTargetExecutionConfigs(c, &item, res) if err != nil { return nil, err } - diffs = append(diffs, ds...) + + items = append(items, i) } - return diffs, nil -} -// urlNormalized returns a copy of the resource struct with values normalized -// for URL substitutions. For instance, it converts long-form self-links to -// short-form so they can be substituted in. -func (r *Target) urlNormalized() *Target { - normalized := dcl.Copy(*r).(Target) - normalized.Name = dcl.SelfLinkToName(r.Name) - normalized.TargetId = dcl.SelfLinkToName(r.TargetId) - normalized.Uid = dcl.SelfLinkToName(r.Uid) - normalized.Description = dcl.SelfLinkToName(r.Description) - normalized.Etag = dcl.SelfLinkToName(r.Etag) - normalized.Project = dcl.SelfLinkToName(r.Project) - normalized.Location = dcl.SelfLinkToName(r.Location) - return &normalized + return items, nil } -func (r *Target) updateURL(userBasePath, updateName string) (string, error) { - nr := r.urlNormalized() - if updateName == "UpdateTarget" { - fields := map[string]interface{}{ - "project": dcl.ValueOrEmptyString(nr.Project), - "location": dcl.ValueOrEmptyString(nr.Location), - "name": dcl.ValueOrEmptyString(nr.Name), - } - return dcl.URL("projects/{{project}}/locations/{{location}}/targets/{{name}}", nr.basePath(), userBasePath, fields), nil - +// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { + a, ok := i.(map[string]interface{}) + if !ok { + return map[string]TargetExecutionConfigs{} } - return "", fmt.Errorf("unknown update name: %s", updateName) -} + if len(a) == 0 { + return map[string]TargetExecutionConfigs{} + } -// marshal encodes the Target resource into JSON for a Create request, and -// performs transformations from the resource schema to the API schema if -// necessary. -func (r *Target) marshal(c *Client) ([]byte, error) { - m, err := expandTarget(c, r) - if err != nil { - return nil, fmt.Errorf("error marshalling Target: %w", err) + items := make(map[string]TargetExecutionConfigs) + for k, item := range a { + items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) } - return json.Marshal(m) + return items } -// unmarshalTarget decodes JSON responses into the Target resource schema. -func unmarshalTarget(b []byte, c *Client, res *Target) (*Target, error) { - var m map[string]interface{} - if err := json.Unmarshal(b, &m); err != nil { - return nil, err +// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { + a, ok := i.([]interface{}) + if !ok { + return []TargetExecutionConfigs{} } - return unmarshalMapTarget(m, c, res) -} -func unmarshalMapTarget(m map[string]interface{}, c *Client, res *Target) (*Target, error) { + if len(a) == 0 { + return []TargetExecutionConfigs{} + } - flattened := flattenTarget(c, m, res) - if flattened == nil { - return nil, fmt.Errorf("attempted to flatten empty json object") + items := make([]TargetExecutionConfigs, 0, len(a)) + for _, item := range a { + items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) } - return flattened, nil + + return items } -// expandTarget expands Target into a JSON request object. -func expandTarget(c *Client, f *Target) (map[string]interface{}, error) { - m := make(map[string]interface{}) - res := f - _ = res - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Name into name: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["name"] = v - } - if v := f.Description; dcl.ValueShouldBeSent(v) { - m["description"] = v - } - if v := f.Annotations; dcl.ValueShouldBeSent(v) { - m["annotations"] = v - } - if v := f.Labels; dcl.ValueShouldBeSent(v) { - m["labels"] = v - } - if v := f.RequireApproval; dcl.ValueShouldBeSent(v) { - m["requireApproval"] = v - } - if v, err := expandTargetGke(c, f.Gke, res); err != nil { - return nil, fmt.Errorf("error expanding Gke into gke: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["gke"] = v - } - if v, err := expandTargetAnthosCluster(c, f.AnthosCluster, res); err != nil { - return nil, fmt.Errorf("error expanding AnthosCluster into anthosCluster: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["anthosCluster"] = v - } - if v, err := expandTargetExecutionConfigsSlice(c, f.ExecutionConfigs, res); err != nil { - return nil, fmt.Errorf("error expanding ExecutionConfigs into executionConfigs: %w", err) - } else if v != nil { - m["executionConfigs"] = v +// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// request object. +func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { + if f == nil { + return nil, nil } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Project into project: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["project"] = v + + m := make(map[string]interface{}) + if v := f.Usages; v != nil { + m["usages"] = v } - if v, err := dcl.EmptyValue(); err != nil { - return nil, fmt.Errorf("error expanding Location into location: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { + m["workerPool"] = v } - if v, err := expandTargetRun(c, f.Run, res); err != nil { - return nil, fmt.Errorf("error expanding Run into run: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["run"] = v + if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { + m["serviceAccount"] = v } - if v, err := expandTargetMultiTarget(c, f.MultiTarget, res); err != nil { - return nil, fmt.Errorf("error expanding MultiTarget into multiTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["multiTarget"] = v + if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { + m["artifactStorage"] = v } - if v := f.DeployParameters; dcl.ValueShouldBeSent(v) { - m["deployParameters"] = v + if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { + m["executionTimeout"] = v } - if v, err := expandTargetCustomTarget(c, f.CustomTarget, res); err != nil { - return nil, fmt.Errorf("error expanding CustomTarget into customTarget: %w", err) - } else if !dcl.IsEmptyValueIndirect(v) { - m["customTarget"] = v + if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { + m["verbose"] = v } return m, nil } -// flattenTarget flattens Target from a JSON request object into the -// Target type. -func flattenTarget(c *Client, i interface{}, res *Target) *Target { +// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// response object. +func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { m, ok := i.(map[string]interface{}) if !ok { return nil } - if len(m) == 0 { - return nil - } - resultRes := &Target{} - resultRes.Name = dcl.FlattenString(m["name"]) - resultRes.TargetId = dcl.FlattenString(m["targetId"]) - resultRes.Uid = dcl.FlattenString(m["uid"]) - resultRes.Description = dcl.FlattenString(m["description"]) - resultRes.Annotations = dcl.FlattenKeyValuePairs(m["annotations"]) - resultRes.Labels = dcl.FlattenKeyValuePairs(m["labels"]) - resultRes.RequireApproval = dcl.FlattenBool(m["requireApproval"]) - resultRes.CreateTime = dcl.FlattenString(m["createTime"]) - resultRes.UpdateTime = dcl.FlattenString(m["updateTime"]) - resultRes.Gke = flattenTargetGke(c, m["gke"], res) - resultRes.AnthosCluster = flattenTargetAnthosCluster(c, m["anthosCluster"], res) - resultRes.Etag = dcl.FlattenString(m["etag"]) - resultRes.ExecutionConfigs = flattenTargetExecutionConfigsSlice(c, m["executionConfigs"], res) - resultRes.Project = dcl.FlattenString(m["project"]) - resultRes.Location = dcl.FlattenString(m["location"]) - resultRes.Run = flattenTargetRun(c, m["run"], res) - resultRes.MultiTarget = flattenTargetMultiTarget(c, m["multiTarget"], res) - resultRes.DeployParameters = dcl.FlattenKeyValuePairs(m["deployParameters"]) - resultRes.CustomTarget = flattenTargetCustomTarget(c, m["customTarget"], res) + r := &TargetExecutionConfigs{} - return resultRes + if dcl.IsEmptyValueIndirect(i) { + return EmptyTargetExecutionConfigs + } + r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) + r.WorkerPool = dcl.FlattenString(m["workerPool"]) + r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) + r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) + r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) + r.Verbose = dcl.FlattenBool(m["verbose"]) + + return r } -// expandTargetGkeMap expands the contents of TargetGke into a JSON +// expandTargetRunMap expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2132,16 +3009,16 @@ func expandTargetGkeMap(c *Client, f map[string]TargetGke, res *Target) (map[str return items, nil } -// expandTargetGkeSlice expands the contents of TargetGke into a JSON +// expandTargetRunSlice expands the contents of TargetRun into a JSON // request object. -func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]interface{}, error) { +func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetGke(c, &item, res) + i, err := expandTargetRun(c, &item, res) if err != nil { return nil, err } @@ -2152,97 +3029,89 @@ func expandTargetGkeSlice(c *Client, f []TargetGke, res *Target) ([]map[string]i return items, nil } -// flattenTargetGkeMap flattens the contents of TargetGke from a JSON +// flattenTargetRunMap flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeMap(c *Client, i interface{}, res *Target) map[string]TargetGke { +func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetGke{} + return map[string]TargetRun{} } if len(a) == 0 { - return map[string]TargetGke{} + return map[string]TargetRun{} } - items := make(map[string]TargetGke) + items := make(map[string]TargetRun) for k, item := range a { - items[k] = *flattenTargetGke(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) } return items } -// flattenTargetGkeSlice flattens the contents of TargetGke from a JSON +// flattenTargetRunSlice flattens the contents of TargetRun from a JSON // response object. -func flattenTargetGkeSlice(c *Client, i interface{}, res *Target) []TargetGke { +func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { a, ok := i.([]interface{}) if !ok { - return []TargetGke{} + return []TargetRun{} } if len(a) == 0 { - return []TargetGke{} + return []TargetRun{} } - items := make([]TargetGke, 0, len(a)) + items := make([]TargetRun, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetGke(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) } return items } -// expandTargetGke expands an instance of TargetGke into a JSON +// expandTargetRun expands an instance of TargetRun into a JSON // request object. -func expandTargetGke(c *Client, f *TargetGke, res *Target) (map[string]interface{}, error) { +func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { - m["cluster"] = v - } - if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { - m["internalIp"] = v - } - if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { - m["proxyUrl"] = v + if v := f.Location; !dcl.IsEmptyValueIndirect(v) { + m["location"] = v } return m, nil } -// flattenTargetGke flattens an instance of TargetGke from a JSON +// flattenTargetRun flattens an instance of TargetRun from a JSON // response object. -func flattenTargetGke(c *Client, i interface{}, res *Target) *TargetGke { +func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetGke{} + r := &TargetRun{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetGke + return EmptyTargetRun } - r.Cluster = dcl.FlattenString(m["cluster"]) - r.InternalIP = dcl.FlattenBool(m["internalIp"]) - r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) + r.Location = dcl.FlattenString(m["location"]) return r } -// expandTargetAnthosClusterMap expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2254,16 +3123,16 @@ func expandTargetAnthosClusterMap(c *Client, f map[string]TargetAnthosCluster, r return items, nil } -// expandTargetAnthosClusterSlice expands the contents of TargetAnthosCluster into a JSON +// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Target) ([]map[string]interface{}, error) { +func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetAnthosCluster(c, &item, res) + i, err := expandTargetMultiTarget(c, &item, res) if err != nil { return nil, err } @@ -2274,89 +3143,89 @@ func expandTargetAnthosClusterSlice(c *Client, f []TargetAnthosCluster, res *Tar return items, nil } -// flattenTargetAnthosClusterMap flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterMap(c *Client, i interface{}, res *Target) map[string]TargetAnthosCluster { +func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } if len(a) == 0 { - return map[string]TargetAnthosCluster{} + return map[string]TargetMultiTarget{} } - items := make(map[string]TargetAnthosCluster) + items := make(map[string]TargetMultiTarget) for k, item := range a { - items[k] = *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetAnthosClusterSlice flattens the contents of TargetAnthosCluster from a JSON +// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosClusterSlice(c *Client, i interface{}, res *Target) []TargetAnthosCluster { +func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { a, ok := i.([]interface{}) if !ok { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } if len(a) == 0 { - return []TargetAnthosCluster{} + return []TargetMultiTarget{} } - items := make([]TargetAnthosCluster, 0, len(a)) + items := make([]TargetMultiTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetAnthosCluster(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetAnthosCluster expands an instance of TargetAnthosCluster into a JSON +// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON // request object. -func expandTargetAnthosCluster(c *Client, f *TargetAnthosCluster, res *Target) (map[string]interface{}, error) { +func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { - m["membership"] = v + if v := f.TargetIds; v != nil { + m["targetIds"] = v } return m, nil } -// flattenTargetAnthosCluster flattens an instance of TargetAnthosCluster from a JSON +// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON // response object. -func flattenTargetAnthosCluster(c *Client, i interface{}, res *Target) *TargetAnthosCluster { +func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetAnthosCluster{} + r := &TargetMultiTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetAnthosCluster + return EmptyTargetMultiTarget } - r.Membership = dcl.FlattenString(m["membership"]) + r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) return r } -// expandTargetExecutionConfigsMap expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { +func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2368,16 +3237,16 @@ func expandTargetExecutionConfigsMap(c *Client, f map[string]TargetExecutionConf return items, nil } -// expandTargetExecutionConfigsSlice expands the contents of TargetExecutionConfigs into a JSON +// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, res *Target) ([]map[string]interface{}, error) { +func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetExecutionConfigs(c, &item, res) + i, err := expandTargetCustomTarget(c, &item, res) if err != nil { return nil, err } @@ -2388,109 +3257,89 @@ func expandTargetExecutionConfigsSlice(c *Client, f []TargetExecutionConfigs, re return items, nil } -// flattenTargetExecutionConfigsMap flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsMap(c *Client, i interface{}, res *Target) map[string]TargetExecutionConfigs { +func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } if len(a) == 0 { - return map[string]TargetExecutionConfigs{} + return map[string]TargetCustomTarget{} } - items := make(map[string]TargetExecutionConfigs) + items := make(map[string]TargetCustomTarget) for k, item := range a { - items[k] = *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) } return items } -// flattenTargetExecutionConfigsSlice flattens the contents of TargetExecutionConfigs from a JSON +// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigsSlice(c *Client, i interface{}, res *Target) []TargetExecutionConfigs { +func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { a, ok := i.([]interface{}) if !ok { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } if len(a) == 0 { - return []TargetExecutionConfigs{} + return []TargetCustomTarget{} } - items := make([]TargetExecutionConfigs, 0, len(a)) + items := make([]TargetCustomTarget, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetExecutionConfigs(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) } return items } -// expandTargetExecutionConfigs expands an instance of TargetExecutionConfigs into a JSON +// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON // request object. -func expandTargetExecutionConfigs(c *Client, f *TargetExecutionConfigs, res *Target) (map[string]interface{}, error) { - if f == nil { +func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { + if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Usages; v != nil { - m["usages"] = v - } - if v := f.WorkerPool; !dcl.IsEmptyValueIndirect(v) { - m["workerPool"] = v - } - if v := f.ServiceAccount; !dcl.IsEmptyValueIndirect(v) { - m["serviceAccount"] = v - } - if v := f.ArtifactStorage; !dcl.IsEmptyValueIndirect(v) { - m["artifactStorage"] = v - } - if v := f.ExecutionTimeout; !dcl.IsEmptyValueIndirect(v) { - m["executionTimeout"] = v - } - if v := f.Verbose; !dcl.IsEmptyValueIndirect(v) { - m["verbose"] = v + if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { + m["customTargetType"] = v } return m, nil } -// flattenTargetExecutionConfigs flattens an instance of TargetExecutionConfigs from a JSON +// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON // response object. -func flattenTargetExecutionConfigs(c *Client, i interface{}, res *Target) *TargetExecutionConfigs { +func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetExecutionConfigs{} + r := &TargetCustomTarget{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetExecutionConfigs + return EmptyTargetCustomTarget } - r.Usages = flattenTargetExecutionConfigsUsagesEnumSlice(c, m["usages"], res) - r.WorkerPool = dcl.FlattenString(m["workerPool"]) - r.ServiceAccount = dcl.FlattenString(m["serviceAccount"]) - r.ArtifactStorage = dcl.FlattenString(m["artifactStorage"]) - r.ExecutionTimeout = dcl.FlattenString(m["executionTimeout"]) - r.Verbose = dcl.FlattenBool(m["verbose"]) + r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) return r } -// expandTargetRunMap expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesMap expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesMap(c *Client, f map[string]TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2502,16 +3351,16 @@ func expandTargetRunMap(c *Client, f map[string]TargetRun, res *Target) (map[str return items, nil } -// expandTargetRunSlice expands the contents of TargetRun into a JSON +// expandTargetAssociatedEntitiesSlice expands the contents of TargetAssociatedEntities into a JSON // request object. -func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesSlice(c *Client, f []TargetAssociatedEntities, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetRun(c, &item, res) + i, err := expandTargetAssociatedEntities(c, &item, res) if err != nil { return nil, err } @@ -2522,89 +3371,97 @@ func expandTargetRunSlice(c *Client, f []TargetRun, res *Target) ([]map[string]i return items, nil } -// flattenTargetRunMap flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesMap flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunMap(c *Client, i interface{}, res *Target) map[string]TargetRun { +func flattenTargetAssociatedEntitiesMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntities { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } if len(a) == 0 { - return map[string]TargetRun{} + return map[string]TargetAssociatedEntities{} } - items := make(map[string]TargetRun) + items := make(map[string]TargetAssociatedEntities) for k, item := range a { - items[k] = *flattenTargetRun(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res) } return items } -// flattenTargetRunSlice flattens the contents of TargetRun from a JSON +// flattenTargetAssociatedEntitiesSlice flattens the contents of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRunSlice(c *Client, i interface{}, res *Target) []TargetRun { +func flattenTargetAssociatedEntitiesSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntities { a, ok := i.([]interface{}) if !ok { - return []TargetRun{} + return []TargetAssociatedEntities{} } if len(a) == 0 { - return []TargetRun{} + return []TargetAssociatedEntities{} } - items := make([]TargetRun, 0, len(a)) + items := make([]TargetAssociatedEntities, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetRun(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntities(c, item.(map[string]interface{}), res)) } return items } -// expandTargetRun expands an instance of TargetRun into a JSON +// expandTargetAssociatedEntities expands an instance of TargetAssociatedEntities into a JSON // request object. -func expandTargetRun(c *Client, f *TargetRun, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntities(c *Client, f *TargetAssociatedEntities, res *Target) (map[string]interface{}, error) { if dcl.IsEmptyValueIndirect(f) { return nil, nil } m := make(map[string]interface{}) - if v := f.Location; !dcl.IsEmptyValueIndirect(v) { - m["location"] = v + if v, err := expandTargetAssociatedEntitiesGkeClustersSlice(c, f.GkeClusters, res); err != nil { + return nil, fmt.Errorf("error expanding GkeClusters into gkeClusters: %w", err) + } else if v != nil { + m["gkeClusters"] = v + } + if v, err := expandTargetAssociatedEntitiesAnthosClustersSlice(c, f.AnthosClusters, res); err != nil { + return nil, fmt.Errorf("error expanding AnthosClusters into anthosClusters: %w", err) + } else if v != nil { + m["anthosClusters"] = v } return m, nil } -// flattenTargetRun flattens an instance of TargetRun from a JSON +// flattenTargetAssociatedEntities flattens an instance of TargetAssociatedEntities from a JSON // response object. -func flattenTargetRun(c *Client, i interface{}, res *Target) *TargetRun { +func flattenTargetAssociatedEntities(c *Client, i interface{}, res *Target) *TargetAssociatedEntities { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetRun{} + r := &TargetAssociatedEntities{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetRun + return EmptyTargetAssociatedEntities } - r.Location = dcl.FlattenString(m["location"]) + r.GkeClusters = flattenTargetAssociatedEntitiesGkeClustersSlice(c, m["gkeClusters"], res) + r.AnthosClusters = flattenTargetAssociatedEntitiesAnthosClustersSlice(c, m["anthosClusters"], res) return r } -// expandTargetMultiTargetMap expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersMap expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersMap(c *Client, f map[string]TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2616,16 +3473,16 @@ func expandTargetMultiTargetMap(c *Client, f map[string]TargetMultiTarget, res * return items, nil } -// expandTargetMultiTargetSlice expands the contents of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClustersSlice expands the contents of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesGkeClustersSlice(c *Client, f []TargetAssociatedEntitiesGkeClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetMultiTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesGkeClusters(c, &item, res) if err != nil { return nil, err } @@ -2636,89 +3493,97 @@ func expandTargetMultiTargetSlice(c *Client, f []TargetMultiTarget, res *Target) return items, nil } -// flattenTargetMultiTargetMap flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersMap flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetMap(c *Client, i interface{}, res *Target) map[string]TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesGkeClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return map[string]TargetMultiTarget{} + return map[string]TargetAssociatedEntitiesGkeClusters{} } - items := make(map[string]TargetMultiTarget) + items := make(map[string]TargetAssociatedEntitiesGkeClusters) for k, item := range a { - items[k] = *flattenTargetMultiTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetMultiTargetSlice flattens the contents of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClustersSlice flattens the contents of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTargetSlice(c *Client, i interface{}, res *Target) []TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesGkeClusters { a, ok := i.([]interface{}) if !ok { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } if len(a) == 0 { - return []TargetMultiTarget{} + return []TargetAssociatedEntitiesGkeClusters{} } - items := make([]TargetMultiTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesGkeClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetMultiTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesGkeClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetMultiTarget expands an instance of TargetMultiTarget into a JSON +// expandTargetAssociatedEntitiesGkeClusters expands an instance of TargetAssociatedEntitiesGkeClusters into a JSON // request object. -func expandTargetMultiTarget(c *Client, f *TargetMultiTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesGkeClusters(c *Client, f *TargetAssociatedEntitiesGkeClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.TargetIds; v != nil { - m["targetIds"] = v + if v := f.Cluster; !dcl.IsEmptyValueIndirect(v) { + m["cluster"] = v + } + if v := f.InternalIP; !dcl.IsEmptyValueIndirect(v) { + m["internalIp"] = v + } + if v := f.ProxyUrl; !dcl.IsEmptyValueIndirect(v) { + m["proxyUrl"] = v } return m, nil } -// flattenTargetMultiTarget flattens an instance of TargetMultiTarget from a JSON +// flattenTargetAssociatedEntitiesGkeClusters flattens an instance of TargetAssociatedEntitiesGkeClusters from a JSON // response object. -func flattenTargetMultiTarget(c *Client, i interface{}, res *Target) *TargetMultiTarget { +func flattenTargetAssociatedEntitiesGkeClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesGkeClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetMultiTarget{} + r := &TargetAssociatedEntitiesGkeClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetMultiTarget + return EmptyTargetAssociatedEntitiesGkeClusters } - r.TargetIds = dcl.FlattenStringSlice(m["targetIds"]) + r.Cluster = dcl.FlattenString(m["cluster"]) + r.InternalIP = dcl.FlattenBool(m["internalIp"]) + r.ProxyUrl = dcl.FlattenString(m["proxyUrl"]) return r } -// expandTargetCustomTargetMap expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersMap expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res *Target) (map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersMap(c *Client, f map[string]TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { if f == nil { return nil, nil } items := make(map[string]interface{}) for k, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2730,16 +3595,16 @@ func expandTargetCustomTargetMap(c *Client, f map[string]TargetCustomTarget, res return items, nil } -// expandTargetCustomTargetSlice expands the contents of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClustersSlice expands the contents of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Target) ([]map[string]interface{}, error) { +func expandTargetAssociatedEntitiesAnthosClustersSlice(c *Client, f []TargetAssociatedEntitiesAnthosClusters, res *Target) ([]map[string]interface{}, error) { if f == nil { return nil, nil } items := []map[string]interface{}{} for _, item := range f { - i, err := expandTargetCustomTarget(c, &item, res) + i, err := expandTargetAssociatedEntitiesAnthosClusters(c, &item, res) if err != nil { return nil, err } @@ -2750,75 +3615,75 @@ func expandTargetCustomTargetSlice(c *Client, f []TargetCustomTarget, res *Targe return items, nil } -// flattenTargetCustomTargetMap flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersMap flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetMap(c *Client, i interface{}, res *Target) map[string]TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersMap(c *Client, i interface{}, res *Target) map[string]TargetAssociatedEntitiesAnthosClusters { a, ok := i.(map[string]interface{}) if !ok { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return map[string]TargetCustomTarget{} + return map[string]TargetAssociatedEntitiesAnthosClusters{} } - items := make(map[string]TargetCustomTarget) + items := make(map[string]TargetAssociatedEntitiesAnthosClusters) for k, item := range a { - items[k] = *flattenTargetCustomTarget(c, item.(map[string]interface{}), res) + items[k] = *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res) } return items } -// flattenTargetCustomTargetSlice flattens the contents of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClustersSlice flattens the contents of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTargetSlice(c *Client, i interface{}, res *Target) []TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClustersSlice(c *Client, i interface{}, res *Target) []TargetAssociatedEntitiesAnthosClusters { a, ok := i.([]interface{}) if !ok { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } if len(a) == 0 { - return []TargetCustomTarget{} + return []TargetAssociatedEntitiesAnthosClusters{} } - items := make([]TargetCustomTarget, 0, len(a)) + items := make([]TargetAssociatedEntitiesAnthosClusters, 0, len(a)) for _, item := range a { - items = append(items, *flattenTargetCustomTarget(c, item.(map[string]interface{}), res)) + items = append(items, *flattenTargetAssociatedEntitiesAnthosClusters(c, item.(map[string]interface{}), res)) } return items } -// expandTargetCustomTarget expands an instance of TargetCustomTarget into a JSON +// expandTargetAssociatedEntitiesAnthosClusters expands an instance of TargetAssociatedEntitiesAnthosClusters into a JSON // request object. -func expandTargetCustomTarget(c *Client, f *TargetCustomTarget, res *Target) (map[string]interface{}, error) { - if dcl.IsEmptyValueIndirect(f) { +func expandTargetAssociatedEntitiesAnthosClusters(c *Client, f *TargetAssociatedEntitiesAnthosClusters, res *Target) (map[string]interface{}, error) { + if f == nil { return nil, nil } m := make(map[string]interface{}) - if v := f.CustomTargetType; !dcl.IsEmptyValueIndirect(v) { - m["customTargetType"] = v + if v := f.Membership; !dcl.IsEmptyValueIndirect(v) { + m["membership"] = v } return m, nil } -// flattenTargetCustomTarget flattens an instance of TargetCustomTarget from a JSON +// flattenTargetAssociatedEntitiesAnthosClusters flattens an instance of TargetAssociatedEntitiesAnthosClusters from a JSON // response object. -func flattenTargetCustomTarget(c *Client, i interface{}, res *Target) *TargetCustomTarget { +func flattenTargetAssociatedEntitiesAnthosClusters(c *Client, i interface{}, res *Target) *TargetAssociatedEntitiesAnthosClusters { m, ok := i.(map[string]interface{}) if !ok { return nil } - r := &TargetCustomTarget{} + r := &TargetAssociatedEntitiesAnthosClusters{} if dcl.IsEmptyValueIndirect(i) { - return EmptyTargetCustomTarget + return EmptyTargetAssociatedEntitiesAnthosClusters } - r.CustomTargetType = dcl.FlattenString(m["customTargetType"]) + r.Membership = dcl.FlattenString(m["membership"]) return r } @@ -3043,6 +3908,15 @@ func extractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) error { func extractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func extractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func extractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func extractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} func postReadExtractTargetFields(r *Target) error { vGke := r.Gke @@ -3120,3 +3994,12 @@ func postReadExtractTargetMultiTargetFields(r *Target, o *TargetMultiTarget) err func postReadExtractTargetCustomTargetFields(r *Target, o *TargetCustomTarget) error { return nil } +func postReadExtractTargetAssociatedEntitiesFields(r *Target, o *TargetAssociatedEntities) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesGkeClustersFields(r *Target, o *TargetAssociatedEntitiesGkeClusters) error { + return nil +} +func postReadExtractTargetAssociatedEntitiesAnthosClustersFields(r *Target, o *TargetAssociatedEntitiesAnthosClusters) error { + return nil +} diff --git a/services/google/clouddeploy/target_schema.go b/services/google/clouddeploy/target_schema.go index d6b7b9f81..6865271f4 100755 --- a/services/google/clouddeploy/target_schema.go +++ b/services/google/clouddeploy/target_schema.go @@ -146,6 +146,75 @@ func DCLTargetSchema() *dcl.Schema { }, }, }, + "associatedEntities": &dcl.Property{ + Type: "object", + AdditionalProperties: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntities", + Properties: map[string]*dcl.Property{ + "anthosClusters": &dcl.Property{ + Type: "array", + GoName: "AnthosClusters", + Description: "Optional. Information specifying Anthos clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesAnthosClusters", + Properties: map[string]*dcl.Property{ + "membership": &dcl.Property{ + Type: "string", + GoName: "Membership", + Description: "Optional. Membership of the GKE Hub-registered cluster to which to apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Gkehub/Membership", + Field: "selfLink", + }, + }, + }, + }, + }, + }, + "gkeClusters": &dcl.Property{ + Type: "array", + GoName: "GkeClusters", + Description: "Optional. Information specifying GKE clusters as associated entities.", + SendEmpty: true, + ListType: "list", + Items: &dcl.Property{ + Type: "object", + GoType: "TargetAssociatedEntitiesGkeClusters", + Properties: map[string]*dcl.Property{ + "cluster": &dcl.Property{ + Type: "string", + GoName: "Cluster", + Description: "Optional. Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.", + ResourceReferences: []*dcl.PropertyResourceReference{ + &dcl.PropertyResourceReference{ + Resource: "Container/Cluster", + Field: "selfLink", + }, + }, + }, + "internalIP": &dcl.Property{ + Type: "boolean", + GoName: "InternalIP", + Description: "Optional. If true, `cluster` is accessed using the private IP address of the control plane endpoint. Otherwise, the default IP address of the control plane endpoint is used. The default IP address is the private IP address for clusters with private control-plane endpoints and the public IP address otherwise. Only specify this option when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).", + }, + "proxyUrl": &dcl.Property{ + Type: "string", + GoName: "ProxyUrl", + Description: "Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy) to the Kubernetes server.", + }, + }, + }, + }, + }, + }, + GoName: "AssociatedEntities", + Description: "Optional. Map of entity IDs to their associated entities. Associated entities allows specifying places other than the deployment target for specific features. For example, the Gateway API canary can be configured to deploy the HTTPRoute to a different cluster(s) than the deployment cluster using associated entities. An entity ID must consist of lower-case letters, numbers, and hyphens, start with a letter and end with a letter or a number, and have a max length of 63 characters. In other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.", + }, "createTime": &dcl.Property{ Type: "string", Format: "date-time", diff --git a/services/google/clouddeploy/target_yaml_embed.go b/services/google/clouddeploy/target_yaml_embed.go index 114186eef..e289c8bd9 100755 --- a/services/google/clouddeploy/target_yaml_embed.go +++ b/services/google/clouddeploy/target_yaml_embed.go @@ -17,7 +17,7 @@ package clouddeploy // blaze-out/k8-fastbuild/genfiles/cloud/graphite/mmv2/services/google/clouddeploy/target.yaml -var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") +var YAML_target = []byte("info:\n title: Clouddeploy/Target\n description: The Cloud Deploy `Target` resource\n x-dcl-struct-name: Target\n x-dcl-has-iam: false\n x-dcl-ref:\n text: REST API\n url: https://cloud.google.com/deploy/docs/api/reference/rest/v1/projects.locations.targets\npaths:\n get:\n description: The function used to get information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n apply:\n description: The function used to apply information about a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n delete:\n description: The function used to delete a Target\n parameters:\n - name: target\n required: true\n description: A full instance of a Target\n deleteAll:\n description: The function used to delete all Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\n list:\n description: The function used to list information about many Target\n parameters:\n - name: project\n required: true\n schema:\n type: string\n - name: location\n required: true\n schema:\n type: string\ncomponents:\n schemas:\n Target:\n title: Target\n x-dcl-id: projects/{{project}}/locations/{{location}}/targets/{{name}}\n x-dcl-parent-container: project\n x-dcl-has-create: true\n x-dcl-has-iam: false\n x-dcl-read-timeout: 0\n x-dcl-apply-timeout: 0\n x-dcl-delete-timeout: 0\n type: object\n required:\n - name\n - project\n - location\n properties:\n annotations:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Annotations\n description: Optional. User annotations. These attributes can only be set\n and used by the user, and not by Google Cloud Deploy. See https://google.aip.dev/128#annotations\n for more details such as format and size limitations.\n anthosCluster:\n type: object\n x-dcl-go-name: AnthosCluster\n x-dcl-go-type: TargetAnthosCluster\n description: Information specifying an Anthos Cluster.\n x-dcl-conflicts:\n - gke\n - run\n - multiTarget\n - customTarget\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Membership of the GKE Hub-registered cluster to which to\n apply the Skaffold configuration. Format is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n associatedEntities:\n type: object\n additionalProperties:\n type: object\n x-dcl-go-type: TargetAssociatedEntities\n properties:\n anthosClusters:\n type: array\n x-dcl-go-name: AnthosClusters\n description: Optional. Information specifying Anthos clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesAnthosClusters\n properties:\n membership:\n type: string\n x-dcl-go-name: Membership\n description: Optional. Membership of the GKE Hub-registered\n cluster to which to apply the Skaffold configuration. Format\n is `projects/{project}/locations/{location}/memberships/{membership_name}`.\n x-dcl-references:\n - resource: Gkehub/Membership\n field: selfLink\n gkeClusters:\n type: array\n x-dcl-go-name: GkeClusters\n description: Optional. Information specifying GKE clusters as associated\n entities.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetAssociatedEntitiesGkeClusters\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Optional. Information specifying a GKE Cluster.\n Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}`.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using\n the private IP address of the control plane endpoint. Otherwise,\n the default IP address of the control plane endpoint is used.\n The default IP address is the private IP address for clusters\n with private control-plane endpoints and the public IP address\n otherwise. Only specify this option when `cluster` is a [private\n GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n x-dcl-go-name: AssociatedEntities\n description: 'Optional. Map of entity IDs to their associated entities.\n Associated entities allows specifying places other than the deployment\n target for specific features. For example, the Gateway API canary can\n be configured to deploy the HTTPRoute to a different cluster(s) than the\n deployment cluster using associated entities. An entity ID must consist\n of lower-case letters, numbers, and hyphens, start with a letter and end\n with a letter or a number, and have a max length of 63 characters. In\n other words, it must match the following regex: `^[a-z]([a-z0-9-]{0,61}[a-z0-9])?$`.'\n createTime:\n type: string\n format: date-time\n x-dcl-go-name: CreateTime\n readOnly: true\n description: Output only. Time at which the `Target` was created.\n x-kubernetes-immutable: true\n customTarget:\n type: object\n x-dcl-go-name: CustomTarget\n x-dcl-go-type: TargetCustomTarget\n description: Optional. Information specifying a Custom Target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - multiTarget\n required:\n - customTargetType\n properties:\n customTargetType:\n type: string\n x-dcl-go-name: CustomTargetType\n description: Required. The name of the CustomTargetType. Format must\n be `projects/{project}/locations/{location}/customTargetTypes/{custom_target_type}`.\n x-dcl-references:\n - resource: Clouddeploy/CustomTargetType\n field: selfLink\n deployParameters:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: DeployParameters\n description: Optional. The deploy parameters to use for this target.\n description:\n type: string\n x-dcl-go-name: Description\n description: Optional. Description of the `Target`. Max length is 255 characters.\n etag:\n type: string\n x-dcl-go-name: Etag\n readOnly: true\n description: Optional. This checksum is computed by the server based on\n the value of other fields, and may be sent on update and delete requests\n to ensure the client has an up-to-date value before proceeding.\n x-kubernetes-immutable: true\n executionConfigs:\n type: array\n x-dcl-go-name: ExecutionConfigs\n description: Configurations for all execution that relates to this `Target`.\n Each `ExecutionEnvironmentUsage` value may only be used in a single configuration;\n using the same value multiple times is an error. When one or more configurations\n are specified, they must include the `RENDER` and `DEPLOY` `ExecutionEnvironmentUsage`\n values. When no configurations are specified, execution will use the default\n specified in `DefaultPool`.\n x-dcl-server-default: true\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: object\n x-dcl-go-type: TargetExecutionConfigs\n required:\n - usages\n properties:\n artifactStorage:\n type: string\n x-dcl-go-name: ArtifactStorage\n description: Optional. Cloud Storage location in which to store execution\n outputs. This can either be a bucket (\"gs://my-bucket\") or a path\n within a bucket (\"gs://my-bucket/my-dir\"). If unspecified, a default\n bucket located in the same region will be used.\n x-dcl-server-default: true\n executionTimeout:\n type: string\n x-dcl-go-name: ExecutionTimeout\n description: Optional. Execution timeout for a Cloud Build Execution.\n This must be between 10m and 24h in seconds format. If unspecified,\n a default timeout of 1h is used.\n x-dcl-server-default: true\n serviceAccount:\n type: string\n x-dcl-go-name: ServiceAccount\n description: Optional. Google service account to use for execution.\n If unspecified, the project execution service account (-compute@developer.gserviceaccount.com)\n is used.\n x-dcl-server-default: true\n usages:\n type: array\n x-dcl-go-name: Usages\n description: Required. Usages when this configuration should be applied.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: TargetExecutionConfigsUsagesEnum\n enum:\n - EXECUTION_ENVIRONMENT_USAGE_UNSPECIFIED\n - RENDER\n - DEPLOY\n verbose:\n type: boolean\n x-dcl-go-name: Verbose\n description: Optional. If true, additional logging will be enabled\n when running builds in this execution environment.\n workerPool:\n type: string\n x-dcl-go-name: WorkerPool\n description: Optional. The resource name of the `WorkerPool`, with\n the format `projects/{project}/locations/{location}/workerPools/{worker_pool}`.\n If this optional field is unspecified, the default Cloud Build pool\n will be used.\n x-dcl-references:\n - resource: Cloudbuild/WorkerPool\n field: selfLink\n gke:\n type: object\n x-dcl-go-name: Gke\n x-dcl-go-type: TargetGke\n description: Information specifying a GKE Cluster.\n x-dcl-conflicts:\n - anthosCluster\n - run\n - multiTarget\n - customTarget\n properties:\n cluster:\n type: string\n x-dcl-go-name: Cluster\n description: Information specifying a GKE Cluster. Format is `projects/{project_id}/locations/{location_id}/clusters/{cluster_id}.\n x-dcl-references:\n - resource: Container/Cluster\n field: selfLink\n internalIP:\n type: boolean\n x-dcl-go-name: InternalIP\n description: Optional. If true, `cluster` is accessed using the private\n IP address of the control plane endpoint. Otherwise, the default IP\n address of the control plane endpoint is used. The default IP address\n is the private IP address for clusters with private control-plane\n endpoints and the public IP address otherwise. Only specify this option\n when `cluster` is a [private GKE cluster](https://cloud.google.com/kubernetes-engine/docs/concepts/private-cluster-concept).\n proxyUrl:\n type: string\n x-dcl-go-name: ProxyUrl\n description: Optional. If set, used to configure a [proxy](https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#proxy)\n to the Kubernetes server.\n labels:\n type: object\n additionalProperties:\n type: string\n x-dcl-go-name: Labels\n description: 'Optional. Labels are attributes that can be set and used by\n both the user and by Google Cloud Deploy. Labels must meet the following\n constraints: * Keys and values can contain only lowercase letters, numeric\n characters, underscores, and dashes. * All characters must use UTF-8 encoding,\n and international characters are allowed. * Keys must start with a lowercase\n letter or international character. * Each resource is limited to a maximum\n of 64 labels. Both keys and values are additionally constrained to be\n <= 128 bytes.'\n location:\n type: string\n x-dcl-go-name: Location\n description: The location for the resource\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n multiTarget:\n type: object\n x-dcl-go-name: MultiTarget\n x-dcl-go-type: TargetMultiTarget\n description: Information specifying a multiTarget.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - run\n - customTarget\n required:\n - targetIds\n properties:\n targetIds:\n type: array\n x-dcl-go-name: TargetIds\n description: Required. The target_ids of this multiTarget.\n x-dcl-send-empty: true\n x-dcl-list-type: list\n items:\n type: string\n x-dcl-go-type: string\n name:\n type: string\n x-dcl-go-name: Name\n description: Name of the `Target`. Format is `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`.\n x-kubernetes-immutable: true\n x-dcl-parameter: true\n x-dcl-has-long-form: true\n project:\n type: string\n x-dcl-go-name: Project\n description: The project for the resource\n x-kubernetes-immutable: true\n x-dcl-references:\n - resource: Cloudresourcemanager/Project\n field: name\n parent: true\n x-dcl-parameter: true\n requireApproval:\n type: boolean\n x-dcl-go-name: RequireApproval\n description: Optional. Whether or not the `Target` requires approval.\n run:\n type: object\n x-dcl-go-name: Run\n x-dcl-go-type: TargetRun\n description: Information specifying a Cloud Run deployment target.\n x-dcl-conflicts:\n - gke\n - anthosCluster\n - multiTarget\n - customTarget\n required:\n - location\n properties:\n location:\n type: string\n x-dcl-go-name: Location\n description: Required. The location where the Cloud Run Service should\n be located. Format is `projects/{project}/locations/{location}`.\n targetId:\n type: string\n x-dcl-go-name: TargetId\n readOnly: true\n description: Output only. Resource id of the `Target`.\n x-kubernetes-immutable: true\n uid:\n type: string\n x-dcl-go-name: Uid\n readOnly: true\n description: Output only. Unique identifier of the `Target`.\n x-kubernetes-immutable: true\n updateTime:\n type: string\n format: date-time\n x-dcl-go-name: UpdateTime\n readOnly: true\n description: Output only. Most recent time at which the `Target` was updated.\n x-kubernetes-immutable: true\n") -// 13256 bytes -// MD5: 6af2eccf69e0aafa0d3498bc876d8a28 +// 17100 bytes +// MD5: 7db60317a50bbd142f17a887065f11f0 diff --git a/unstructured/google/clouddeploy/alpha/delivery_pipeline.go b/unstructured/google/clouddeploy/alpha/delivery_pipeline.go index 1f35f89a6..f0f81aad1 100755 --- a/unstructured/google/clouddeploy/alpha/delivery_pipeline.go +++ b/unstructured/google/clouddeploy/alpha/delivery_pipeline.go @@ -246,6 +246,18 @@ func DeliveryPipelineToUnstructured(r *dclService.DeliveryPipeline) *unstructure if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["podSelectorLabel"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel } + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != nil && rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != dclService.EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations := make(map[string]interface{}) + var rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds []interface{} + for _, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal := range rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds = append(rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal) + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService != nil { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime } @@ -765,6 +777,31 @@ func UnstructuredToDeliveryPipeline(u *unstructured.Resource) (*dclService.Deliv return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel: expected string") } } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"]; ok { + if rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"].(map[string]interface{}); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations = &dclService.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"]; ok { + if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"].([]interface{}); ok { + for _, ss := range s { + if strval, ok := ss.(string); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds = append(rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds, strval) + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds: expected []interface{}") + } + } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"]; ok { + if b, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"].(bool); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService: expected bool") + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations: expected map[string]interface{}") + } + } if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"]; ok { if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"].(string); ok { rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime = dcl.String(s) diff --git a/unstructured/google/clouddeploy/alpha/target.go b/unstructured/google/clouddeploy/alpha/target.go index 36d76d49d..1890bb6d6 100755 --- a/unstructured/google/clouddeploy/alpha/target.go +++ b/unstructured/google/clouddeploy/alpha/target.go @@ -46,6 +46,38 @@ func TargetToUnstructured(r *dclService.Target) *unstructured.Resource { } u.Object["anthosCluster"] = rAnthosCluster } + if r.AssociatedEntities != nil { + rAssociatedEntities := make(map[string]interface{}) + for k, v := range r.AssociatedEntities { + rAssociatedEntitiesMap := make(map[string]interface{}) + var vAnthosClusters []interface{} + for _, vAnthosClustersVal := range v.AnthosClusters { + vAnthosClustersObject := make(map[string]interface{}) + if vAnthosClustersVal.Membership != nil { + vAnthosClustersObject["membership"] = *vAnthosClustersVal.Membership + } + vAnthosClusters = append(vAnthosClusters, vAnthosClustersObject) + } + rAssociatedEntitiesMap["anthosClusters"] = vAnthosClusters + var vGkeClusters []interface{} + for _, vGkeClustersVal := range v.GkeClusters { + vGkeClustersObject := make(map[string]interface{}) + if vGkeClustersVal.Cluster != nil { + vGkeClustersObject["cluster"] = *vGkeClustersVal.Cluster + } + if vGkeClustersVal.InternalIP != nil { + vGkeClustersObject["internalIP"] = *vGkeClustersVal.InternalIP + } + if vGkeClustersVal.ProxyUrl != nil { + vGkeClustersObject["proxyUrl"] = *vGkeClustersVal.ProxyUrl + } + vGkeClusters = append(vGkeClusters, vGkeClustersObject) + } + rAssociatedEntitiesMap["gkeClusters"] = vGkeClusters + rAssociatedEntities[k] = rAssociatedEntitiesMap + } + u.Object["associatedEntities"] = rAssociatedEntities + } if r.CreateTime != nil { u.Object["createTime"] = *r.CreateTime } @@ -184,6 +216,74 @@ func UnstructuredToTarget(u *unstructured.Resource) (*dclService.Target, error) return nil, fmt.Errorf("r.AnthosCluster: expected map[string]interface{}") } } + if _, ok := u.Object["associatedEntities"]; ok { + if rAssociatedEntities, ok := u.Object["associatedEntities"].(map[string]interface{}); ok { + m := make(map[string]dclService.TargetAssociatedEntities) + for k, v := range rAssociatedEntities { + if objval, ok := v.(map[string]interface{}); ok { + var rAssociatedEntitiesObj dclService.TargetAssociatedEntities + if _, ok := objval["anthosClusters"]; ok { + if s, ok := objval["anthosClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjAnthosClusters dclService.TargetAssociatedEntitiesAnthosClusters + if _, ok := objval["membership"]; ok { + if s, ok := objval["membership"].(string); ok { + rAssociatedEntitiesObjAnthosClusters.Membership = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjAnthosClusters.Membership: expected string") + } + } + rAssociatedEntitiesObj.AnthosClusters = append(rAssociatedEntitiesObj.AnthosClusters, rAssociatedEntitiesObjAnthosClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.AnthosClusters: expected []interface{}") + } + } + if _, ok := objval["gkeClusters"]; ok { + if s, ok := objval["gkeClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjGkeClusters dclService.TargetAssociatedEntitiesGkeClusters + if _, ok := objval["cluster"]; ok { + if s, ok := objval["cluster"].(string); ok { + rAssociatedEntitiesObjGkeClusters.Cluster = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.Cluster: expected string") + } + } + if _, ok := objval["internalIP"]; ok { + if b, ok := objval["internalIP"].(bool); ok { + rAssociatedEntitiesObjGkeClusters.InternalIP = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.InternalIP: expected bool") + } + } + if _, ok := objval["proxyUrl"]; ok { + if s, ok := objval["proxyUrl"].(string); ok { + rAssociatedEntitiesObjGkeClusters.ProxyUrl = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.ProxyUrl: expected string") + } + } + rAssociatedEntitiesObj.GkeClusters = append(rAssociatedEntitiesObj.GkeClusters, rAssociatedEntitiesObjGkeClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.GkeClusters: expected []interface{}") + } + } + m[k] = rAssociatedEntitiesObj + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } + r.AssociatedEntities = m + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } if _, ok := u.Object["createTime"]; ok { if s, ok := u.Object["createTime"].(string); ok { r.CreateTime = dcl.String(s) diff --git a/unstructured/google/clouddeploy/beta/delivery_pipeline.go b/unstructured/google/clouddeploy/beta/delivery_pipeline.go index e1407fc7f..effd19049 100755 --- a/unstructured/google/clouddeploy/beta/delivery_pipeline.go +++ b/unstructured/google/clouddeploy/beta/delivery_pipeline.go @@ -246,6 +246,18 @@ func DeliveryPipelineToUnstructured(r *dclService.DeliveryPipeline) *unstructure if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["podSelectorLabel"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel } + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != nil && rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != dclService.EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations := make(map[string]interface{}) + var rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds []interface{} + for _, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal := range rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds = append(rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal) + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService != nil { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime } @@ -765,6 +777,31 @@ func UnstructuredToDeliveryPipeline(u *unstructured.Resource) (*dclService.Deliv return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel: expected string") } } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"]; ok { + if rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"].(map[string]interface{}); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations = &dclService.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"]; ok { + if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"].([]interface{}); ok { + for _, ss := range s { + if strval, ok := ss.(string); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds = append(rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds, strval) + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds: expected []interface{}") + } + } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"]; ok { + if b, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"].(bool); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService: expected bool") + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations: expected map[string]interface{}") + } + } if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"]; ok { if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"].(string); ok { rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime = dcl.String(s) diff --git a/unstructured/google/clouddeploy/beta/target.go b/unstructured/google/clouddeploy/beta/target.go index 79ae2c1d3..d7f589cbc 100755 --- a/unstructured/google/clouddeploy/beta/target.go +++ b/unstructured/google/clouddeploy/beta/target.go @@ -46,6 +46,38 @@ func TargetToUnstructured(r *dclService.Target) *unstructured.Resource { } u.Object["anthosCluster"] = rAnthosCluster } + if r.AssociatedEntities != nil { + rAssociatedEntities := make(map[string]interface{}) + for k, v := range r.AssociatedEntities { + rAssociatedEntitiesMap := make(map[string]interface{}) + var vAnthosClusters []interface{} + for _, vAnthosClustersVal := range v.AnthosClusters { + vAnthosClustersObject := make(map[string]interface{}) + if vAnthosClustersVal.Membership != nil { + vAnthosClustersObject["membership"] = *vAnthosClustersVal.Membership + } + vAnthosClusters = append(vAnthosClusters, vAnthosClustersObject) + } + rAssociatedEntitiesMap["anthosClusters"] = vAnthosClusters + var vGkeClusters []interface{} + for _, vGkeClustersVal := range v.GkeClusters { + vGkeClustersObject := make(map[string]interface{}) + if vGkeClustersVal.Cluster != nil { + vGkeClustersObject["cluster"] = *vGkeClustersVal.Cluster + } + if vGkeClustersVal.InternalIP != nil { + vGkeClustersObject["internalIP"] = *vGkeClustersVal.InternalIP + } + if vGkeClustersVal.ProxyUrl != nil { + vGkeClustersObject["proxyUrl"] = *vGkeClustersVal.ProxyUrl + } + vGkeClusters = append(vGkeClusters, vGkeClustersObject) + } + rAssociatedEntitiesMap["gkeClusters"] = vGkeClusters + rAssociatedEntities[k] = rAssociatedEntitiesMap + } + u.Object["associatedEntities"] = rAssociatedEntities + } if r.CreateTime != nil { u.Object["createTime"] = *r.CreateTime } @@ -184,6 +216,74 @@ func UnstructuredToTarget(u *unstructured.Resource) (*dclService.Target, error) return nil, fmt.Errorf("r.AnthosCluster: expected map[string]interface{}") } } + if _, ok := u.Object["associatedEntities"]; ok { + if rAssociatedEntities, ok := u.Object["associatedEntities"].(map[string]interface{}); ok { + m := make(map[string]dclService.TargetAssociatedEntities) + for k, v := range rAssociatedEntities { + if objval, ok := v.(map[string]interface{}); ok { + var rAssociatedEntitiesObj dclService.TargetAssociatedEntities + if _, ok := objval["anthosClusters"]; ok { + if s, ok := objval["anthosClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjAnthosClusters dclService.TargetAssociatedEntitiesAnthosClusters + if _, ok := objval["membership"]; ok { + if s, ok := objval["membership"].(string); ok { + rAssociatedEntitiesObjAnthosClusters.Membership = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjAnthosClusters.Membership: expected string") + } + } + rAssociatedEntitiesObj.AnthosClusters = append(rAssociatedEntitiesObj.AnthosClusters, rAssociatedEntitiesObjAnthosClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.AnthosClusters: expected []interface{}") + } + } + if _, ok := objval["gkeClusters"]; ok { + if s, ok := objval["gkeClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjGkeClusters dclService.TargetAssociatedEntitiesGkeClusters + if _, ok := objval["cluster"]; ok { + if s, ok := objval["cluster"].(string); ok { + rAssociatedEntitiesObjGkeClusters.Cluster = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.Cluster: expected string") + } + } + if _, ok := objval["internalIP"]; ok { + if b, ok := objval["internalIP"].(bool); ok { + rAssociatedEntitiesObjGkeClusters.InternalIP = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.InternalIP: expected bool") + } + } + if _, ok := objval["proxyUrl"]; ok { + if s, ok := objval["proxyUrl"].(string); ok { + rAssociatedEntitiesObjGkeClusters.ProxyUrl = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.ProxyUrl: expected string") + } + } + rAssociatedEntitiesObj.GkeClusters = append(rAssociatedEntitiesObj.GkeClusters, rAssociatedEntitiesObjGkeClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.GkeClusters: expected []interface{}") + } + } + m[k] = rAssociatedEntitiesObj + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } + r.AssociatedEntities = m + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } if _, ok := u.Object["createTime"]; ok { if s, ok := u.Object["createTime"].(string); ok { r.CreateTime = dcl.String(s) diff --git a/unstructured/google/clouddeploy/delivery_pipeline.go b/unstructured/google/clouddeploy/delivery_pipeline.go index faadd0801..52e23f429 100755 --- a/unstructured/google/clouddeploy/delivery_pipeline.go +++ b/unstructured/google/clouddeploy/delivery_pipeline.go @@ -246,6 +246,18 @@ func DeliveryPipelineToUnstructured(r *dclService.DeliveryPipeline) *unstructure if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["podSelectorLabel"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel } + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != nil && rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations != dclService.EmptyDeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations := make(map[string]interface{}) + var rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds []interface{} + for _, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal := range rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds = append(rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds, rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIdsVal) + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinationsDestinationIds + if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService != nil { + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService + } + rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"] = rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations + } if rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime != nil { rSerialPipelineStagesValStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"] = *rSerialPipelineStagesVal.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime } @@ -765,6 +777,31 @@ func UnstructuredToDeliveryPipeline(u *unstructured.Resource) (*dclService.Deliv return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.PodSelectorLabel: expected string") } } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"]; ok { + if rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeDestinations"].(map[string]interface{}); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations = &dclService.DeliveryPipelineSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations{} + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"]; ok { + if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["destinationIds"].([]interface{}); ok { + for _, ss := range s { + if strval, ok := ss.(string); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds = append(rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds, strval) + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.DestinationIds: expected []interface{}") + } + } + if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"]; ok { + if b, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMeshRouteDestinations["propagateService"].(bool); ok { + rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations.PropagateService: expected bool") + } + } + } else { + return nil, fmt.Errorf("rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteDestinations: expected map[string]interface{}") + } + } if _, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"]; ok { if s, ok := rSerialPipelineStagesStrategyCanaryRuntimeConfigKubernetesGatewayServiceMesh["routeUpdateWaitTime"].(string); ok { rSerialPipelineStages.Strategy.Canary.RuntimeConfig.Kubernetes.GatewayServiceMesh.RouteUpdateWaitTime = dcl.String(s) diff --git a/unstructured/google/clouddeploy/target.go b/unstructured/google/clouddeploy/target.go index c0ac988c8..3d48f8b14 100755 --- a/unstructured/google/clouddeploy/target.go +++ b/unstructured/google/clouddeploy/target.go @@ -46,6 +46,38 @@ func TargetToUnstructured(r *dclService.Target) *unstructured.Resource { } u.Object["anthosCluster"] = rAnthosCluster } + if r.AssociatedEntities != nil { + rAssociatedEntities := make(map[string]interface{}) + for k, v := range r.AssociatedEntities { + rAssociatedEntitiesMap := make(map[string]interface{}) + var vAnthosClusters []interface{} + for _, vAnthosClustersVal := range v.AnthosClusters { + vAnthosClustersObject := make(map[string]interface{}) + if vAnthosClustersVal.Membership != nil { + vAnthosClustersObject["membership"] = *vAnthosClustersVal.Membership + } + vAnthosClusters = append(vAnthosClusters, vAnthosClustersObject) + } + rAssociatedEntitiesMap["anthosClusters"] = vAnthosClusters + var vGkeClusters []interface{} + for _, vGkeClustersVal := range v.GkeClusters { + vGkeClustersObject := make(map[string]interface{}) + if vGkeClustersVal.Cluster != nil { + vGkeClustersObject["cluster"] = *vGkeClustersVal.Cluster + } + if vGkeClustersVal.InternalIP != nil { + vGkeClustersObject["internalIP"] = *vGkeClustersVal.InternalIP + } + if vGkeClustersVal.ProxyUrl != nil { + vGkeClustersObject["proxyUrl"] = *vGkeClustersVal.ProxyUrl + } + vGkeClusters = append(vGkeClusters, vGkeClustersObject) + } + rAssociatedEntitiesMap["gkeClusters"] = vGkeClusters + rAssociatedEntities[k] = rAssociatedEntitiesMap + } + u.Object["associatedEntities"] = rAssociatedEntities + } if r.CreateTime != nil { u.Object["createTime"] = *r.CreateTime } @@ -184,6 +216,74 @@ func UnstructuredToTarget(u *unstructured.Resource) (*dclService.Target, error) return nil, fmt.Errorf("r.AnthosCluster: expected map[string]interface{}") } } + if _, ok := u.Object["associatedEntities"]; ok { + if rAssociatedEntities, ok := u.Object["associatedEntities"].(map[string]interface{}); ok { + m := make(map[string]dclService.TargetAssociatedEntities) + for k, v := range rAssociatedEntities { + if objval, ok := v.(map[string]interface{}); ok { + var rAssociatedEntitiesObj dclService.TargetAssociatedEntities + if _, ok := objval["anthosClusters"]; ok { + if s, ok := objval["anthosClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjAnthosClusters dclService.TargetAssociatedEntitiesAnthosClusters + if _, ok := objval["membership"]; ok { + if s, ok := objval["membership"].(string); ok { + rAssociatedEntitiesObjAnthosClusters.Membership = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjAnthosClusters.Membership: expected string") + } + } + rAssociatedEntitiesObj.AnthosClusters = append(rAssociatedEntitiesObj.AnthosClusters, rAssociatedEntitiesObjAnthosClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.AnthosClusters: expected []interface{}") + } + } + if _, ok := objval["gkeClusters"]; ok { + if s, ok := objval["gkeClusters"].([]interface{}); ok { + for _, o := range s { + if objval, ok := o.(map[string]interface{}); ok { + var rAssociatedEntitiesObjGkeClusters dclService.TargetAssociatedEntitiesGkeClusters + if _, ok := objval["cluster"]; ok { + if s, ok := objval["cluster"].(string); ok { + rAssociatedEntitiesObjGkeClusters.Cluster = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.Cluster: expected string") + } + } + if _, ok := objval["internalIP"]; ok { + if b, ok := objval["internalIP"].(bool); ok { + rAssociatedEntitiesObjGkeClusters.InternalIP = dcl.Bool(b) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.InternalIP: expected bool") + } + } + if _, ok := objval["proxyUrl"]; ok { + if s, ok := objval["proxyUrl"].(string); ok { + rAssociatedEntitiesObjGkeClusters.ProxyUrl = dcl.String(s) + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObjGkeClusters.ProxyUrl: expected string") + } + } + rAssociatedEntitiesObj.GkeClusters = append(rAssociatedEntitiesObj.GkeClusters, rAssociatedEntitiesObjGkeClusters) + } + } + } else { + return nil, fmt.Errorf("rAssociatedEntitiesObj.GkeClusters: expected []interface{}") + } + } + m[k] = rAssociatedEntitiesObj + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } + r.AssociatedEntities = m + } else { + return nil, fmt.Errorf("r.AssociatedEntities: expected map[string]interface{}") + } + } if _, ok := u.Object["createTime"]; ok { if s, ok := u.Object["createTime"].(string); ok { r.CreateTime = dcl.String(s)