Skip to content

Commit

Permalink
Move default base paths because conversion repo is missing most products
Browse files Browse the repository at this point in the history
  • Loading branch information
rileykarson committed Jun 11, 2019
1 parent b84046f commit 4ee0602
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 58 deletions.
57 changes: 0 additions & 57 deletions third_party/terraform/utils/config.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion third_party/terraform/utils/gcp_sweeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func sharedConfigForRegion(region string) (*Config, error) {
Project: project,
}

conf.SetDefaultBasePaths()
BasePathsConfigure(conf)

return conf, nil
}
56 changes: 56 additions & 0 deletions third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ee0602

Please sign in to comment.