Skip to content

Commit 14e5d8d

Browse files
Promote the call_log_level attribute to GA and update tests. Fixes #15575. (#9825) (#17051)
[upstream:38a04d347cc22c93abb177a60fc48f4fab3aa5fe] Signed-off-by: Modular Magician <[email protected]>
1 parent 4b97647 commit 14e5d8d

File tree

5 files changed

+58
-8
lines changed

5 files changed

+58
-8
lines changed

.changelog/9825.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
workflows: add support for `call_log_level` to resource `google_workflows_workflow`
3+
```

google/services/workflows/resource_workflows_workflow.go

+37-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
3333
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
34+
"github.com/hashicorp/terraform-provider-google/google/verify"
3435
)
3536

3637
func ResourceWorkflowsWorkflow() *schema.Resource {
@@ -61,6 +62,14 @@ func ResourceWorkflowsWorkflow() *schema.Resource {
6162
),
6263

6364
Schema: map[string]*schema.Schema{
65+
"call_log_level": {
66+
Type: schema.TypeString,
67+
Optional: true,
68+
ValidateFunc: verify.ValidateEnum([]string{"CALL_LOG_LEVEL_UNSPECIFIED", "LOG_ALL_CALLS", "LOG_ERRORS_ONLY", "LOG_NONE", ""}),
69+
Description: `Describes the level of platform logging to apply to calls and call responses during
70+
executions of this workflow. If both the workflow and the execution specify a logging level,
71+
the execution level takes precedence. Possible values: ["CALL_LOG_LEVEL_UNSPECIFIED", "LOG_ALL_CALLS", "LOG_ERRORS_ONLY", "LOG_NONE"]`,
72+
},
6473
"crypto_key_name": {
6574
Type: schema.TypeString,
6675
Optional: true,
@@ -113,7 +122,7 @@ Modifying this field for an existing workflow results in a new workflow revision
113122
"source_contents": {
114123
Type: schema.TypeString,
115124
Optional: true,
116-
Description: `Workflow code to be executed. The size limit is 32KB.`,
125+
Description: `Workflow code to be executed. The size limit is 128KB.`,
117126
},
118127
"user_env_vars": {
119128
Type: schema.TypeMap,
@@ -210,6 +219,12 @@ func resourceWorkflowsWorkflowCreate(d *schema.ResourceData, meta interface{}) e
210219
} else if v, ok := d.GetOkExists("crypto_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(cryptoKeyNameProp)) && (ok || !reflect.DeepEqual(v, cryptoKeyNameProp)) {
211220
obj["cryptoKeyName"] = cryptoKeyNameProp
212221
}
222+
callLogLevelProp, err := expandWorkflowsWorkflowCallLogLevel(d.Get("call_log_level"), d, config)
223+
if err != nil {
224+
return err
225+
} else if v, ok := d.GetOkExists("call_log_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(callLogLevelProp)) && (ok || !reflect.DeepEqual(v, callLogLevelProp)) {
226+
obj["callLogLevel"] = callLogLevelProp
227+
}
213228
userEnvVarsProp, err := expandWorkflowsWorkflowUserEnvVars(d.Get("user_env_vars"), d, config)
214229
if err != nil {
215230
return err
@@ -366,6 +381,9 @@ func resourceWorkflowsWorkflowRead(d *schema.ResourceData, meta interface{}) err
366381
if err := d.Set("crypto_key_name", flattenWorkflowsWorkflowCryptoKeyName(res["cryptoKeyName"], d, config)); err != nil {
367382
return fmt.Errorf("Error reading Workflow: %s", err)
368383
}
384+
if err := d.Set("call_log_level", flattenWorkflowsWorkflowCallLogLevel(res["callLogLevel"], d, config)); err != nil {
385+
return fmt.Errorf("Error reading Workflow: %s", err)
386+
}
369387
if err := d.Set("user_env_vars", flattenWorkflowsWorkflowUserEnvVars(res["userEnvVars"], d, config)); err != nil {
370388
return fmt.Errorf("Error reading Workflow: %s", err)
371389
}
@@ -419,6 +437,12 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e
419437
} else if v, ok := d.GetOkExists("crypto_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, cryptoKeyNameProp)) {
420438
obj["cryptoKeyName"] = cryptoKeyNameProp
421439
}
440+
callLogLevelProp, err := expandWorkflowsWorkflowCallLogLevel(d.Get("call_log_level"), d, config)
441+
if err != nil {
442+
return err
443+
} else if v, ok := d.GetOkExists("call_log_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, callLogLevelProp)) {
444+
obj["callLogLevel"] = callLogLevelProp
445+
}
422446
userEnvVarsProp, err := expandWorkflowsWorkflowUserEnvVars(d.Get("user_env_vars"), d, config)
423447
if err != nil {
424448
return err
@@ -461,6 +485,10 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e
461485
updateMask = append(updateMask, "cryptoKeyName")
462486
}
463487

488+
if d.HasChange("call_log_level") {
489+
updateMask = append(updateMask, "callLogLevel")
490+
}
491+
464492
if d.HasChange("user_env_vars") {
465493
updateMask = append(updateMask, "userEnvVars")
466494
}
@@ -617,6 +645,10 @@ func flattenWorkflowsWorkflowCryptoKeyName(v interface{}, d *schema.ResourceData
617645
return v
618646
}
619647

648+
func flattenWorkflowsWorkflowCallLogLevel(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
649+
return v
650+
}
651+
620652
func flattenWorkflowsWorkflowUserEnvVars(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
621653
return v
622654
}
@@ -660,6 +692,10 @@ func expandWorkflowsWorkflowCryptoKeyName(v interface{}, d tpgresource.Terraform
660692
return v, nil
661693
}
662694

695+
func expandWorkflowsWorkflowCallLogLevel(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
696+
return v, nil
697+
}
698+
663699
func expandWorkflowsWorkflowUserEnvVars(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
664700
if v == nil {
665701
return map[string]string{}, nil

google/services/workflows/resource_workflows_workflow_generated_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ resource "google_workflows_workflow" "example" {
6161
region = "us-central1"
6262
description = "Magic"
6363
service_account = google_service_account.test_account.id
64+
call_log_level = "LOG_ERRORS_ONLY"
6465
labels = {
6566
env = "test"
6667
}

google/services/workflows/resource_workflows_workflow_test.go

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ func TestAccWorkflowsWorkflow_Update(t *testing.T) {
3838
func testAccWorkflowsWorkflow_Update(name string) string {
3939
return fmt.Sprintf(`
4040
resource "google_workflows_workflow" "example" {
41-
name = "%s"
42-
region = "us-central1"
43-
description = "Magic"
41+
name = "%s"
42+
region = "us-central1"
43+
description = "Magic"
44+
call_log_level = "LOG_ERRORS_ONLY"
4445
user_env_vars = {
4546
url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"
4647
}
@@ -78,9 +79,10 @@ EOF
7879
func testAccWorkflowsWorkflow_Updated(name string) string {
7980
return fmt.Sprintf(`
8081
resource "google_workflows_workflow" "example" {
81-
name = "%s"
82-
region = "us-central1"
83-
description = "Magic"
82+
name = "%s"
83+
region = "us-central1"
84+
description = "Magic"
85+
call_log_level = "LOG_ERRORS_ONLY"
8486
user_env_vars = {
8587
url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"
8688
}

website/docs/r/workflows_workflow.html.markdown

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ resource "google_workflows_workflow" "example" {
4747
region = "us-central1"
4848
description = "Magic"
4949
service_account = google_service_account.test_account.id
50+
call_log_level = "LOG_ERRORS_ONLY"
5051
labels = {
5152
env = "test"
5253
}
@@ -120,13 +121,20 @@ The following arguments are supported:
120121

121122
* `source_contents` -
122123
(Optional)
123-
Workflow code to be executed. The size limit is 32KB.
124+
Workflow code to be executed. The size limit is 128KB.
124125

125126
* `crypto_key_name` -
126127
(Optional)
127128
The KMS key used to encrypt workflow and execution data.
128129
Format: projects/{project}/locations/{location}/keyRings/{keyRing}/cryptoKeys/{cryptoKey}
129130

131+
* `call_log_level` -
132+
(Optional)
133+
Describes the level of platform logging to apply to calls and call responses during
134+
executions of this workflow. If both the workflow and the execution specify a logging level,
135+
the execution level takes precedence.
136+
Possible values are: `CALL_LOG_LEVEL_UNSPECIFIED`, `LOG_ALL_CALLS`, `LOG_ERRORS_ONLY`, `LOG_NONE`.
137+
130138
* `user_env_vars` -
131139
(Optional)
132140
User-defined environment variables associated with this workflow revision. This map has a maximum length of 20. Each string can take up to 4KiB. Keys cannot be empty strings and cannot start with “GOOGLE” or “WORKFLOWS".

0 commit comments

Comments
 (0)