-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* AD Domain resource added * fmt issue fixed * validation regex and input flag added * Trust resouce attributes added to api.yaml * ad domain trust resource added * ad domain trust resource added * post_create attribute added * nested_query attribute added - work in progress * work in progress - peer review * encoder and decoder added - wip * custom encoders and decoders added for update and delete resource * comment removed * comment added * comment syntax corrected * comments added as PR review comments
- Loading branch information
1 parent
58d5a99
commit b7acb81
Showing
7 changed files
with
359 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
templates/terraform/custom_delete/active_directory_domain_trust.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
config := meta.(*Config) | ||
|
||
project, err := getProject(d, config) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
url, err := replaceVars(d, config, "{{ActiveDirectoryBasePath}}projects/{{project}}/locations/global/domains/{{domain}}:detachTrust") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
<%# The generate DELETE method isn't including the {trust: } object in the response body thus custom_delete is needed -%> | ||
|
||
obj := make(map[string]interface{}) | ||
targetDomainNameProp, err := expandNestedActiveDirectoryDomainTrustTargetDomainName(d.Get("target_domain_name"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("target_domain_name"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetDomainNameProp)) { | ||
obj["targetDomainName"] = targetDomainNameProp | ||
} | ||
trustTypeProp, err := expandNestedActiveDirectoryDomainTrustTrustType(d.Get("trust_type"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("trust_type"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, trustTypeProp)) { | ||
obj["trustType"] = trustTypeProp | ||
} | ||
trustDirectionProp, err := expandNestedActiveDirectoryDomainTrustTrustDirection(d.Get("trust_direction"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("trust_direction"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, trustDirectionProp)) { | ||
obj["trustDirection"] = trustDirectionProp | ||
} | ||
selectiveAuthenticationProp, err := expandNestedActiveDirectoryDomainTrustSelectiveAuthentication(d.Get("selective_authentication"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("selective_authentication"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, selectiveAuthenticationProp)) { | ||
obj["selectiveAuthentication"] = selectiveAuthenticationProp | ||
} | ||
targetDnsIpAddressesProp, err := expandNestedActiveDirectoryDomainTrustTargetDnsIpAddresses(d.Get("target_dns_ip_addresses"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("target_dns_ip_addresses"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, targetDnsIpAddressesProp)) { | ||
obj["targetDnsIpAddresses"] = targetDnsIpAddressesProp | ||
} | ||
trustHandshakeSecretProp, err := expandNestedActiveDirectoryDomainTrustTrustHandshakeSecret(d.Get("trust_handshake_secret"), d, config) | ||
if err != nil { | ||
return err | ||
} else if v, ok := d.GetOkExists("trust_handshake_secret"); !isEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, trustHandshakeSecretProp)) { | ||
obj["trustHandshakeSecret"] = trustHandshakeSecretProp | ||
} | ||
|
||
obj, err = resourceActiveDirectoryDomainTrustEncoder(d, meta, obj) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("[DEBUG] Deleting DomainTrust %q", d.Id()) | ||
|
||
res, err := sendRequestWithTimeout(config, "POST", project, url, obj, d.Timeout(schema.TimeoutDelete)) | ||
if err != nil { | ||
return handleNotFoundError(err, d, "DomainTrust") | ||
} | ||
|
||
err = activeDirectoryOperationWaitTime( | ||
config, res, project, "Deleting DomainTrust", | ||
d.Timeout(schema.TimeoutDelete)) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
log.Printf("[DEBUG] Finished deleting DomainTrust %q: %#v", d.Id(), res) | ||
return nil |
19 changes: 19 additions & 0 deletions
19
templates/terraform/encoders/active_directory_domain_trust.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2020 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
|
||
wrappedReq := map[string]interface{}{ | ||
"trust": obj, | ||
} | ||
return wrappedReq, nil |
8 changes: 8 additions & 0 deletions
8
templates/terraform/examples/active_directory_domain_trust_basic.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
resource "google_active_directory_domain_trust" "ad-domain-trust" { | ||
domain = "test-managed-ad.com" | ||
target_domain_name = "example-gcp.com" | ||
target_dns_ip_addresses = ["10.1.0.100"] | ||
trust_direction = "OUTBOUND" | ||
trust_type = "FOREST" | ||
trust_handshake_secret = "Testing1!" | ||
} |
19 changes: 19 additions & 0 deletions
19
templates/terraform/update_encoder/active_directory_domain_trust.go.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<%# The license inside this block applies to this file. | ||
# Copyright 2020 Google Inc. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
-%> | ||
wrappedReq := map[string]interface{}{ | ||
"targetDomainName": obj["targetDomainName"], | ||
"targetDnsIpAddresses": obj["targetDnsIpAddresses"], | ||
} | ||
return wrappedReq, nil |
Oops, something went wrong.