From a6d021056ea38d5e7203a578bb0a748a744242bf Mon Sep 17 00:00:00 2001 From: The Magician Date: Tue, 15 Jun 2021 18:35:44 -0700 Subject: [PATCH] mtls refactor for endpoints (#4869) (#724) Signed-off-by: Modular Magician --- google/config.go | 372 +++++++++++++++--------- google/provider_handwritten_endpoint.go | 57 +--- 2 files changed, 249 insertions(+), 180 deletions(-) diff --git a/google/config.go b/google/config.go index 5c883c113..aaf86910a 100644 --- a/google/config.go +++ b/google/config.go @@ -166,68 +166,160 @@ type Config struct { GkeHubBasePath string } +const AccessApprovalBasePathKey = "AccessApproval" +const AccessContextManagerBasePathKey = "AccessContextManager" +const ActiveDirectoryBasePathKey = "ActiveDirectory" +const ApigeeBasePathKey = "Apigee" +const AppEngineBasePathKey = "AppEngine" +const BigQueryBasePathKey = "BigQuery" +const BigqueryDataTransferBasePathKey = "BigqueryDataTransfer" +const BigqueryReservationBasePathKey = "BigqueryReservation" +const BigtableBasePathKey = "Bigtable" +const BillingBasePathKey = "Billing" +const BinaryAuthorizationBasePathKey = "BinaryAuthorization" +const CloudAssetBasePathKey = "CloudAsset" +const CloudBuildBasePathKey = "CloudBuild" +const CloudFunctionsBasePathKey = "CloudFunctions" +const CloudIdentityBasePathKey = "CloudIdentity" +const CloudIotBasePathKey = "CloudIot" +const CloudRunBasePathKey = "CloudRun" +const CloudSchedulerBasePathKey = "CloudScheduler" +const CloudTasksBasePathKey = "CloudTasks" +const ComputeBasePathKey = "Compute" +const ContainerAnalysisBasePathKey = "ContainerAnalysis" +const DataCatalogBasePathKey = "DataCatalog" +const DataLossPreventionBasePathKey = "DataLossPrevention" +const DataprocBasePathKey = "Dataproc" +const DatastoreBasePathKey = "Datastore" +const DeploymentManagerBasePathKey = "DeploymentManager" +const DialogflowBasePathKey = "Dialogflow" +const DialogflowCXBasePathKey = "DialogflowCX" +const DNSBasePathKey = "DNS" +const FilestoreBasePathKey = "Filestore" +const FirestoreBasePathKey = "Firestore" +const GameServicesBasePathKey = "GameServices" +const HealthcareBasePathKey = "Healthcare" +const IapBasePathKey = "Iap" +const IdentityPlatformBasePathKey = "IdentityPlatform" +const KMSBasePathKey = "KMS" +const LoggingBasePathKey = "Logging" +const MemcacheBasePathKey = "Memcache" +const MLEngineBasePathKey = "MLEngine" +const MonitoringBasePathKey = "Monitoring" +const NetworkManagementBasePathKey = "NetworkManagement" +const NotebooksBasePathKey = "Notebooks" +const OSConfigBasePathKey = "OSConfig" +const OSLoginBasePathKey = "OSLogin" +const PubsubBasePathKey = "Pubsub" +const PubsubLiteBasePathKey = "PubsubLite" +const RedisBasePathKey = "Redis" +const ResourceManagerBasePathKey = "ResourceManager" +const RuntimeConfigBasePathKey = "RuntimeConfig" +const SecretManagerBasePathKey = "SecretManager" +const SecurityCenterBasePathKey = "SecurityCenter" +const ServiceManagementBasePathKey = "ServiceManagement" +const ServiceUsageBasePathKey = "ServiceUsage" +const SourceRepoBasePathKey = "SourceRepo" +const SpannerBasePathKey = "Spanner" +const SQLBasePathKey = "SQL" +const StorageBasePathKey = "Storage" +const TagsBasePathKey = "Tags" +const TPUBasePathKey = "TPU" +const VPCAccessBasePathKey = "VPCAccess" +const WorkflowsBasePathKey = "Workflows" +const CloudBillingBasePathKey = "CloudBilling" +const ComposerBasePathKey = "Composer" +const ComputeBetaBasePathKey = "ComputeBeta" +const ContainerBasePathKey = "Container" +const DataprocBetaBasePathKey = "DataprocBeta" +const ContainerBetaBasePathKey = "ContainerBeta" +const DataflowBasePathKey = "Dataflow" +const IAMBasePathKey = "IAM" +const IamCredentialsBasePathKey = "IamCredentials" +const ResourceManagerV2BasePathKey = "ResourceManagerV2" +const ServiceNetworkingBasePathKey = "ServiceNetworking" +const StorageTransferBasePathKey = "StorageTransfer" +const BigtableAdminBasePathKey = "BigtableAdmin" +const GkeHubFeatureBasePathKey = "GkeHubFeatureBasePathKey" + // Generated product base paths -var AccessApprovalDefaultBasePath = "https://accessapproval.googleapis.com/v1/" -var AccessContextManagerDefaultBasePath = "https://accesscontextmanager.googleapis.com/v1/" -var ActiveDirectoryDefaultBasePath = "https://managedidentities.googleapis.com/v1/" -var ApigeeDefaultBasePath = "https://apigee.googleapis.com/v1/" -var AppEngineDefaultBasePath = "https://appengine.googleapis.com/v1/" -var BigQueryDefaultBasePath = "https://bigquery.googleapis.com/bigquery/v2/" -var BigqueryDataTransferDefaultBasePath = "https://bigquerydatatransfer.googleapis.com/v1/" -var BigqueryReservationDefaultBasePath = "https://bigqueryreservation.googleapis.com/v1/" -var BigtableDefaultBasePath = "https://bigtableadmin.googleapis.com/v2/" -var BillingDefaultBasePath = "https://billingbudgets.googleapis.com/v1/" -var BinaryAuthorizationDefaultBasePath = "https://binaryauthorization.googleapis.com/v1/" -var CloudAssetDefaultBasePath = "https://cloudasset.googleapis.com/v1/" -var CloudBuildDefaultBasePath = "https://cloudbuild.googleapis.com/v1/" -var CloudFunctionsDefaultBasePath = "https://cloudfunctions.googleapis.com/v1/" -var CloudIdentityDefaultBasePath = "https://cloudidentity.googleapis.com/v1/" -var CloudIotDefaultBasePath = "https://cloudiot.googleapis.com/v1/" -var CloudRunDefaultBasePath = "https://{{location}}-run.googleapis.com/" -var CloudSchedulerDefaultBasePath = "https://cloudscheduler.googleapis.com/v1/" -var CloudTasksDefaultBasePath = "https://cloudtasks.googleapis.com/v2/" -var ComputeDefaultBasePath = "https://compute.googleapis.com/compute/v1/" -var ContainerAnalysisDefaultBasePath = "https://containeranalysis.googleapis.com/v1/" -var DataCatalogDefaultBasePath = "https://datacatalog.googleapis.com/v1/" -var DataLossPreventionDefaultBasePath = "https://dlp.googleapis.com/v2/" -var DataprocDefaultBasePath = "https://dataproc.googleapis.com/v1/" -var DatastoreDefaultBasePath = "https://datastore.googleapis.com/v1/" -var DeploymentManagerDefaultBasePath = "https://www.googleapis.com/deploymentmanager/v2/" -var DialogflowDefaultBasePath = "https://dialogflow.googleapis.com/v2/" -var DialogflowCXDefaultBasePath = "https://{{location}}-dialogflow.googleapis.com/v3/" -var DNSDefaultBasePath = "https://dns.googleapis.com/dns/v1/" -var FilestoreDefaultBasePath = "https://file.googleapis.com/v1/" -var FirestoreDefaultBasePath = "https://firestore.googleapis.com/v1/" -var GameServicesDefaultBasePath = "https://gameservices.googleapis.com/v1/" -var HealthcareDefaultBasePath = "https://healthcare.googleapis.com/v1/" -var IapDefaultBasePath = "https://iap.googleapis.com/v1/" -var IdentityPlatformDefaultBasePath = "https://identitytoolkit.googleapis.com/v2/" -var KMSDefaultBasePath = "https://cloudkms.googleapis.com/v1/" -var LoggingDefaultBasePath = "https://logging.googleapis.com/v2/" -var MemcacheDefaultBasePath = "https://memcache.googleapis.com/v1/" -var MLEngineDefaultBasePath = "https://ml.googleapis.com/v1/" -var MonitoringDefaultBasePath = "https://monitoring.googleapis.com/" -var NetworkManagementDefaultBasePath = "https://networkmanagement.googleapis.com/v1/" -var NotebooksDefaultBasePath = "https://notebooks.googleapis.com/v1/" -var OSConfigDefaultBasePath = "https://osconfig.googleapis.com/v1/" -var OSLoginDefaultBasePath = "https://oslogin.googleapis.com/v1/" -var PubsubDefaultBasePath = "https://pubsub.googleapis.com/v1/" -var PubsubLiteDefaultBasePath = "https://{{region}}-pubsublite.googleapis.com/v1/admin/" -var RedisDefaultBasePath = "https://redis.googleapis.com/v1/" -var ResourceManagerDefaultBasePath = "https://cloudresourcemanager.googleapis.com/v1/" -var RuntimeConfigDefaultBasePath = "https://runtimeconfig.googleapis.com/v1beta1/" -var SecretManagerDefaultBasePath = "https://secretmanager.googleapis.com/v1/" -var SecurityCenterDefaultBasePath = "https://securitycenter.googleapis.com/v1/" -var ServiceManagementDefaultBasePath = "https://servicemanagement.googleapis.com/v1/" -var ServiceUsageDefaultBasePath = "https://serviceusage.googleapis.com/v1/" -var SourceRepoDefaultBasePath = "https://sourcerepo.googleapis.com/v1/" -var SpannerDefaultBasePath = "https://spanner.googleapis.com/v1/" -var SQLDefaultBasePath = "https://sqladmin.googleapis.com/sql/v1beta4/" -var StorageDefaultBasePath = "https://storage.googleapis.com/storage/v1/" -var TagsDefaultBasePath = "https://cloudresourcemanager.googleapis.com/v3/" -var TPUDefaultBasePath = "https://tpu.googleapis.com/v1/" -var VPCAccessDefaultBasePath = "https://vpcaccess.googleapis.com/v1/" -var WorkflowsDefaultBasePath = "https://workflows.googleapis.com/v1/" +var DefaultBasePaths = map[string]string{ + AccessApprovalBasePathKey: "https://accessapproval.googleapis.com/v1/", + AccessContextManagerBasePathKey: "https://accesscontextmanager.googleapis.com/v1/", + ActiveDirectoryBasePathKey: "https://managedidentities.googleapis.com/v1/", + ApigeeBasePathKey: "https://apigee.googleapis.com/v1/", + AppEngineBasePathKey: "https://appengine.googleapis.com/v1/", + BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/", + BigqueryDataTransferBasePathKey: "https://bigquerydatatransfer.googleapis.com/v1/", + BigqueryReservationBasePathKey: "https://bigqueryreservation.googleapis.com/v1/", + BigtableBasePathKey: "https://bigtableadmin.googleapis.com/v2/", + BillingBasePathKey: "https://billingbudgets.googleapis.com/v1/", + BinaryAuthorizationBasePathKey: "https://binaryauthorization.googleapis.com/v1/", + CloudAssetBasePathKey: "https://cloudasset.googleapis.com/v1/", + CloudBuildBasePathKey: "https://cloudbuild.googleapis.com/v1/", + CloudFunctionsBasePathKey: "https://cloudfunctions.googleapis.com/v1/", + CloudIdentityBasePathKey: "https://cloudidentity.googleapis.com/v1/", + CloudIotBasePathKey: "https://cloudiot.googleapis.com/v1/", + CloudRunBasePathKey: "https://{{location}}-run.googleapis.com/", + CloudSchedulerBasePathKey: "https://cloudscheduler.googleapis.com/v1/", + CloudTasksBasePathKey: "https://cloudtasks.googleapis.com/v2/", + ComputeBasePathKey: "https://compute.googleapis.com/compute/v1/", + ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1/", + DataCatalogBasePathKey: "https://datacatalog.googleapis.com/v1/", + DataLossPreventionBasePathKey: "https://dlp.googleapis.com/v2/", + DataprocBasePathKey: "https://dataproc.googleapis.com/v1/", + DatastoreBasePathKey: "https://datastore.googleapis.com/v1/", + DeploymentManagerBasePathKey: "https://www.googleapis.com/deploymentmanager/v2/", + DialogflowBasePathKey: "https://dialogflow.googleapis.com/v2/", + DialogflowCXBasePathKey: "https://{{location}}-dialogflow.googleapis.com/v3/", + DNSBasePathKey: "https://dns.googleapis.com/dns/v1/", + FilestoreBasePathKey: "https://file.googleapis.com/v1/", + FirestoreBasePathKey: "https://firestore.googleapis.com/v1/", + GameServicesBasePathKey: "https://gameservices.googleapis.com/v1/", + HealthcareBasePathKey: "https://healthcare.googleapis.com/v1/", + IapBasePathKey: "https://iap.googleapis.com/v1/", + IdentityPlatformBasePathKey: "https://identitytoolkit.googleapis.com/v2/", + KMSBasePathKey: "https://cloudkms.googleapis.com/v1/", + LoggingBasePathKey: "https://logging.googleapis.com/v2/", + MemcacheBasePathKey: "https://memcache.googleapis.com/v1/", + MLEngineBasePathKey: "https://ml.googleapis.com/v1/", + MonitoringBasePathKey: "https://monitoring.googleapis.com/", + NetworkManagementBasePathKey: "https://networkmanagement.googleapis.com/v1/", + NotebooksBasePathKey: "https://notebooks.googleapis.com/v1/", + OSConfigBasePathKey: "https://osconfig.googleapis.com/v1/", + OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/", + PubsubBasePathKey: "https://pubsub.googleapis.com/v1/", + PubsubLiteBasePathKey: "https://{{region}}-pubsublite.googleapis.com/v1/admin/", + RedisBasePathKey: "https://redis.googleapis.com/v1/", + ResourceManagerBasePathKey: "https://cloudresourcemanager.googleapis.com/v1/", + RuntimeConfigBasePathKey: "https://runtimeconfig.googleapis.com/v1beta1/", + SecretManagerBasePathKey: "https://secretmanager.googleapis.com/v1/", + SecurityCenterBasePathKey: "https://securitycenter.googleapis.com/v1/", + ServiceManagementBasePathKey: "https://servicemanagement.googleapis.com/v1/", + ServiceUsageBasePathKey: "https://serviceusage.googleapis.com/v1/", + SourceRepoBasePathKey: "https://sourcerepo.googleapis.com/v1/", + SpannerBasePathKey: "https://spanner.googleapis.com/v1/", + SQLBasePathKey: "https://sqladmin.googleapis.com/sql/v1beta4/", + StorageBasePathKey: "https://storage.googleapis.com/storage/v1/", + TagsBasePathKey: "https://cloudresourcemanager.googleapis.com/v3/", + TPUBasePathKey: "https://tpu.googleapis.com/v1/", + VPCAccessBasePathKey: "https://vpcaccess.googleapis.com/v1/", + WorkflowsBasePathKey: "https://workflows.googleapis.com/v1/", + CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/", + ComposerBasePathKey: "https://composer.googleapis.com/v1/", + ComputeBetaBasePathKey: "https://www.googleapis.com/compute/beta/", + ContainerBasePathKey: "https://container.googleapis.com/v1/", + ContainerBetaBasePathKey: "https://container.googleapis.com/v1beta1/", + DataprocBetaBasePathKey: "https://dataproc.googleapis.com/v1beta2/", + DataflowBasePathKey: "https://dataflow.googleapis.com/v1b3/", + IAMBasePathKey: "https://iam.googleapis.com/v1/", + IamCredentialsBasePathKey: "https://iamcredentials.googleapis.com/v1/", + ResourceManagerV2BasePathKey: "https://cloudresourcemanager.googleapis.com/v2/", + ServiceNetworkingBasePathKey: "https://servicenetworking.googleapis.com/v1/", + StorageTransferBasePathKey: "https://storagetransfer.googleapis.com/v1/", + BigtableAdminBasePathKey: "https://bigtableadmin.googleapis.com/v2/", + GkeHubFeatureBasePathKey: "https://gkehub.googleapis.com/v1beta/", +} var DefaultClientScopes = []string{ "https://www.googleapis.com/auth/compute", @@ -254,9 +346,11 @@ func (c *Config) LoadAndValidate(ctx context.Context) error { cleanCtx := context.WithValue(ctx, oauth2.HTTPClient, cleanhttp.DefaultClient()) - // 1. OAUTH2 TRANSPORT/CLIENT - sets up proper auth headers - client := oauth2.NewClient(cleanCtx, tokenSource) - + // 1. MTLS TRANSPORT/CLIENT - sets up proper auth headers + client, _, err := transport.NewHTTPClient(cleanCtx, option.WithTokenSource(tokenSource)) + if err != nil { + return err + } // Userinfo is fetched before request logging is enabled to reduce additional noise. err = c.logGoogleIdentities() if err != nil { @@ -981,81 +1075,81 @@ func removeBasePathVersion(url string) string { // values to a default. After using this, you should call config.LoadAndValidate. func ConfigureBasePaths(c *Config) { // Generated Products - c.AccessApprovalBasePath = AccessApprovalDefaultBasePath - c.AccessContextManagerBasePath = AccessContextManagerDefaultBasePath - c.ActiveDirectoryBasePath = ActiveDirectoryDefaultBasePath - c.ApigeeBasePath = ApigeeDefaultBasePath - c.AppEngineBasePath = AppEngineDefaultBasePath - c.BigQueryBasePath = BigQueryDefaultBasePath - c.BigqueryDataTransferBasePath = BigqueryDataTransferDefaultBasePath - c.BigqueryReservationBasePath = BigqueryReservationDefaultBasePath - c.BigtableBasePath = BigtableDefaultBasePath - c.BillingBasePath = BillingDefaultBasePath - c.BinaryAuthorizationBasePath = BinaryAuthorizationDefaultBasePath - c.CloudAssetBasePath = CloudAssetDefaultBasePath - c.CloudBuildBasePath = CloudBuildDefaultBasePath - c.CloudFunctionsBasePath = CloudFunctionsDefaultBasePath - c.CloudIdentityBasePath = CloudIdentityDefaultBasePath - c.CloudIotBasePath = CloudIotDefaultBasePath - c.CloudRunBasePath = CloudRunDefaultBasePath - c.CloudSchedulerBasePath = CloudSchedulerDefaultBasePath - c.CloudTasksBasePath = CloudTasksDefaultBasePath - c.ComputeBasePath = ComputeDefaultBasePath - c.ContainerAnalysisBasePath = ContainerAnalysisDefaultBasePath - c.DataCatalogBasePath = DataCatalogDefaultBasePath - c.DataLossPreventionBasePath = DataLossPreventionDefaultBasePath - c.DataprocBasePath = DataprocDefaultBasePath - c.DatastoreBasePath = DatastoreDefaultBasePath - c.DeploymentManagerBasePath = DeploymentManagerDefaultBasePath - c.DialogflowBasePath = DialogflowDefaultBasePath - c.DialogflowCXBasePath = DialogflowCXDefaultBasePath - c.DNSBasePath = DNSDefaultBasePath - c.FilestoreBasePath = FilestoreDefaultBasePath - c.FirestoreBasePath = FirestoreDefaultBasePath - c.GameServicesBasePath = GameServicesDefaultBasePath - c.HealthcareBasePath = HealthcareDefaultBasePath - c.IapBasePath = IapDefaultBasePath - c.IdentityPlatformBasePath = IdentityPlatformDefaultBasePath - c.KMSBasePath = KMSDefaultBasePath - c.LoggingBasePath = LoggingDefaultBasePath - c.MemcacheBasePath = MemcacheDefaultBasePath - c.MLEngineBasePath = MLEngineDefaultBasePath - c.MonitoringBasePath = MonitoringDefaultBasePath - c.NetworkManagementBasePath = NetworkManagementDefaultBasePath - c.NotebooksBasePath = NotebooksDefaultBasePath - c.OSConfigBasePath = OSConfigDefaultBasePath - c.OSLoginBasePath = OSLoginDefaultBasePath - c.PubsubBasePath = PubsubDefaultBasePath - c.PubsubLiteBasePath = PubsubLiteDefaultBasePath - c.RedisBasePath = RedisDefaultBasePath - c.ResourceManagerBasePath = ResourceManagerDefaultBasePath - c.RuntimeConfigBasePath = RuntimeConfigDefaultBasePath - c.SecretManagerBasePath = SecretManagerDefaultBasePath - c.SecurityCenterBasePath = SecurityCenterDefaultBasePath - c.ServiceManagementBasePath = ServiceManagementDefaultBasePath - c.ServiceUsageBasePath = ServiceUsageDefaultBasePath - c.SourceRepoBasePath = SourceRepoDefaultBasePath - c.SpannerBasePath = SpannerDefaultBasePath - c.SQLBasePath = SQLDefaultBasePath - c.StorageBasePath = StorageDefaultBasePath - c.TagsBasePath = TagsDefaultBasePath - c.TPUBasePath = TPUDefaultBasePath - c.VPCAccessBasePath = VPCAccessDefaultBasePath - c.WorkflowsBasePath = WorkflowsDefaultBasePath + c.AccessApprovalBasePath = DefaultBasePaths[AccessApprovalBasePathKey] + c.AccessContextManagerBasePath = DefaultBasePaths[AccessContextManagerBasePathKey] + c.ActiveDirectoryBasePath = DefaultBasePaths[ActiveDirectoryBasePathKey] + c.ApigeeBasePath = DefaultBasePaths[ApigeeBasePathKey] + c.AppEngineBasePath = DefaultBasePaths[AppEngineBasePathKey] + c.BigQueryBasePath = DefaultBasePaths[BigQueryBasePathKey] + c.BigqueryDataTransferBasePath = DefaultBasePaths[BigqueryDataTransferBasePathKey] + c.BigqueryReservationBasePath = DefaultBasePaths[BigqueryReservationBasePathKey] + c.BigtableBasePath = DefaultBasePaths[BigtableBasePathKey] + c.BillingBasePath = DefaultBasePaths[BillingBasePathKey] + c.BinaryAuthorizationBasePath = DefaultBasePaths[BinaryAuthorizationBasePathKey] + c.CloudAssetBasePath = DefaultBasePaths[CloudAssetBasePathKey] + c.CloudBuildBasePath = DefaultBasePaths[CloudBuildBasePathKey] + c.CloudFunctionsBasePath = DefaultBasePaths[CloudFunctionsBasePathKey] + c.CloudIdentityBasePath = DefaultBasePaths[CloudIdentityBasePathKey] + c.CloudIotBasePath = DefaultBasePaths[CloudIotBasePathKey] + c.CloudRunBasePath = DefaultBasePaths[CloudRunBasePathKey] + c.CloudSchedulerBasePath = DefaultBasePaths[CloudSchedulerBasePathKey] + c.CloudTasksBasePath = DefaultBasePaths[CloudTasksBasePathKey] + c.ComputeBasePath = DefaultBasePaths[ComputeBasePathKey] + c.ContainerAnalysisBasePath = DefaultBasePaths[ContainerAnalysisBasePathKey] + c.DataCatalogBasePath = DefaultBasePaths[DataCatalogBasePathKey] + c.DataLossPreventionBasePath = DefaultBasePaths[DataLossPreventionBasePathKey] + c.DataprocBasePath = DefaultBasePaths[DataprocBasePathKey] + c.DatastoreBasePath = DefaultBasePaths[DatastoreBasePathKey] + c.DeploymentManagerBasePath = DefaultBasePaths[DeploymentManagerBasePathKey] + c.DialogflowBasePath = DefaultBasePaths[DialogflowBasePathKey] + c.DialogflowCXBasePath = DefaultBasePaths[DialogflowCXBasePathKey] + c.DNSBasePath = DefaultBasePaths[DNSBasePathKey] + c.FilestoreBasePath = DefaultBasePaths[FilestoreBasePathKey] + c.FirestoreBasePath = DefaultBasePaths[FirestoreBasePathKey] + c.GameServicesBasePath = DefaultBasePaths[GameServicesBasePathKey] + c.HealthcareBasePath = DefaultBasePaths[HealthcareBasePathKey] + c.IapBasePath = DefaultBasePaths[IapBasePathKey] + c.IdentityPlatformBasePath = DefaultBasePaths[IdentityPlatformBasePathKey] + c.KMSBasePath = DefaultBasePaths[KMSBasePathKey] + c.LoggingBasePath = DefaultBasePaths[LoggingBasePathKey] + c.MemcacheBasePath = DefaultBasePaths[MemcacheBasePathKey] + c.MLEngineBasePath = DefaultBasePaths[MLEngineBasePathKey] + c.MonitoringBasePath = DefaultBasePaths[MonitoringBasePathKey] + c.NetworkManagementBasePath = DefaultBasePaths[NetworkManagementBasePathKey] + c.NotebooksBasePath = DefaultBasePaths[NotebooksBasePathKey] + c.OSConfigBasePath = DefaultBasePaths[OSConfigBasePathKey] + c.OSLoginBasePath = DefaultBasePaths[OSLoginBasePathKey] + c.PubsubBasePath = DefaultBasePaths[PubsubBasePathKey] + c.PubsubLiteBasePath = DefaultBasePaths[PubsubLiteBasePathKey] + c.RedisBasePath = DefaultBasePaths[RedisBasePathKey] + c.ResourceManagerBasePath = DefaultBasePaths[ResourceManagerBasePathKey] + c.RuntimeConfigBasePath = DefaultBasePaths[RuntimeConfigBasePathKey] + c.SecretManagerBasePath = DefaultBasePaths[SecretManagerBasePathKey] + c.SecurityCenterBasePath = DefaultBasePaths[SecurityCenterBasePathKey] + c.ServiceManagementBasePath = DefaultBasePaths[ServiceManagementBasePathKey] + c.ServiceUsageBasePath = DefaultBasePaths[ServiceUsageBasePathKey] + c.SourceRepoBasePath = DefaultBasePaths[SourceRepoBasePathKey] + c.SpannerBasePath = DefaultBasePaths[SpannerBasePathKey] + c.SQLBasePath = DefaultBasePaths[SQLBasePathKey] + c.StorageBasePath = DefaultBasePaths[StorageBasePathKey] + c.TagsBasePath = DefaultBasePaths[TagsBasePathKey] + c.TPUBasePath = DefaultBasePaths[TPUBasePathKey] + c.VPCAccessBasePath = DefaultBasePaths[VPCAccessBasePathKey] + c.WorkflowsBasePath = DefaultBasePaths[WorkflowsBasePathKey] // Handwritten Products / Versioned / Atypical Entries - c.CloudBillingBasePath = CloudBillingDefaultBasePath - c.ComposerBasePath = ComposerDefaultBasePath - c.ComputeBetaBasePath = ComputeBetaDefaultBasePath - c.ContainerBasePath = ContainerDefaultBasePath - c.ContainerBetaBasePath = ContainerBetaDefaultBasePath - c.DataprocBasePath = DataprocDefaultBasePath - c.DataflowBasePath = DataflowDefaultBasePath - c.IamCredentialsBasePath = IamCredentialsDefaultBasePath - c.ResourceManagerV2BasePath = ResourceManagerV2DefaultBasePath - c.IAMBasePath = IAMDefaultBasePath - c.ServiceNetworkingBasePath = ServiceNetworkingDefaultBasePath - c.BigQueryBasePath = BigQueryDefaultBasePath - c.StorageTransferBasePath = StorageTransferDefaultBasePath - c.BigtableAdminBasePath = BigtableAdminDefaultBasePath + c.CloudBillingBasePath = DefaultBasePaths[CloudBillingBasePathKey] + c.ComposerBasePath = DefaultBasePaths[ComposerBasePathKey] + c.ComputeBetaBasePath = DefaultBasePaths[ComputeBetaBasePathKey] + c.ContainerBasePath = DefaultBasePaths[ContainerBasePathKey] + c.ContainerBetaBasePath = DefaultBasePaths[ContainerBetaBasePathKey] + c.DataprocBasePath = DefaultBasePaths[DataprocBasePathKey] + c.DataflowBasePath = DefaultBasePaths[DataflowBasePathKey] + c.IamCredentialsBasePath = DefaultBasePaths[IamCredentialsBasePathKey] + c.ResourceManagerV2BasePath = DefaultBasePaths[ResourceManagerV2BasePathKey] + c.IAMBasePath = DefaultBasePaths[IAMBasePathKey] + c.ServiceNetworkingBasePath = DefaultBasePaths[ServiceNetworkingBasePathKey] + c.BigQueryBasePath = DefaultBasePaths[BigQueryBasePathKey] + c.StorageTransferBasePath = DefaultBasePaths[StorageTransferBasePathKey] + c.BigtableAdminBasePath = DefaultBasePaths[BigtableAdminBasePathKey] } diff --git a/google/provider_handwritten_endpoint.go b/google/provider_handwritten_endpoint.go index 36de885a8..d27531e70 100644 --- a/google/provider_handwritten_endpoint.go +++ b/google/provider_handwritten_endpoint.go @@ -8,7 +8,6 @@ import ( // files. Collect handwritten ones here. If any of these are modified, be sure // to update the provider_reference docs page. -var CloudBillingDefaultBasePath = "https://cloudbilling.googleapis.com/v1/" var CloudBillingCustomEndpointEntryKey = "cloud_billing_custom_endpoint" var CloudBillingCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -16,10 +15,9 @@ var CloudBillingCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_BILLING_CUSTOM_ENDPOINT", - }, CloudBillingDefaultBasePath), + }, DefaultBasePaths[CloudBillingBasePathKey]), } -var ComposerDefaultBasePath = "https://composer.googleapis.com/v1/" var ComposerCustomEndpointEntryKey = "composer_custom_endpoint" var ComposerCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -27,10 +25,9 @@ var ComposerCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_COMPOSER_CUSTOM_ENDPOINT", - }, ComposerDefaultBasePath), + }, DefaultBasePaths[ComposerBasePathKey]), } -var ComputeBetaDefaultBasePath = "https://www.googleapis.com/compute/beta/" var ComputeBetaCustomEndpointEntryKey = "compute_beta_custom_endpoint" var ComputeBetaCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -38,10 +35,9 @@ var ComputeBetaCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_COMPUTE_BETA_CUSTOM_ENDPOINT", - }, ComputeBetaDefaultBasePath), + }, DefaultBasePaths[ComputeBetaBasePathKey]), } -var ContainerDefaultBasePath = "https://container.googleapis.com/v1/" var ContainerCustomEndpointEntryKey = "container_custom_endpoint" var ContainerCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -49,10 +45,9 @@ var ContainerCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CONTAINER_CUSTOM_ENDPOINT", - }, ContainerDefaultBasePath), + }, DefaultBasePaths[ContainerBasePathKey]), } -var ContainerBetaDefaultBasePath = "https://container.googleapis.com/v1beta1/" var ContainerBetaCustomEndpointEntryKey = "container_beta_custom_endpoint" var ContainerBetaCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -60,10 +55,9 @@ var ContainerBetaCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CONTAINER_BETA_CUSTOM_ENDPOINT", - }, ContainerBetaDefaultBasePath), + }, DefaultBasePaths[ContainerBetaBasePathKey]), } -var DataprocBetaDefaultBasePath = "https://dataproc.googleapis.com/v1beta2/" var DataprocBetaCustomEndpointEntryKey = "dataproc_beta_custom_endpoint" var DataprocBetaCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -71,10 +65,9 @@ var DataprocBetaCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATAPROC_BETA_CUSTOM_ENDPOINT", - }, DataprocBetaDefaultBasePath), + }, DefaultBasePaths[DataprocBetaBasePathKey]), } -var DataflowDefaultBasePath = "https://dataflow.googleapis.com/v1b3/" var DataflowCustomEndpointEntryKey = "dataflow_custom_endpoint" var DataflowCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -82,10 +75,9 @@ var DataflowCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATAFLOW_CUSTOM_ENDPOINT", - }, DataflowDefaultBasePath), + }, DefaultBasePaths[DataflowBasePathKey]), } -var IAMDefaultBasePath = "https://iam.googleapis.com/v1/" var IAMCustomEndpointEntryKey = "iam_custom_endpoint" var IAMCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -93,10 +85,9 @@ var IAMCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_IAM_CUSTOM_ENDPOINT", - }, IAMDefaultBasePath), + }, DefaultBasePaths[IAMBasePathKey]), } -var IamCredentialsDefaultBasePath = "https://iamcredentials.googleapis.com/v1/" var IamCredentialsCustomEndpointEntryKey = "iam_credentials_custom_endpoint" var IamCredentialsCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -104,10 +95,9 @@ var IamCredentialsCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_IAM_CREDENTIALS_CUSTOM_ENDPOINT", - }, IamCredentialsDefaultBasePath), + }, DefaultBasePaths[IamCredentialsBasePathKey]), } -var ResourceManagerV2DefaultBasePath = "https://cloudresourcemanager.googleapis.com/v2/" var ResourceManagerV2CustomEndpointEntryKey = "resource_manager_v2_custom_endpoint" var ResourceManagerV2CustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -115,7 +105,7 @@ var ResourceManagerV2CustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_RESOURCE_MANAGER_V2_CUSTOM_ENDPOINT", - }, ResourceManagerV2DefaultBasePath), + }, DefaultBasePaths[ResourceManagerV2BasePathKey]), } var RuntimeConfigCustomEndpointEntryKey = "runtimeconfig_custom_endpoint" @@ -125,10 +115,9 @@ var RuntimeConfigCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_RUNTIMECONFIG_CUSTOM_ENDPOINT", - }, RuntimeConfigDefaultBasePath), + }, DefaultBasePaths[RuntimeConfigBasePathKey]), } -var ServiceNetworkingDefaultBasePath = "https://servicenetworking.googleapis.com/v1/" var ServiceNetworkingCustomEndpointEntryKey = "service_networking_custom_endpoint" var ServiceNetworkingCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -136,7 +125,7 @@ var ServiceNetworkingCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SERVICE_NETWORKING_CUSTOM_ENDPOINT", - }, ServiceNetworkingDefaultBasePath), + }, DefaultBasePaths[ServiceNetworkingBasePathKey]), } var ServiceUsageCustomEndpointEntryKey = "service_usage_custom_endpoint" @@ -146,10 +135,9 @@ var ServiceUsageCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SERVICE_USAGE_CUSTOM_ENDPOINT", - }, ServiceUsageDefaultBasePath), + }, DefaultBasePaths[ServiceUsageBasePathKey]), } -var StorageTransferDefaultBasePath = "https://storagetransfer.googleapis.com/v1/" var StorageTransferCustomEndpointEntryKey = "storage_transfer_custom_endpoint" var StorageTransferCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -157,10 +145,9 @@ var StorageTransferCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_STORAGE_TRANSFER_CUSTOM_ENDPOINT", - }, StorageTransferDefaultBasePath), + }, DefaultBasePaths[StorageTransferBasePathKey]), } -var BigtableAdminDefaultBasePath = "https://bigtableadmin.googleapis.com/v2/" var BigtableAdminCustomEndpointEntryKey = "bigtable_custom_endpoint" var BigtableAdminCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -168,22 +155,10 @@ var BigtableAdminCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIGTABLE_CUSTOM_ENDPOINT", - }, BigtableAdminDefaultBasePath), -} - -var EventarcDefaultBasePath = "https://eventarc.googleapis.com/v1/" -var EventarcCustomEndpointEntryKey = "eventarc_custom_endpoint" -var EventarcCustomEndpointEntry = &schema.Schema{ - Type: schema.TypeString, - Optional: true, - ValidateFunc: validateCustomEndpoint, - DefaultFunc: schema.MultiEnvDefaultFunc([]string{ - "GOOGLE_EVENTARC_CUSTOM_ENDPOINT", - }, EventarcDefaultBasePath), + }, DefaultBasePaths[BigtableAdminBasePathKey]), } // GkeHubFeature uses a different base path "v1beta" than GkeHubMembership "v1beta1" -var GkeHubFeatureDefaultBasePath = "https://gkehub.googleapis.com/v1beta/" var GkeHubFeatureCustomEndpointEntryKey = "gkehub_feature_custom_endpoint" var GkeHubFeatureCustomEndpointEntry = &schema.Schema{ Type: schema.TypeString, @@ -191,7 +166,7 @@ var GkeHubFeatureCustomEndpointEntry = &schema.Schema{ ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_GKEHUB_FEATURE_CUSTOM_ENDPOINT", - }, GkeHubFeatureDefaultBasePath), + }, DefaultBasePaths[GkeHubFeatureBasePathKey]), } func validateCustomEndpoint(v interface{}, k string) (ws []string, errors []error) {