Skip to content

Commit d383aa0

Browse files
google_os_config_os_policy_assignment (#5481) (#10676)
* 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]>
1 parent 7434d9f commit d383aa0

11 files changed

+4905
-5
lines changed

.changelog/5481.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_os_config_os_policy_assignment`
3+
```

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module github.com/hashicorp/terraform-provider-google
22
require (
33
cloud.google.com/go/bigtable v1.10.1
4-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811
4+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b
55
github.com/apparentlymart/go-cidr v1.1.0
66
github.com/client9/misspell v0.3.4
77
github.com/davecgh/go-spew v1.1.1

go.sum

+2-4
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,5 @@ github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-202110
14401440
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211026195335-4a6ae4ac04de/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
14411441
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211027225138-ef28ca390518 h1:tFdFasG+VDpnn+BfVbZrfGcoH6pw6s7ODYlZlhTO3UM=
14421442
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211027225138-ef28ca390518/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
1443-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211129235756-547215b5e6ef h1:f+09BJVg+I/SObjSguOGGoSQHlT/Y1c8ah+nz1bkppI=
1444-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211129235756-547215b5e6ef/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
1445-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811 h1:j1JJXw1MuANOPXJcruRaKIYIfPMNUwksphKSQruFF6w=
1446-
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211201210024-59e87ee7d811/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
1443+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b h1:tXwnAInHrxG7UA0ZqJqA6Wh8IFamRpSXZXt/DTZFOyU=
1444+
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211202000727-18e4bafd7e9b/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=

google/provider.go

+1
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
12091209
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
12101210
"google_eventarc_trigger": resourceEventarcTrigger(),
12111211
"google_org_policy_policy": resourceOrgPolicyPolicy(),
1212+
"google_os_config_os_policy_assignment": resourceOSConfigOSPolicyAssignment(),
12121213
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
12131214
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
12141215
},

google/provider_dcl_client_creation.go

+24
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc"
2727
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc"
2828
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy"
29+
osconfig "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/osconfig"
2930
privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca"
3031
recaptchaenterprise "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/recaptchaenterprise"
3132
)
@@ -191,6 +192,29 @@ func NewDCLOrgPolicyClient(config *Config, userAgent, billingProject string, tim
191192
return orgpolicy.NewClient(dclConfig)
192193
}
193194

195+
func NewDCLOSConfigClient(config *Config, userAgent, billingProject string, timeout time.Duration) *osconfig.Client {
196+
configOptions := []dcl.ConfigOption{
197+
dcl.WithHTTPClient(config.client),
198+
dcl.WithUserAgent(userAgent),
199+
dcl.WithLogger(dclLogger{}),
200+
dcl.WithBasePath(config.OSConfigBasePath),
201+
}
202+
203+
if timeout != 0 {
204+
configOptions = append(configOptions, dcl.WithTimeout(timeout))
205+
}
206+
207+
if config.UserProjectOverride {
208+
configOptions = append(configOptions, dcl.WithUserProjectOverride())
209+
if billingProject != "" {
210+
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
211+
}
212+
}
213+
214+
dclConfig := dcl.NewConfig(configOptions...)
215+
return osconfig.NewClient(dclConfig)
216+
}
217+
194218
func NewDCLPrivatecaClient(config *Config, userAgent, billingProject string, timeout time.Duration) *privateca.Client {
195219
configOptions := []dcl.ConfigOption{
196220
dcl.WithHTTPClient(config.client),

google/provider_dcl_endpoints.go

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ var OrgPolicyEndpointEntry = &schema.Schema{
7676
}, ""),
7777
}
7878

79+
var OSConfigEndpointEntryKey = "os_config_custom_endpoint"
80+
var OSConfigEndpointEntry = &schema.Schema{
81+
Type: schema.TypeString,
82+
Optional: true,
83+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
84+
"GOOGLE_OS_CONFIG_CUSTOM_ENDPOINT",
85+
}, ""),
86+
}
87+
7988
var PrivatecaEndpointEntryKey = "privateca_custom_endpoint"
8089
var PrivatecaEndpointEntry = &schema.Schema{
8190
Type: schema.TypeString,
@@ -101,6 +110,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
101110
//ComputeBasePath string
102111
//EventarcBasePath string
103112
//OrgPolicyBasePath string
113+
//OSConfigBasePath string
104114
//PrivatecaBasePath string
105115
//RecaptchaEnterpriseBasePath string
106116

@@ -111,6 +121,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
111121
// ComputeEndpointEntryKey: ComputeEndpointEntry,
112122
// EventarcEndpointEntryKey: EventarcEndpointEntry,
113123
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
124+
// OSConfigEndpointEntryKey: OSConfigEndpointEntry,
114125
// PrivatecaEndpointEntryKey: PrivatecaEndpointEntry,
115126
// RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry,
116127

@@ -121,5 +132,6 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
121132
// config.ComputeBasePath = d.Get(ComputeEndpointEntryKey).(string)
122133
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
123134
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
135+
// config.OSConfigBasePath = d.Get(OSConfigEndpointEntryKey).(string)
124136
// config.PrivatecaBasePath = d.Get(PrivatecaEndpointEntryKey).(string)
125137
// config.RecaptchaEnterpriseBasePath = d.Get(RecaptchaEnterpriseEndpointEntryKey).(string)

0 commit comments

Comments
 (0)