Skip to content

Commit

Permalink
google_os_config_os_policy_assignment (#5481) (#3892)
Browse files Browse the repository at this point in the history
* Upgraded DCL and added overrides for osconfig os policy assignment.

Reworked AppendToBasePath override into BasePathReplacement.
Implemented serialization for map[string]string types.

* Split ReplaceInBasePath and AppendToBasePath into two overrides.

* Re-added missing quotation marks.

* Fixed handling of append to base path override.

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Dec 3, 2021
1 parent f2bc73e commit 4ce2c9d
Show file tree
Hide file tree
Showing 11 changed files with 4,910 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/5481.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
`google_os_config_os_policy_assignment`
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/hashicorp/terraform-provider-google-beta
require (
cloud.google.com/go/bigtable v1.10.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1440,7 +1440,5 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-202110
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211026195335-4a6ae4ac04de/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211027225138-ef28ca390518 h1:tFdFasG+VDpnn+BfVbZrfGcoH6pw6s7ODYlZlhTO3UM=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211027225138-ef28ca390518/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211129235756-547215b5e6ef h1:f+09BJVg+I/SObjSguOGGoSQHlT/Y1c8ah+nz1bkppI=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211129235756-547215b5e6ef/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811 h1:j1JJXw1MuANOPXJcruRaKIYIfPMNUwksphKSQruFF6w=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b h1:tXwnAInHrxG7UA0ZqJqA6Wh8IFamRpSXZXt/DTZFOyU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
1 change: 1 addition & 0 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1362,6 +1362,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_gke_hub_feature_membership": resourceGkeHubFeatureMembership(),
"google_monitoring_monitored_project": resourceMonitoringMonitoredProject(),
"google_org_policy_policy": resourceOrgPolicyPolicy(),
"google_os_config_os_policy_assignment": resourceOSConfigOSPolicyAssignment(),
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
},
Expand Down
24 changes: 24 additions & 0 deletions google-beta/provider_dcl_client_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
gkehub "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/gkehub/beta"
monitoring "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/monitoring/beta"
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy/beta"
osconfig "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/osconfig/beta"
privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca/beta"
recaptchaenterprise "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/recaptchaenterprise/beta"
)
Expand Down Expand Up @@ -239,6 +240,29 @@ func NewDCLOrgPolicyClient(config *Config, userAgent, billingProject string, tim
return orgpolicy.NewClient(dclConfig)
}

func NewDCLOSConfigClient(config *Config, userAgent, billingProject string, timeout time.Duration) *osconfig.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
dcl.WithUserAgent(userAgent),
dcl.WithLogger(dclLogger{}),
dcl.WithBasePath(config.OSConfigBasePath),
}

if timeout != 0 {
configOptions = append(configOptions, dcl.WithTimeout(timeout))
}

if config.UserProjectOverride {
configOptions = append(configOptions, dcl.WithUserProjectOverride())
if billingProject != "" {
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
}
}

dclConfig := dcl.NewConfig(configOptions...)
return osconfig.NewClient(dclConfig)
}

func NewDCLPrivatecaClient(config *Config, userAgent, billingProject string, timeout time.Duration) *privateca.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
Expand Down
12 changes: 12 additions & 0 deletions google-beta/provider_dcl_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ var OrgPolicyEndpointEntry = &schema.Schema{
}, ""),
}

var OSConfigEndpointEntryKey = "os_config_custom_endpoint"
var OSConfigEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_OS_CONFIG_CUSTOM_ENDPOINT",
}, ""),
}

var PrivatecaEndpointEntryKey = "privateca_custom_endpoint"
var PrivatecaEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand All @@ -111,6 +120,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
//EventarcBasePath string
//MonitoringBasePath string
//OrgPolicyBasePath string
//OSConfigBasePath string
//PrivatecaBasePath string
//RecaptchaEnterpriseBasePath string

Expand All @@ -122,6 +132,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
// EventarcEndpointEntryKey: EventarcEndpointEntry,
// MonitoringEndpointEntryKey: MonitoringEndpointEntry,
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
// OSConfigEndpointEntryKey: OSConfigEndpointEntry,
// PrivatecaEndpointEntryKey: PrivatecaEndpointEntry,
// RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry,

Expand All @@ -133,5 +144,6 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
// config.MonitoringBasePath = d.Get(MonitoringEndpointEntryKey).(string)
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
// config.OSConfigBasePath = d.Get(OSConfigEndpointEntryKey).(string)
// config.PrivatecaBasePath = d.Get(PrivatecaEndpointEntryKey).(string)
// config.RecaptchaEnterpriseBasePath = d.Get(RecaptchaEnterpriseEndpointEntryKey).(string)
Loading

0 comments on commit 4ce2c9d

Please sign in to comment.