From 4ee0602ed9e20fa89cab3213c3e659b9bd7a4a2a Mon Sep 17 00:00:00 2001 From: Riley Karson Date: Tue, 11 Jun 2019 10:33:50 -0700 Subject: [PATCH] Move default base paths because conversion repo is missing most products --- third_party/terraform/utils/config.go.erb | 57 ------------------- .../terraform/utils/gcp_sweeper_test.go | 2 +- third_party/terraform/utils/provider.go.erb | 56 ++++++++++++++++++ 3 files changed, 57 insertions(+), 58 deletions(-) diff --git a/third_party/terraform/utils/config.go.erb b/third_party/terraform/utils/config.go.erb index d94f2d3acb57..c79287c01cb8 100644 --- a/third_party/terraform/utils/config.go.erb +++ b/third_party/terraform/utils/config.go.erb @@ -535,63 +535,6 @@ func (c *Config) LoadAndValidate() error { return nil } - -// For a consumer of config.go that isn't a full fledged provider and doesn't -// have its own endpoint mechanism such as sweepers, init {{service}}BasePath -// values to a default. After using this, you should call LoadAndValidate. -func (c *Config) SetDefaultBasePaths() { - // Generated Products - <% unless version == 'ga' -%> - // start beta-only products - c.BinaryAuthorizationBasePath = BinaryAuthorizationDefaultBasePath - c.ContainerAnalysisBasePath = ContainerAnalysisDefaultBasePath - c.SecurityScannerBasePath = SecurityScannerDefaultBasePath - // end beta-only products - <% end -%> - c.AccessContextManagerBasePath = AccessContextManagerDefaultBasePath - c.AppEngineBasePath = AppEngineDefaultBasePath - c.ComputeBasePath = ComputeDefaultBasePath - c.CloudBuildBasePath = CloudBuildDefaultBasePath - c.CloudSchedulerBasePath = CloudSchedulerDefaultBasePath - c.DnsBasePath = DnsDefaultBasePath - c.FilestoreBasePath = FilestoreDefaultBasePath - c.FirestoreBasePath = FirestoreDefaultBasePath - c.KmsBasePath = KmsDefaultBasePath - c.PubsubBasePath = PubsubDefaultBasePath - c.ResourceManagerBasePath = ResourceManagerDefaultBasePath - c.SourceRepoBasePath = SourceRepoDefaultBasePath - c.SpannerBasePath = SpannerDefaultBasePath - c.SqlBasePath = SqlDefaultBasePath - c.StorageBasePath = StorageDefaultBasePath - - // Handwritten Products / Versioned / Atypical Entries - <% unless version == 'ga' -%> - // start beta-only products - c.IAPBasePath = IAPDefaultBasePath - c.ServiceNetworkingBasePath = ServiceNetworkingDefaultBasePath - // end beta-only products - <% end -%> - c.CloudBillingBasePath = CloudBillingDefaultBasePath - c.ComposerBasePath = ComposerDefaultBasePath - c.ComputeBetaBasePath = ComputeBetaDefaultBasePath - c.ContainerBasePath = ContainerDefaultBasePath - c.ContainerBetaBasePath = ContainerBetaDefaultBasePath - c.DataprocBasePath = DataprocDefaultBasePath - c.DataflowBasePath = DataflowDefaultBasePath - c.DnsBetaBasePath = DnsBetaDefaultBasePath - c.IamCredentialsBasePath = IamCredentialsDefaultBasePath - c.LoggingBasePath = LoggingDefaultBasePath - c.ResourceManagerV2Beta1BasePath = ResourceManagerV2Beta1DefaultBasePath - c.RuntimeconfigBasePath = RuntimeconfigDefaultBasePath - c.IAMBasePath = IAMDefaultBasePath - c.ServiceManagementBasePath = ServiceManagementDefaultBasePath - c.ServiceUsageBasePath = ServiceUsageDefaultBasePath - c.BigQueryBasePath = BigQueryDefaultBasePath - c.CloudFunctionsBasePath = CloudFunctionsDefaultBasePath - c.CloudIoTBasePath = CloudIoTDefaultBasePath - c.StorageTransferBasePath = StorageTransferDefaultBasePath -} - func (c *Config) getTokenSource(clientScopes []string) (oauth2.TokenSource, error) { if c.AccessToken != "" { contents, _, err := pathorcontents.Read(c.AccessToken) diff --git a/third_party/terraform/utils/gcp_sweeper_test.go b/third_party/terraform/utils/gcp_sweeper_test.go index c9c56f341f28..3f1411997d99 100644 --- a/third_party/terraform/utils/gcp_sweeper_test.go +++ b/third_party/terraform/utils/gcp_sweeper_test.go @@ -30,7 +30,7 @@ func sharedConfigForRegion(region string) (*Config, error) { Project: project, } - conf.SetDefaultBasePaths() + BasePathsConfigure(conf) return conf, nil } diff --git a/third_party/terraform/utils/provider.go.erb b/third_party/terraform/utils/provider.go.erb index 8198f2f2f2f4..4bbaa2167835 100644 --- a/third_party/terraform/utils/provider.go.erb +++ b/third_party/terraform/utils/provider.go.erb @@ -426,6 +426,62 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) { return &config, nil } +// For a consumer of config.go that isn't a full fledged provider and doesn't +// have its own endpoint mechanism such as sweepers, init {{service}}BasePath +// values to a default. After using this, you should call config.LoadAndValidate. +func BasePathsConfigure(c *Config) { + // Generated Products + <% unless version == 'ga' -%> + // start beta-only products + c.BinaryAuthorizationBasePath = BinaryAuthorizationDefaultBasePath + c.ContainerAnalysisBasePath = ContainerAnalysisDefaultBasePath + c.SecurityScannerBasePath = SecurityScannerDefaultBasePath + // end beta-only products + <% end -%> + c.AccessContextManagerBasePath = AccessContextManagerDefaultBasePath + c.AppEngineBasePath = AppEngineDefaultBasePath + c.ComputeBasePath = ComputeDefaultBasePath + c.CloudBuildBasePath = CloudBuildDefaultBasePath + c.CloudSchedulerBasePath = CloudSchedulerDefaultBasePath + c.DnsBasePath = DnsDefaultBasePath + c.FilestoreBasePath = FilestoreDefaultBasePath + c.FirestoreBasePath = FirestoreDefaultBasePath + c.KmsBasePath = KmsDefaultBasePath + c.PubsubBasePath = PubsubDefaultBasePath + c.ResourceManagerBasePath = ResourceManagerDefaultBasePath + c.SourceRepoBasePath = SourceRepoDefaultBasePath + c.SpannerBasePath = SpannerDefaultBasePath + c.SqlBasePath = SqlDefaultBasePath + c.StorageBasePath = StorageDefaultBasePath + + // Handwritten Products / Versioned / Atypical Entries + <% unless version == 'ga' -%> + // start beta-only products + c.IAPBasePath = IAPDefaultBasePath + c.ServiceNetworkingBasePath = ServiceNetworkingDefaultBasePath + // end beta-only products + <% end -%> + c.CloudBillingBasePath = CloudBillingDefaultBasePath + c.ComposerBasePath = ComposerDefaultBasePath + c.ComputeBetaBasePath = ComputeBetaDefaultBasePath + c.ContainerBasePath = ContainerDefaultBasePath + c.ContainerBetaBasePath = ContainerBetaDefaultBasePath + c.DataprocBasePath = DataprocDefaultBasePath + c.DataflowBasePath = DataflowDefaultBasePath + c.DnsBetaBasePath = DnsBetaDefaultBasePath + c.IamCredentialsBasePath = IamCredentialsDefaultBasePath + c.LoggingBasePath = LoggingDefaultBasePath + c.ResourceManagerV2Beta1BasePath = ResourceManagerV2Beta1DefaultBasePath + c.RuntimeconfigBasePath = RuntimeconfigDefaultBasePath + c.IAMBasePath = IAMDefaultBasePath + c.ServiceManagementBasePath = ServiceManagementDefaultBasePath + c.ServiceUsageBasePath = ServiceUsageDefaultBasePath + c.BigQueryBasePath = BigQueryDefaultBasePath + c.CloudFunctionsBasePath = CloudFunctionsDefaultBasePath + c.CloudIoTBasePath = CloudIoTDefaultBasePath + c.StorageTransferBasePath = StorageTransferDefaultBasePath +} + func validateCredentials(v interface{}, k string) (warnings []string, errors []error) { if v == nil || v.(string) == "" { return