diff --git a/.changelog/4869.txt b/.changelog/4869.txt new file mode 100644 index 0000000000..f24d45540b --- /dev/null +++ b/.changelog/4869.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +added support for [mtls authentication](https://google.aip.dev/auth/4114) +``` diff --git a/google-beta/config.go b/google-beta/config.go index 5a2d2953de..5d81d31df3 100644 --- a/google-beta/config.go +++ b/google-beta/config.go @@ -178,80 +178,184 @@ type Config struct { GkeHubBasePath string } +const AccessApprovalBasePathKey = "AccessApproval" +const AccessContextManagerBasePathKey = "AccessContextManager" +const ActiveDirectoryBasePathKey = "ActiveDirectory" +const ApiGatewayBasePathKey = "ApiGateway" +const ApigeeBasePathKey = "Apigee" +const AppEngineBasePathKey = "AppEngine" +const ArtifactRegistryBasePathKey = "ArtifactRegistry" +const BigQueryBasePathKey = "BigQuery" +const BigqueryConnectionBasePathKey = "BigqueryConnection" +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 DataFusionBasePathKey = "DataFusion" +const DataLossPreventionBasePathKey = "DataLossPrevention" +const DataprocBasePathKey = "Dataproc" +const DataprocMetastoreBasePathKey = "DataprocMetastore" +const DatastoreBasePathKey = "Datastore" +const DeploymentManagerBasePathKey = "DeploymentManager" +const DialogflowBasePathKey = "Dialogflow" +const DialogflowCXBasePathKey = "DialogflowCX" +const DNSBasePathKey = "DNS" +const EssentialContactsBasePathKey = "EssentialContacts" +const FilestoreBasePathKey = "Filestore" +const FirebaseBasePathKey = "Firebase" +const FirestoreBasePathKey = "Firestore" +const GameServicesBasePathKey = "GameServices" +const GKEHubBasePathKey = "GKEHub" +const HealthcareBasePathKey = "Healthcare" +const IAMBetaBasePathKey = "IAMBeta" +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 PrivatecaBasePathKey = "Privateca" +const PubsubBasePathKey = "Pubsub" +const PubsubLiteBasePathKey = "PubsubLite" +const RedisBasePathKey = "Redis" +const ResourceManagerBasePathKey = "ResourceManager" +const RuntimeConfigBasePathKey = "RuntimeConfig" +const SecretManagerBasePathKey = "SecretManager" +const SecurityCenterBasePathKey = "SecurityCenter" +const SecurityScannerBasePathKey = "SecurityScanner" +const ServiceDirectoryBasePathKey = "ServiceDirectory" +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 ApiGatewayDefaultBasePath = "https://apigateway.googleapis.com/v1beta/" -var ApigeeDefaultBasePath = "https://apigee.googleapis.com/v1/" -var AppEngineDefaultBasePath = "https://appengine.googleapis.com/v1/" -var ArtifactRegistryDefaultBasePath = "https://artifactregistry.googleapis.com/v1beta2/" -var BigQueryDefaultBasePath = "https://bigquery.googleapis.com/bigquery/v2/" -var BigqueryConnectionDefaultBasePath = "https://bigqueryconnection.googleapis.com/v1beta1/" -var BigqueryDataTransferDefaultBasePath = "https://bigquerydatatransfer.googleapis.com/v1/" -var BigqueryReservationDefaultBasePath = "https://bigqueryreservation.googleapis.com/v1beta1/" -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/v1beta1/" -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/beta/" -var ContainerAnalysisDefaultBasePath = "https://containeranalysis.googleapis.com/v1beta1/" -var DataCatalogDefaultBasePath = "https://datacatalog.googleapis.com/v1beta1/" -var DataFusionDefaultBasePath = "https://datafusion.googleapis.com/v1beta1/" -var DataLossPreventionDefaultBasePath = "https://dlp.googleapis.com/v2/" -var DataprocDefaultBasePath = "https://dataproc.googleapis.com/v1beta2/" -var DataprocMetastoreDefaultBasePath = "https://metastore.googleapis.com/v1beta/" -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/v1beta2/" -var EssentialContactsDefaultBasePath = "https://essentialcontacts.googleapis.com/v1beta1/" -var FilestoreDefaultBasePath = "https://file.googleapis.com/v1beta1/" -var FirebaseDefaultBasePath = "https://firebase.googleapis.com/v1beta1/" -var FirestoreDefaultBasePath = "https://firestore.googleapis.com/v1/" -var GameServicesDefaultBasePath = "https://gameservices.googleapis.com/v1beta/" -var GKEHubDefaultBasePath = "https://gkehub.googleapis.com/v1beta1/" -var HealthcareDefaultBasePath = "https://healthcare.googleapis.com/v1beta1/" -var IAMBetaDefaultBasePath = "https://iam.googleapis.com/v1beta/" -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/v1beta2/" -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/v1beta1/" -var OSConfigDefaultBasePath = "https://osconfig.googleapis.com/v1beta/" -var OSLoginDefaultBasePath = "https://oslogin.googleapis.com/v1/" -var PrivatecaDefaultBasePath = "https://privateca.googleapis.com/v1beta1/" -var PubsubDefaultBasePath = "https://pubsub.googleapis.com/v1/" -var PubsubLiteDefaultBasePath = "https://{{region}}-pubsublite.googleapis.com/v1/admin/" -var RedisDefaultBasePath = "https://redis.googleapis.com/v1beta1/" -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 SecurityScannerDefaultBasePath = "https://websecurityscanner.googleapis.com/v1beta/" -var ServiceDirectoryDefaultBasePath = "https://servicedirectory.googleapis.com/v1beta1/" -var ServiceManagementDefaultBasePath = "https://servicemanagement.googleapis.com/v1/" -var ServiceUsageDefaultBasePath = "https://serviceusage.googleapis.com/v1beta1/" -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/v1beta1/" -var WorkflowsDefaultBasePath = "https://workflows.googleapis.com/v1beta/" +var DefaultBasePaths = map[string]string{ + AccessApprovalBasePathKey: "https://accessapproval.googleapis.com/v1/", + AccessContextManagerBasePathKey: "https://accesscontextmanager.googleapis.com/v1/", + ActiveDirectoryBasePathKey: "https://managedidentities.googleapis.com/v1/", + ApiGatewayBasePathKey: "https://apigateway.googleapis.com/v1beta/", + ApigeeBasePathKey: "https://apigee.googleapis.com/v1/", + AppEngineBasePathKey: "https://appengine.googleapis.com/v1/", + ArtifactRegistryBasePathKey: "https://artifactregistry.googleapis.com/v1beta2/", + BigQueryBasePathKey: "https://bigquery.googleapis.com/bigquery/v2/", + BigqueryConnectionBasePathKey: "https://bigqueryconnection.googleapis.com/v1beta1/", + BigqueryDataTransferBasePathKey: "https://bigquerydatatransfer.googleapis.com/v1/", + BigqueryReservationBasePathKey: "https://bigqueryreservation.googleapis.com/v1beta1/", + 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/v1beta1/", + 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/beta/", + ContainerAnalysisBasePathKey: "https://containeranalysis.googleapis.com/v1beta1/", + DataCatalogBasePathKey: "https://datacatalog.googleapis.com/v1beta1/", + DataFusionBasePathKey: "https://datafusion.googleapis.com/v1beta1/", + DataLossPreventionBasePathKey: "https://dlp.googleapis.com/v2/", + DataprocBasePathKey: "https://dataproc.googleapis.com/v1beta2/", + DataprocMetastoreBasePathKey: "https://metastore.googleapis.com/v1beta/", + 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/v1beta2/", + EssentialContactsBasePathKey: "https://essentialcontacts.googleapis.com/v1beta1/", + FilestoreBasePathKey: "https://file.googleapis.com/v1beta1/", + FirebaseBasePathKey: "https://firebase.googleapis.com/v1beta1/", + FirestoreBasePathKey: "https://firestore.googleapis.com/v1/", + GameServicesBasePathKey: "https://gameservices.googleapis.com/v1beta/", + GKEHubBasePathKey: "https://gkehub.googleapis.com/v1beta1/", + HealthcareBasePathKey: "https://healthcare.googleapis.com/v1beta1/", + IAMBetaBasePathKey: "https://iam.googleapis.com/v1beta/", + 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/v1beta2/", + MLEngineBasePathKey: "https://ml.googleapis.com/v1/", + MonitoringBasePathKey: "https://monitoring.googleapis.com/", + NetworkManagementBasePathKey: "https://networkmanagement.googleapis.com/v1/", + NotebooksBasePathKey: "https://notebooks.googleapis.com/v1beta1/", + OSConfigBasePathKey: "https://osconfig.googleapis.com/v1beta/", + OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/", + PrivatecaBasePathKey: "https://privateca.googleapis.com/v1beta1/", + PubsubBasePathKey: "https://pubsub.googleapis.com/v1/", + PubsubLiteBasePathKey: "https://{{region}}-pubsublite.googleapis.com/v1/admin/", + RedisBasePathKey: "https://redis.googleapis.com/v1beta1/", + ResourceManagerBasePathKey: "https://cloudresourcemanager.googleapis.com/v1/", + RuntimeConfigBasePathKey: "https://runtimeconfig.googleapis.com/v1beta1/", + SecretManagerBasePathKey: "https://secretmanager.googleapis.com/v1/", + SecurityCenterBasePathKey: "https://securitycenter.googleapis.com/v1/", + SecurityScannerBasePathKey: "https://websecurityscanner.googleapis.com/v1beta/", + ServiceDirectoryBasePathKey: "https://servicedirectory.googleapis.com/v1beta1/", + ServiceManagementBasePathKey: "https://servicemanagement.googleapis.com/v1/", + ServiceUsageBasePathKey: "https://serviceusage.googleapis.com/v1beta1/", + 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/v1beta1/", + WorkflowsBasePathKey: "https://workflows.googleapis.com/v1beta/", + CloudBillingBasePathKey: "https://cloudbilling.googleapis.com/v1/", + ComposerBasePathKey: "https://composer.googleapis.com/v1beta1/", + 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", @@ -278,9 +382,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 { @@ -1005,93 +1111,93 @@ 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.ApiGatewayBasePath = ApiGatewayDefaultBasePath - c.ApigeeBasePath = ApigeeDefaultBasePath - c.AppEngineBasePath = AppEngineDefaultBasePath - c.ArtifactRegistryBasePath = ArtifactRegistryDefaultBasePath - c.BigQueryBasePath = BigQueryDefaultBasePath - c.BigqueryConnectionBasePath = BigqueryConnectionDefaultBasePath - 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.DataFusionBasePath = DataFusionDefaultBasePath - c.DataLossPreventionBasePath = DataLossPreventionDefaultBasePath - c.DataprocBasePath = DataprocDefaultBasePath - c.DataprocMetastoreBasePath = DataprocMetastoreDefaultBasePath - c.DatastoreBasePath = DatastoreDefaultBasePath - c.DeploymentManagerBasePath = DeploymentManagerDefaultBasePath - c.DialogflowBasePath = DialogflowDefaultBasePath - c.DialogflowCXBasePath = DialogflowCXDefaultBasePath - c.DNSBasePath = DNSDefaultBasePath - c.EssentialContactsBasePath = EssentialContactsDefaultBasePath - c.FilestoreBasePath = FilestoreDefaultBasePath - c.FirebaseBasePath = FirebaseDefaultBasePath - c.FirestoreBasePath = FirestoreDefaultBasePath - c.GameServicesBasePath = GameServicesDefaultBasePath - c.GKEHubBasePath = GKEHubDefaultBasePath - c.HealthcareBasePath = HealthcareDefaultBasePath - c.IAMBetaBasePath = IAMBetaDefaultBasePath - 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.PrivatecaBasePath = PrivatecaDefaultBasePath - c.PubsubBasePath = PubsubDefaultBasePath - c.PubsubLiteBasePath = PubsubLiteDefaultBasePath - c.RedisBasePath = RedisDefaultBasePath - c.ResourceManagerBasePath = ResourceManagerDefaultBasePath - c.RuntimeConfigBasePath = RuntimeConfigDefaultBasePath - c.SecretManagerBasePath = SecretManagerDefaultBasePath - c.SecurityCenterBasePath = SecurityCenterDefaultBasePath - c.SecurityScannerBasePath = SecurityScannerDefaultBasePath - c.ServiceDirectoryBasePath = ServiceDirectoryDefaultBasePath - 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.ApiGatewayBasePath = DefaultBasePaths[ApiGatewayBasePathKey] + c.ApigeeBasePath = DefaultBasePaths[ApigeeBasePathKey] + c.AppEngineBasePath = DefaultBasePaths[AppEngineBasePathKey] + c.ArtifactRegistryBasePath = DefaultBasePaths[ArtifactRegistryBasePathKey] + c.BigQueryBasePath = DefaultBasePaths[BigQueryBasePathKey] + c.BigqueryConnectionBasePath = DefaultBasePaths[BigqueryConnectionBasePathKey] + 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.DataFusionBasePath = DefaultBasePaths[DataFusionBasePathKey] + c.DataLossPreventionBasePath = DefaultBasePaths[DataLossPreventionBasePathKey] + c.DataprocBasePath = DefaultBasePaths[DataprocBasePathKey] + c.DataprocMetastoreBasePath = DefaultBasePaths[DataprocMetastoreBasePathKey] + c.DatastoreBasePath = DefaultBasePaths[DatastoreBasePathKey] + c.DeploymentManagerBasePath = DefaultBasePaths[DeploymentManagerBasePathKey] + c.DialogflowBasePath = DefaultBasePaths[DialogflowBasePathKey] + c.DialogflowCXBasePath = DefaultBasePaths[DialogflowCXBasePathKey] + c.DNSBasePath = DefaultBasePaths[DNSBasePathKey] + c.EssentialContactsBasePath = DefaultBasePaths[EssentialContactsBasePathKey] + c.FilestoreBasePath = DefaultBasePaths[FilestoreBasePathKey] + c.FirebaseBasePath = DefaultBasePaths[FirebaseBasePathKey] + c.FirestoreBasePath = DefaultBasePaths[FirestoreBasePathKey] + c.GameServicesBasePath = DefaultBasePaths[GameServicesBasePathKey] + c.GKEHubBasePath = DefaultBasePaths[GKEHubBasePathKey] + c.HealthcareBasePath = DefaultBasePaths[HealthcareBasePathKey] + c.IAMBetaBasePath = DefaultBasePaths[IAMBetaBasePathKey] + 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.PrivatecaBasePath = DefaultBasePaths[PrivatecaBasePathKey] + 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.SecurityScannerBasePath = DefaultBasePaths[SecurityScannerBasePathKey] + c.ServiceDirectoryBasePath = DefaultBasePaths[ServiceDirectoryBasePathKey] + 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-beta/mtls_util.go b/google-beta/mtls_util.go new file mode 100644 index 0000000000..a5ef1d9332 --- /dev/null +++ b/google-beta/mtls_util.go @@ -0,0 +1,46 @@ +package google + +import ( + "context" + "fmt" + "net/url" + "strings" + + "google.golang.org/api/option/internaloption" + "google.golang.org/api/transport" +) + +// The transport libaray does not natively expose logic to determine whether +// the user is within mtls mode or not. They do return the mtls endpoint if +// it is enabled during client creation so we will use this logic to determine +// the mode the user is in and throw away the client they give us back. +func isMtls() bool { + regularEndpoint := "https://mockservice.googleapis.com/v1/" + mtlsEndpoint := getMtlsEndpoint(regularEndpoint) + _, endpoint, err := transport.NewHTTPClient(context.Background(), + internaloption.WithDefaultEndpoint(regularEndpoint), + internaloption.WithDefaultMTLSEndpoint(mtlsEndpoint), + ) + if err != nil { + return false + } + isMtls := endpoint == mtlsEndpoint + return isMtls +} + +func getMtlsEndpoint(baseEndpoint string) string { + u, err := url.Parse(baseEndpoint) + if err != nil { + if strings.Contains(baseEndpoint, ".googleapis") { + return strings.Replace(baseEndpoint, ".googleapis", ".mtls.googleapis", 1) + } + return baseEndpoint + } + domainParts := strings.Split(u.Host, ".") + if len(domainParts) > 1 { + u.Host = fmt.Sprintf("%s.mtls.%s", domainParts[0], strings.Join(domainParts[1:], ".")) + } else { + u.Host = fmt.Sprintf("%s.mtls", domainParts[0]) + } + return u.String() +} diff --git a/google-beta/mtls_util_test.go b/google-beta/mtls_util_test.go new file mode 100644 index 0000000000..d1e4b9cfdc --- /dev/null +++ b/google-beta/mtls_util_test.go @@ -0,0 +1,16 @@ +package google + +import ( + "strings" + "testing" +) + +func TestUnitMtls_urlSwitching(t *testing.T) { + t.Parallel() + for key, bp := range DefaultBasePaths { + url := getMtlsEndpoint(bp) + if !strings.Contains(url, ".mtls.") { + t.Errorf("%s: mtls conversion unsuccessful preconv - %s postconv - %s", key, bp, url) + } + } +} diff --git a/google-beta/provider.go b/google-beta/provider.go index 3899b58cf5..ba4f6f9229 100644 --- a/google-beta/provider.go +++ b/google-beta/provider.go @@ -20,6 +20,18 @@ var mutexKV = NewMutexKV() // Provider returns a *schema.Provider. func Provider() *schema.Provider { + + // The mtls service client gives the type of endpoint (mtls/regular) + // at client creation. Since we use a shared client for requests we must + // rewrite the endpoints to be mtls endpoints for the scenario where + // mtls is enabled. + if isMtls() { + // if mtls is enabled switch all default endpoints to use the mtls endpoint + for key, bp := range DefaultBasePaths { + DefaultBasePaths[key] = getMtlsEndpoint(bp) + } + } + provider := &schema.Provider{ Schema: map[string]*schema.Schema{ "credentials": { @@ -133,7 +145,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ACCESS_APPROVAL_CUSTOM_ENDPOINT", - }, AccessApprovalDefaultBasePath), + }, DefaultBasePaths[AccessApprovalBasePathKey]), }, "access_context_manager_custom_endpoint": { Type: schema.TypeString, @@ -141,7 +153,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ACCESS_CONTEXT_MANAGER_CUSTOM_ENDPOINT", - }, AccessContextManagerDefaultBasePath), + }, DefaultBasePaths[AccessContextManagerBasePathKey]), }, "active_directory_custom_endpoint": { Type: schema.TypeString, @@ -149,7 +161,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ACTIVE_DIRECTORY_CUSTOM_ENDPOINT", - }, ActiveDirectoryDefaultBasePath), + }, DefaultBasePaths[ActiveDirectoryBasePathKey]), }, "api_gateway_custom_endpoint": { Type: schema.TypeString, @@ -157,7 +169,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_API_GATEWAY_CUSTOM_ENDPOINT", - }, ApiGatewayDefaultBasePath), + }, DefaultBasePaths[ApiGatewayBasePathKey]), }, "apigee_custom_endpoint": { Type: schema.TypeString, @@ -165,7 +177,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_APIGEE_CUSTOM_ENDPOINT", - }, ApigeeDefaultBasePath), + }, DefaultBasePaths[ApigeeBasePathKey]), }, "app_engine_custom_endpoint": { Type: schema.TypeString, @@ -173,7 +185,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_APP_ENGINE_CUSTOM_ENDPOINT", - }, AppEngineDefaultBasePath), + }, DefaultBasePaths[AppEngineBasePathKey]), }, "artifact_registry_custom_endpoint": { Type: schema.TypeString, @@ -181,7 +193,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ARTIFACT_REGISTRY_CUSTOM_ENDPOINT", - }, ArtifactRegistryDefaultBasePath), + }, DefaultBasePaths[ArtifactRegistryBasePathKey]), }, "big_query_custom_endpoint": { Type: schema.TypeString, @@ -189,7 +201,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIG_QUERY_CUSTOM_ENDPOINT", - }, BigQueryDefaultBasePath), + }, DefaultBasePaths[BigQueryBasePathKey]), }, "bigquery_connection_custom_endpoint": { Type: schema.TypeString, @@ -197,7 +209,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIGQUERY_CONNECTION_CUSTOM_ENDPOINT", - }, BigqueryConnectionDefaultBasePath), + }, DefaultBasePaths[BigqueryConnectionBasePathKey]), }, "bigquery_data_transfer_custom_endpoint": { Type: schema.TypeString, @@ -205,7 +217,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIGQUERY_DATA_TRANSFER_CUSTOM_ENDPOINT", - }, BigqueryDataTransferDefaultBasePath), + }, DefaultBasePaths[BigqueryDataTransferBasePathKey]), }, "bigquery_reservation_custom_endpoint": { Type: schema.TypeString, @@ -213,7 +225,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIGQUERY_RESERVATION_CUSTOM_ENDPOINT", - }, BigqueryReservationDefaultBasePath), + }, DefaultBasePaths[BigqueryReservationBasePathKey]), }, "bigtable_custom_endpoint": { Type: schema.TypeString, @@ -221,7 +233,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BIGTABLE_CUSTOM_ENDPOINT", - }, BigtableDefaultBasePath), + }, DefaultBasePaths[BigtableBasePathKey]), }, "billing_custom_endpoint": { Type: schema.TypeString, @@ -229,7 +241,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BILLING_CUSTOM_ENDPOINT", - }, BillingDefaultBasePath), + }, DefaultBasePaths[BillingBasePathKey]), }, "binary_authorization_custom_endpoint": { Type: schema.TypeString, @@ -237,7 +249,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_BINARY_AUTHORIZATION_CUSTOM_ENDPOINT", - }, BinaryAuthorizationDefaultBasePath), + }, DefaultBasePaths[BinaryAuthorizationBasePathKey]), }, "cloud_asset_custom_endpoint": { Type: schema.TypeString, @@ -245,7 +257,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_ASSET_CUSTOM_ENDPOINT", - }, CloudAssetDefaultBasePath), + }, DefaultBasePaths[CloudAssetBasePathKey]), }, "cloud_build_custom_endpoint": { Type: schema.TypeString, @@ -253,7 +265,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_BUILD_CUSTOM_ENDPOINT", - }, CloudBuildDefaultBasePath), + }, DefaultBasePaths[CloudBuildBasePathKey]), }, "cloud_functions_custom_endpoint": { Type: schema.TypeString, @@ -261,7 +273,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_FUNCTIONS_CUSTOM_ENDPOINT", - }, CloudFunctionsDefaultBasePath), + }, DefaultBasePaths[CloudFunctionsBasePathKey]), }, "cloud_identity_custom_endpoint": { Type: schema.TypeString, @@ -269,7 +281,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_IDENTITY_CUSTOM_ENDPOINT", - }, CloudIdentityDefaultBasePath), + }, DefaultBasePaths[CloudIdentityBasePathKey]), }, "cloud_iot_custom_endpoint": { Type: schema.TypeString, @@ -277,7 +289,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_IOT_CUSTOM_ENDPOINT", - }, CloudIotDefaultBasePath), + }, DefaultBasePaths[CloudIotBasePathKey]), }, "cloud_run_custom_endpoint": { Type: schema.TypeString, @@ -285,7 +297,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_RUN_CUSTOM_ENDPOINT", - }, CloudRunDefaultBasePath), + }, DefaultBasePaths[CloudRunBasePathKey]), }, "cloud_scheduler_custom_endpoint": { Type: schema.TypeString, @@ -293,7 +305,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_SCHEDULER_CUSTOM_ENDPOINT", - }, CloudSchedulerDefaultBasePath), + }, DefaultBasePaths[CloudSchedulerBasePathKey]), }, "cloud_tasks_custom_endpoint": { Type: schema.TypeString, @@ -301,7 +313,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CLOUD_TASKS_CUSTOM_ENDPOINT", - }, CloudTasksDefaultBasePath), + }, DefaultBasePaths[CloudTasksBasePathKey]), }, "compute_custom_endpoint": { Type: schema.TypeString, @@ -309,7 +321,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_COMPUTE_CUSTOM_ENDPOINT", - }, ComputeDefaultBasePath), + }, DefaultBasePaths[ComputeBasePathKey]), }, "container_analysis_custom_endpoint": { Type: schema.TypeString, @@ -317,7 +329,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_CONTAINER_ANALYSIS_CUSTOM_ENDPOINT", - }, ContainerAnalysisDefaultBasePath), + }, DefaultBasePaths[ContainerAnalysisBasePathKey]), }, "data_catalog_custom_endpoint": { Type: schema.TypeString, @@ -325,7 +337,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATA_CATALOG_CUSTOM_ENDPOINT", - }, DataCatalogDefaultBasePath), + }, DefaultBasePaths[DataCatalogBasePathKey]), }, "data_fusion_custom_endpoint": { Type: schema.TypeString, @@ -333,7 +345,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATA_FUSION_CUSTOM_ENDPOINT", - }, DataFusionDefaultBasePath), + }, DefaultBasePaths[DataFusionBasePathKey]), }, "data_loss_prevention_custom_endpoint": { Type: schema.TypeString, @@ -341,7 +353,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATA_LOSS_PREVENTION_CUSTOM_ENDPOINT", - }, DataLossPreventionDefaultBasePath), + }, DefaultBasePaths[DataLossPreventionBasePathKey]), }, "dataproc_custom_endpoint": { Type: schema.TypeString, @@ -349,7 +361,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATAPROC_CUSTOM_ENDPOINT", - }, DataprocDefaultBasePath), + }, DefaultBasePaths[DataprocBasePathKey]), }, "dataproc_metastore_custom_endpoint": { Type: schema.TypeString, @@ -357,7 +369,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATAPROC_METASTORE_CUSTOM_ENDPOINT", - }, DataprocMetastoreDefaultBasePath), + }, DefaultBasePaths[DataprocMetastoreBasePathKey]), }, "datastore_custom_endpoint": { Type: schema.TypeString, @@ -365,7 +377,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DATASTORE_CUSTOM_ENDPOINT", - }, DatastoreDefaultBasePath), + }, DefaultBasePaths[DatastoreBasePathKey]), }, "deployment_manager_custom_endpoint": { Type: schema.TypeString, @@ -373,7 +385,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DEPLOYMENT_MANAGER_CUSTOM_ENDPOINT", - }, DeploymentManagerDefaultBasePath), + }, DefaultBasePaths[DeploymentManagerBasePathKey]), }, "dialogflow_custom_endpoint": { Type: schema.TypeString, @@ -381,7 +393,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DIALOGFLOW_CUSTOM_ENDPOINT", - }, DialogflowDefaultBasePath), + }, DefaultBasePaths[DialogflowBasePathKey]), }, "dialogflow_cx_custom_endpoint": { Type: schema.TypeString, @@ -389,7 +401,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DIALOGFLOW_CX_CUSTOM_ENDPOINT", - }, DialogflowCXDefaultBasePath), + }, DefaultBasePaths[DialogflowCXBasePathKey]), }, "dns_custom_endpoint": { Type: schema.TypeString, @@ -397,7 +409,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_DNS_CUSTOM_ENDPOINT", - }, DNSDefaultBasePath), + }, DefaultBasePaths[DNSBasePathKey]), }, "essential_contacts_custom_endpoint": { Type: schema.TypeString, @@ -405,7 +417,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ESSENTIAL_CONTACTS_CUSTOM_ENDPOINT", - }, EssentialContactsDefaultBasePath), + }, DefaultBasePaths[EssentialContactsBasePathKey]), }, "filestore_custom_endpoint": { Type: schema.TypeString, @@ -413,7 +425,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_FILESTORE_CUSTOM_ENDPOINT", - }, FilestoreDefaultBasePath), + }, DefaultBasePaths[FilestoreBasePathKey]), }, "firebase_custom_endpoint": { Type: schema.TypeString, @@ -421,7 +433,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_FIREBASE_CUSTOM_ENDPOINT", - }, FirebaseDefaultBasePath), + }, DefaultBasePaths[FirebaseBasePathKey]), }, "firestore_custom_endpoint": { Type: schema.TypeString, @@ -429,7 +441,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_FIRESTORE_CUSTOM_ENDPOINT", - }, FirestoreDefaultBasePath), + }, DefaultBasePaths[FirestoreBasePathKey]), }, "game_services_custom_endpoint": { Type: schema.TypeString, @@ -437,7 +449,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_GAME_SERVICES_CUSTOM_ENDPOINT", - }, GameServicesDefaultBasePath), + }, DefaultBasePaths[GameServicesBasePathKey]), }, "gke_hub_custom_endpoint": { Type: schema.TypeString, @@ -445,7 +457,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_GKE_HUB_CUSTOM_ENDPOINT", - }, GKEHubDefaultBasePath), + }, DefaultBasePaths[GKEHubBasePathKey]), }, "healthcare_custom_endpoint": { Type: schema.TypeString, @@ -453,7 +465,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_HEALTHCARE_CUSTOM_ENDPOINT", - }, HealthcareDefaultBasePath), + }, DefaultBasePaths[HealthcareBasePathKey]), }, "iam_beta_custom_endpoint": { Type: schema.TypeString, @@ -461,7 +473,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_IAM_BETA_CUSTOM_ENDPOINT", - }, IAMBetaDefaultBasePath), + }, DefaultBasePaths[IAMBetaBasePathKey]), }, "iap_custom_endpoint": { Type: schema.TypeString, @@ -469,7 +481,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_IAP_CUSTOM_ENDPOINT", - }, IapDefaultBasePath), + }, DefaultBasePaths[IapBasePathKey]), }, "identity_platform_custom_endpoint": { Type: schema.TypeString, @@ -477,7 +489,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_IDENTITY_PLATFORM_CUSTOM_ENDPOINT", - }, IdentityPlatformDefaultBasePath), + }, DefaultBasePaths[IdentityPlatformBasePathKey]), }, "kms_custom_endpoint": { Type: schema.TypeString, @@ -485,7 +497,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_KMS_CUSTOM_ENDPOINT", - }, KMSDefaultBasePath), + }, DefaultBasePaths[KMSBasePathKey]), }, "logging_custom_endpoint": { Type: schema.TypeString, @@ -493,7 +505,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_LOGGING_CUSTOM_ENDPOINT", - }, LoggingDefaultBasePath), + }, DefaultBasePaths[LoggingBasePathKey]), }, "memcache_custom_endpoint": { Type: schema.TypeString, @@ -501,7 +513,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_MEMCACHE_CUSTOM_ENDPOINT", - }, MemcacheDefaultBasePath), + }, DefaultBasePaths[MemcacheBasePathKey]), }, "ml_engine_custom_endpoint": { Type: schema.TypeString, @@ -509,7 +521,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_ML_ENGINE_CUSTOM_ENDPOINT", - }, MLEngineDefaultBasePath), + }, DefaultBasePaths[MLEngineBasePathKey]), }, "monitoring_custom_endpoint": { Type: schema.TypeString, @@ -517,7 +529,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_MONITORING_CUSTOM_ENDPOINT", - }, MonitoringDefaultBasePath), + }, DefaultBasePaths[MonitoringBasePathKey]), }, "network_management_custom_endpoint": { Type: schema.TypeString, @@ -525,7 +537,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_NETWORK_MANAGEMENT_CUSTOM_ENDPOINT", - }, NetworkManagementDefaultBasePath), + }, DefaultBasePaths[NetworkManagementBasePathKey]), }, "notebooks_custom_endpoint": { Type: schema.TypeString, @@ -533,7 +545,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_NOTEBOOKS_CUSTOM_ENDPOINT", - }, NotebooksDefaultBasePath), + }, DefaultBasePaths[NotebooksBasePathKey]), }, "os_config_custom_endpoint": { Type: schema.TypeString, @@ -541,7 +553,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_OS_CONFIG_CUSTOM_ENDPOINT", - }, OSConfigDefaultBasePath), + }, DefaultBasePaths[OSConfigBasePathKey]), }, "os_login_custom_endpoint": { Type: schema.TypeString, @@ -549,7 +561,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_OS_LOGIN_CUSTOM_ENDPOINT", - }, OSLoginDefaultBasePath), + }, DefaultBasePaths[OSLoginBasePathKey]), }, "privateca_custom_endpoint": { Type: schema.TypeString, @@ -557,7 +569,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_PRIVATECA_CUSTOM_ENDPOINT", - }, PrivatecaDefaultBasePath), + }, DefaultBasePaths[PrivatecaBasePathKey]), }, "pubsub_custom_endpoint": { Type: schema.TypeString, @@ -565,7 +577,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_PUBSUB_CUSTOM_ENDPOINT", - }, PubsubDefaultBasePath), + }, DefaultBasePaths[PubsubBasePathKey]), }, "pubsub_lite_custom_endpoint": { Type: schema.TypeString, @@ -573,7 +585,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_PUBSUB_LITE_CUSTOM_ENDPOINT", - }, PubsubLiteDefaultBasePath), + }, DefaultBasePaths[PubsubLiteBasePathKey]), }, "redis_custom_endpoint": { Type: schema.TypeString, @@ -581,7 +593,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_REDIS_CUSTOM_ENDPOINT", - }, RedisDefaultBasePath), + }, DefaultBasePaths[RedisBasePathKey]), }, "resource_manager_custom_endpoint": { Type: schema.TypeString, @@ -589,7 +601,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_RESOURCE_MANAGER_CUSTOM_ENDPOINT", - }, ResourceManagerDefaultBasePath), + }, DefaultBasePaths[ResourceManagerBasePathKey]), }, "runtime_config_custom_endpoint": { Type: schema.TypeString, @@ -597,7 +609,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_RUNTIME_CONFIG_CUSTOM_ENDPOINT", - }, RuntimeConfigDefaultBasePath), + }, DefaultBasePaths[RuntimeConfigBasePathKey]), }, "secret_manager_custom_endpoint": { Type: schema.TypeString, @@ -605,7 +617,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SECRET_MANAGER_CUSTOM_ENDPOINT", - }, SecretManagerDefaultBasePath), + }, DefaultBasePaths[SecretManagerBasePathKey]), }, "security_center_custom_endpoint": { Type: schema.TypeString, @@ -613,7 +625,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SECURITY_CENTER_CUSTOM_ENDPOINT", - }, SecurityCenterDefaultBasePath), + }, DefaultBasePaths[SecurityCenterBasePathKey]), }, "security_scanner_custom_endpoint": { Type: schema.TypeString, @@ -621,7 +633,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SECURITY_SCANNER_CUSTOM_ENDPOINT", - }, SecurityScannerDefaultBasePath), + }, DefaultBasePaths[SecurityScannerBasePathKey]), }, "service_directory_custom_endpoint": { Type: schema.TypeString, @@ -629,7 +641,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SERVICE_DIRECTORY_CUSTOM_ENDPOINT", - }, ServiceDirectoryDefaultBasePath), + }, DefaultBasePaths[ServiceDirectoryBasePathKey]), }, "service_management_custom_endpoint": { Type: schema.TypeString, @@ -637,7 +649,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SERVICE_MANAGEMENT_CUSTOM_ENDPOINT", - }, ServiceManagementDefaultBasePath), + }, DefaultBasePaths[ServiceManagementBasePathKey]), }, "service_usage_custom_endpoint": { Type: schema.TypeString, @@ -645,7 +657,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SERVICE_USAGE_CUSTOM_ENDPOINT", - }, ServiceUsageDefaultBasePath), + }, DefaultBasePaths[ServiceUsageBasePathKey]), }, "source_repo_custom_endpoint": { Type: schema.TypeString, @@ -653,7 +665,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SOURCE_REPO_CUSTOM_ENDPOINT", - }, SourceRepoDefaultBasePath), + }, DefaultBasePaths[SourceRepoBasePathKey]), }, "spanner_custom_endpoint": { Type: schema.TypeString, @@ -661,7 +673,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SPANNER_CUSTOM_ENDPOINT", - }, SpannerDefaultBasePath), + }, DefaultBasePaths[SpannerBasePathKey]), }, "sql_custom_endpoint": { Type: schema.TypeString, @@ -669,7 +681,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_SQL_CUSTOM_ENDPOINT", - }, SQLDefaultBasePath), + }, DefaultBasePaths[SQLBasePathKey]), }, "storage_custom_endpoint": { Type: schema.TypeString, @@ -677,7 +689,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_STORAGE_CUSTOM_ENDPOINT", - }, StorageDefaultBasePath), + }, DefaultBasePaths[StorageBasePathKey]), }, "tags_custom_endpoint": { Type: schema.TypeString, @@ -685,7 +697,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_TAGS_CUSTOM_ENDPOINT", - }, TagsDefaultBasePath), + }, DefaultBasePaths[TagsBasePathKey]), }, "tpu_custom_endpoint": { Type: schema.TypeString, @@ -693,7 +705,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_TPU_CUSTOM_ENDPOINT", - }, TPUDefaultBasePath), + }, DefaultBasePaths[TPUBasePathKey]), }, "vpc_access_custom_endpoint": { Type: schema.TypeString, @@ -701,7 +713,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_VPC_ACCESS_CUSTOM_ENDPOINT", - }, VPCAccessDefaultBasePath), + }, DefaultBasePaths[VPCAccessBasePathKey]), }, "workflows_custom_endpoint": { Type: schema.TypeString, @@ -709,7 +721,7 @@ func Provider() *schema.Provider { ValidateFunc: validateCustomEndpoint, DefaultFunc: schema.MultiEnvDefaultFunc([]string{ "GOOGLE_WORKFLOWS_CUSTOM_ENDPOINT", - }, WorkflowsDefaultBasePath), + }, DefaultBasePaths[WorkflowsBasePathKey]), }, // Handwritten Products / Versioned / Atypical Entries diff --git a/google-beta/provider_dcl_endpoints.go b/google-beta/provider_dcl_endpoints.go index 8180e17e97..cec3b901a2 100644 --- a/google-beta/provider_dcl_endpoints.go +++ b/google-beta/provider_dcl_endpoints.go @@ -18,6 +18,9 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" ) +// empty string is passed for dcl default since dcl +// [hardcodes the values](https://github.com/GoogleCloudPlatform/declarative-resource-client-library/blob/main/services/google/eventarc/beta/trigger_internal.go#L96-L103) + var EventarcEndpointEntryKey = "eventarc_custom_endpoint" var EventarcEndpointEntry = &schema.Schema{ Type: schema.TypeString, diff --git a/google-beta/provider_handwritten_endpoint.go b/google-beta/provider_handwritten_endpoint.go index b53992f48c..d27531e703 100644 --- a/google-beta/provider_handwritten_endpoint.go +++ b/google-beta/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/v1beta1/" 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) { diff --git a/google-beta/resource_dataproc_cluster_test.go b/google-beta/resource_dataproc_cluster_test.go index 79b887900b..8f3596cc80 100644 --- a/google-beta/resource_dataproc_cluster_test.go +++ b/google-beta/resource_dataproc_cluster_test.go @@ -13,9 +13,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" - "google.golang.org/api/googleapi" - dataproc "google.golang.org/api/dataproc/v1beta2" + "google.golang.org/api/googleapi" ) func TestDataprocExtractInitTimeout(t *testing.T) { diff --git a/website/docs/guides/provider_reference.html.markdown b/website/docs/guides/provider_reference.html.markdown index 478211f0ce..42d127facb 100644 --- a/website/docs/guides/provider_reference.html.markdown +++ b/website/docs/guides/provider_reference.html.markdown @@ -78,6 +78,10 @@ credential/authentication file. Ensure that the scope of the VM/Cluster is set t If you are running terraform outside of Google Cloud, generate a service account key and set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable to the path of the service account key. Terraform will use that key for authentication. +### Disabling mtls authentication + +[mtls authentication](https://google.aip.dev/auth/4114) will soon become enabled by default if your system supports it. To disable mtls authentication at any point set `GOOGLE_API_USE_CLIENT_CERTIFICATE` to `false`. + ### Impersonating Service Accounts Terraform can impersonate a Google Service Account as described [here](https://cloud.google.com/iam/docs/creating-short-lived-service-account-credentials). A valid credential must be provided as mentioned in the earlier section and that identity must have the `roles/iam.serviceAccountTokenCreator` role on the service account you are impersonating.