Skip to content

Commit

Permalink
Add basepath generation (#4745) (#9098)
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored May 6, 2021
1 parent 983befb commit ab1a16c
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 19 deletions.
2 changes: 2 additions & 0 deletions .changelog/4745.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```release-note:none
```
6 changes: 4 additions & 2 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,9 @@ type Config struct {
requestBatcherIam *RequestBatcher

// start DCL clients
// dataprocBasePath is implemented in mm
clientDataprocDCL *dataprocDcl.Client
EventarcBasePath string
clientEventarcDCL *eventarcDcl.Client
}

Expand Down Expand Up @@ -290,8 +292,8 @@ func (c *Config) LoadAndValidate(ctx context.Context) error {
dclLoggerOptions := dcl.WithLogger(dclLogger{})
// each product needs it own client currently since basepath can only be specified at
// the config level.
c.clientDataprocDCL = dataprocDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions, dclLoggerOptions))
c.clientEventarcDCL = eventarcDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions, dclLoggerOptions))
c.clientDataprocDCL = dataprocDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions, dclLoggerOptions, dcl.WithBasePath(c.DataprocBasePath)))
c.clientEventarcDCL = eventarcDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions, dclLoggerOptions, dcl.WithBasePath(c.EventarcBasePath)))

return nil
}
Expand Down
4 changes: 1 addition & 3 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -626,7 +626,6 @@ func Provider() *schema.Provider {
BigtableAdminCustomEndpointEntryKey: BigtableAdminCustomEndpointEntry,

// dcl
DataprocEndpointEntryKey: DataprocEndpointEntry,
EventarcEndpointEntryKey: EventarcEndpointEntry,
},

Expand Down Expand Up @@ -1316,8 +1315,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.BigtableAdminBasePath = d.Get(BigtableAdminCustomEndpointEntryKey).(string)

// dcl
// config.clientDataprocDCL.Config.BasePath = d.Get(DataprocEndpointEntryKey).(string)
// config.clientEventarcDCL.Config.BasePath = d.Get(EventarcEndpointEntryKey).(string)
config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)

stopCtx, ok := schema.StopContext(ctx)
if !ok {
Expand Down
18 changes: 4 additions & 14 deletions google/provider_dcl_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

var DataprocEndpointEntryKey = "eventarc_custom_endpoint"
var DataprocEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_EVENTARC_CUSTOM_ENDPOINT",
}, ""),
}

var EventarcEndpointEntryKey = "eventarc_custom_endpoint"
var EventarcEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand All @@ -38,16 +29,15 @@ var EventarcEndpointEntry = &schema.Schema{

//Add new values to config.go.erb config object declaration
// clientDataprocDCL *dataprocDcl.Client
//EventarcBasePath string
// clientEventarcDCL *eventarcDcl.Client

//Add new values to config.go.erb object initialization
// c.clientDataprocDCL = dataprocDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions,dclLoggerOptions))
// c.clientEventarcDCL = eventarcDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions,dclLoggerOptions))
// c.clientDataprocDCL = dataprocDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions,dclLoggerOptions, dcl.WithBasePath(c.DataprocBasePath)))
// c.clientEventarcDCL = eventarcDcl.NewClient(dcl.NewConfig(dclClientOptions, dclUserAgentOptions,dclLoggerOptions, dcl.WithBasePath(c.EventarcBasePath)))

//Add new values to provider.go.erb schema initialization
// DataprocEndpointEntryKey: DataprocEndpointEntry,
// EventarcEndpointEntryKey: EventarcEndpointEntry,

//Add new values to provider.go.erb - provider block read
// config.clientDataprocDCL.Config.BasePath = d.Get(DataprocEndpointEntryKey).(string)
// config.clientEventarcDCL.Config.BasePath = d.Get(EventarcEndpointEntryKey).(string)
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)

0 comments on commit ab1a16c

Please sign in to comment.