Skip to content

Commit

Permalink
Add org_policy_custom_constraint resource (#6608) (#4741)
Browse files Browse the repository at this point in the history
* Add org_policy_custom_constraint resource

* Update resource config to reflect beta version

* Update handwritten test to reflect beta version

* Update example to use beta version of the provider

* Remove unnecessary TestCheckResourceAttr calls

* Update name attribute to be specified as a shortname

* Add full example

* Tweak config and documentation per final PR comments

Signed-off-by: Modular Magician <magic-modules@google.com>

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician authored Sep 30, 2022
1 parent 3bfa0b7 commit 7566781
Show file tree
Hide file tree
Showing 9 changed files with 953 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .changelog/6608.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:new-resource
google_org_policy_custom_constraint
```
4 changes: 4 additions & 0 deletions google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ type Config struct {
NetworkManagementBasePath string
NetworkServicesBasePath string
NotebooksBasePath string
OrgPolicyBasePath string
OSConfigBasePath string
OSLoginBasePath string
PrivatecaBasePath string
Expand Down Expand Up @@ -332,6 +333,7 @@ const MonitoringBasePathKey = "Monitoring"
const NetworkManagementBasePathKey = "NetworkManagement"
const NetworkServicesBasePathKey = "NetworkServices"
const NotebooksBasePathKey = "Notebooks"
const OrgPolicyBasePathKey = "OrgPolicy"
const OSConfigBasePathKey = "OSConfig"
const OSLoginBasePathKey = "OSLogin"
const PrivatecaBasePathKey = "Privateca"
Expand Down Expand Up @@ -428,6 +430,7 @@ var DefaultBasePaths = map[string]string{
NetworkManagementBasePathKey: "https://networkmanagement.googleapis.com/v1/",
NetworkServicesBasePathKey: "https://networkservices.googleapis.com/v1/",
NotebooksBasePathKey: "https://notebooks.googleapis.com/v1/",
OrgPolicyBasePathKey: "https://orgpolicy.googleapis.com/v2/",
OSConfigBasePathKey: "https://osconfig.googleapis.com/v1beta/",
OSLoginBasePathKey: "https://oslogin.googleapis.com/v1/",
PrivatecaBasePathKey: "https://privateca.googleapis.com/v1/",
Expand Down Expand Up @@ -1300,6 +1303,7 @@ func ConfigureBasePaths(c *Config) {
c.NetworkManagementBasePath = DefaultBasePaths[NetworkManagementBasePathKey]
c.NetworkServicesBasePath = DefaultBasePaths[NetworkServicesBasePathKey]
c.NotebooksBasePath = DefaultBasePaths[NotebooksBasePathKey]
c.OrgPolicyBasePath = DefaultBasePaths[OrgPolicyBasePathKey]
c.OSConfigBasePath = DefaultBasePaths[OSConfigBasePathKey]
c.OSLoginBasePath = DefaultBasePaths[OSLoginBasePathKey]
c.PrivatecaBasePath = DefaultBasePaths[PrivatecaBasePathKey]
Expand Down
14 changes: 12 additions & 2 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,14 @@ func Provider() *schema.Provider {
"GOOGLE_NOTEBOOKS_CUSTOM_ENDPOINT",
}, DefaultBasePaths[NotebooksBasePathKey]),
},
"org_policy_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_ORG_POLICY_CUSTOM_ENDPOINT",
}, DefaultBasePaths[OrgPolicyBasePathKey]),
},
"os_config_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -956,9 +964,9 @@ func Provider() *schema.Provider {
return provider
}

// Generated resources: 264
// Generated resources: 265
// Generated IAM resources: 171
// Total generated resources: 435
// Total generated resources: 436
func ResourceMap() map[string]*schema.Resource {
resourceMap, _ := ResourceMapWithErrors()
return resourceMap
Expand Down Expand Up @@ -1320,6 +1328,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_notebooks_runtime_iam_member": ResourceIamMember(NotebooksRuntimeIamSchema, NotebooksRuntimeIamUpdaterProducer, NotebooksRuntimeIdParseFunc),
"google_notebooks_runtime_iam_policy": ResourceIamPolicy(NotebooksRuntimeIamSchema, NotebooksRuntimeIamUpdaterProducer, NotebooksRuntimeIdParseFunc),
"google_notebooks_location": resourceNotebooksLocation(),
"google_org_policy_custom_constraint": resourceOrgPolicyCustomConstraint(),
"google_os_config_patch_deployment": resourceOSConfigPatchDeployment(),
"google_os_config_guest_policies": resourceOSConfigGuestPolicies(),
"google_os_login_ssh_public_key": resourceOSLoginSSHPublicKey(),
Expand Down Expand Up @@ -1688,6 +1697,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.NetworkManagementBasePath = d.Get("network_management_custom_endpoint").(string)
config.NetworkServicesBasePath = d.Get("network_services_custom_endpoint").(string)
config.NotebooksBasePath = d.Get("notebooks_custom_endpoint").(string)
config.OrgPolicyBasePath = d.Get("org_policy_custom_endpoint").(string)
config.OSConfigBasePath = d.Get("os_config_custom_endpoint").(string)
config.OSLoginBasePath = d.Get("os_login_custom_endpoint").(string)
config.PrivatecaBasePath = d.Get("privateca_custom_endpoint").(string)
Expand Down
12 changes: 0 additions & 12 deletions google-beta/provider_dcl_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,6 @@ var NetworkConnectivityEndpointEntry = &schema.Schema{
}, ""),
}

var OrgPolicyEndpointEntryKey = "org_policy_custom_endpoint"
var OrgPolicyEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_ORG_POLICY_CUSTOM_ENDPOINT",
}, ""),
}

var RecaptchaEnterpriseEndpointEntryKey = "recaptcha_enterprise_custom_endpoint"
var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand All @@ -141,7 +132,6 @@ type DCLConfig struct {
FirebaserulesBasePath string
GKEHubFeatureBasePath string
NetworkConnectivityBasePath string
OrgPolicyBasePath string
RecaptchaEnterpriseBasePath string
}

Expand All @@ -156,7 +146,6 @@ func configureDCLProvider(provider *schema.Provider) {
provider.Schema[FirebaserulesEndpointEntryKey] = FirebaserulesEndpointEntry
provider.Schema[GKEHubFeatureEndpointEntryKey] = GKEHubFeatureEndpointEntry
provider.Schema[NetworkConnectivityEndpointEntryKey] = NetworkConnectivityEndpointEntry
provider.Schema[OrgPolicyEndpointEntryKey] = OrgPolicyEndpointEntry
provider.Schema[RecaptchaEnterpriseEndpointEntryKey] = RecaptchaEnterpriseEndpointEntry
}

Expand All @@ -171,7 +160,6 @@ func providerDCLConfigure(d *schema.ResourceData, config *Config) interface{} {
config.FirebaserulesBasePath = d.Get(FirebaserulesEndpointEntryKey).(string)
config.GKEHubFeatureBasePath = d.Get(GKEHubFeatureEndpointEntryKey).(string)
config.NetworkConnectivityBasePath = d.Get(NetworkConnectivityEndpointEntryKey).(string)
config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
config.RecaptchaEnterpriseBasePath = d.Get(RecaptchaEnterpriseEndpointEntryKey).(string)
config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
return config
Expand Down
Loading

0 comments on commit 7566781

Please sign in to comment.