Skip to content

Commit 84d078f

Browse files
authored
Merge pull request #54 from fortanix/backportDEVOPS-3815
Merge pull request #53 from protyushn/PROD-4928
2 parents cc20afb + f39988d commit 84d078f

File tree

1 file changed

+20
-15
lines changed

1 file changed

+20
-15
lines changed

dsm/resource_sobject.go

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,23 +262,30 @@ func createSO(ctx context.Context, d *schema.ResourceData, m interface{}) diag.D
262262
}
263263
security_object["rsa"] = rsa_obj
264264
}
265-
allowed_key_justifications_policy := d.Get("allowed_key_justifications_policy")
266-
allowed_missing_justifications := d.Get("allowed_missing_justifications")
267-
268-
if allowed_key_justifications_policy != nil && allowed_missing_justifications != nil {
269-
security_object["google_access_reason_policy"] = map[string]interface{}{
270-
"allow": allowed_key_justifications_policy,
271-
"allow_missing_reason": allowed_missing_justifications,
265+
allowed_key_justifications_policy, ok := d.GetOk("allowed_key_justifications_policy")
266+
allowed_missing_justifications, ok2 := d.GetOkExists("allowed_missing_justifications")
267+
268+
if ok && ok2 {
269+
if allowed_key_justifications_policy != nil && allowed_missing_justifications != nil {
270+
security_object["google_access_reason_policy"] = map[string]interface{}{
271+
"allow": allowed_key_justifications_policy,
272+
"allow_missing_reason": allowed_missing_justifications,
273+
}
272274
}
273-
} else if allowed_key_justifications_policy != nil {
274-
security_object["google_access_reason_policy"] = map[string]interface{}{
275-
"allow": allowed_key_justifications_policy,
275+
} else if ok {
276+
if allowed_key_justifications_policy != nil {
277+
security_object["google_access_reason_policy"] = map[string]interface{}{
278+
"allow": allowed_key_justifications_policy,
279+
}
276280
}
277-
} else if allowed_missing_justifications != nil {
278-
security_object["google_access_reason_policy"] = map[string]interface{}{
279-
"allow_missing_reason": allowed_missing_justifications,
281+
} else if ok2 {
282+
if allowed_missing_justifications != nil {
283+
security_object["google_access_reason_policy"] = map[string]interface{}{
284+
"allow_missing_reason": allowed_missing_justifications,
285+
}
280286
}
281287
}
288+
282289
if err := d.Get("fpe_radix"); err != 0 {
283290
security_object["fpe"] = map[string]interface{}{
284291
"radix": d.Get("fpe_radix").(int),
@@ -532,7 +539,6 @@ func resourceUpdateSobject(ctx context.Context, d *schema.ResourceData, m interf
532539
security_object["rsa"] = rsa_obj
533540
has_changed = true
534541
}
535-
536542
if d.HasChanges("allowed_key_justifications_policy", "allowed_missing_justifications") {
537543

538544
google_access_reason_policy := make(map[string]interface{})
@@ -544,7 +550,6 @@ func resourceUpdateSobject(ctx context.Context, d *schema.ResourceData, m interf
544550

545551
security_object["google_access_reason_policy"] = google_access_reason_policy
546552
}
547-
548553
if d.HasChange("key_ops") {
549554
security_object["key_ops"] = d.Get("key_ops")
550555
has_changed = true

0 commit comments

Comments
 (0)