Skip to content

Commit

Permalink
Promote the call_log_level attribute to GA and update tests. Fixes #1…
Browse files Browse the repository at this point in the history
…5575. (#9825) (#17051)

[upstream:38a04d347cc22c93abb177a60fc48f4fab3aa5fe]

Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
modular-magician authored Jan 19, 2024
1 parent 4b97647 commit 14e5d8d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .changelog/9825.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
workflows: add support for `call_log_level` to resource `google_workflows_workflow`
```
38 changes: 37 additions & 1 deletion google/services/workflows/resource_workflows_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/hashicorp/terraform-provider-google/google/tpgresource"
transport_tpg "github.com/hashicorp/terraform-provider-google/google/transport"
"github.com/hashicorp/terraform-provider-google/google/verify"
)

func ResourceWorkflowsWorkflow() *schema.Resource {
Expand Down Expand Up @@ -61,6 +62,14 @@ func ResourceWorkflowsWorkflow() *schema.Resource {
),

Schema: map[string]*schema.Schema{
"call_log_level": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: verify.ValidateEnum([]string{"CALL_LOG_LEVEL_UNSPECIFIED", "LOG_ALL_CALLS", "LOG_ERRORS_ONLY", "LOG_NONE", ""}),
Description: `Describes the level of platform logging to apply to calls and call responses during
executions of this workflow. If both the workflow and the execution specify a logging level,
the execution level takes precedence. Possible values: ["CALL_LOG_LEVEL_UNSPECIFIED", "LOG_ALL_CALLS", "LOG_ERRORS_ONLY", "LOG_NONE"]`,
},
"crypto_key_name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -113,7 +122,7 @@ Modifying this field for an existing workflow results in a new workflow revision
"source_contents": {
Type: schema.TypeString,
Optional: true,
Description: `Workflow code to be executed. The size limit is 32KB.`,
Description: `Workflow code to be executed. The size limit is 128KB.`,
},
"user_env_vars": {
Type: schema.TypeMap,
Expand Down Expand Up @@ -210,6 +219,12 @@ func resourceWorkflowsWorkflowCreate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("crypto_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(cryptoKeyNameProp)) && (ok || !reflect.DeepEqual(v, cryptoKeyNameProp)) {
obj["cryptoKeyName"] = cryptoKeyNameProp
}
callLogLevelProp, err := expandWorkflowsWorkflowCallLogLevel(d.Get("call_log_level"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("call_log_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(callLogLevelProp)) && (ok || !reflect.DeepEqual(v, callLogLevelProp)) {
obj["callLogLevel"] = callLogLevelProp
}
userEnvVarsProp, err := expandWorkflowsWorkflowUserEnvVars(d.Get("user_env_vars"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -366,6 +381,9 @@ func resourceWorkflowsWorkflowRead(d *schema.ResourceData, meta interface{}) err
if err := d.Set("crypto_key_name", flattenWorkflowsWorkflowCryptoKeyName(res["cryptoKeyName"], d, config)); err != nil {
return fmt.Errorf("Error reading Workflow: %s", err)
}
if err := d.Set("call_log_level", flattenWorkflowsWorkflowCallLogLevel(res["callLogLevel"], d, config)); err != nil {
return fmt.Errorf("Error reading Workflow: %s", err)
}
if err := d.Set("user_env_vars", flattenWorkflowsWorkflowUserEnvVars(res["userEnvVars"], d, config)); err != nil {
return fmt.Errorf("Error reading Workflow: %s", err)
}
Expand Down Expand Up @@ -419,6 +437,12 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e
} else if v, ok := d.GetOkExists("crypto_key_name"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, cryptoKeyNameProp)) {
obj["cryptoKeyName"] = cryptoKeyNameProp
}
callLogLevelProp, err := expandWorkflowsWorkflowCallLogLevel(d.Get("call_log_level"), d, config)
if err != nil {
return err
} else if v, ok := d.GetOkExists("call_log_level"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, callLogLevelProp)) {
obj["callLogLevel"] = callLogLevelProp
}
userEnvVarsProp, err := expandWorkflowsWorkflowUserEnvVars(d.Get("user_env_vars"), d, config)
if err != nil {
return err
Expand Down Expand Up @@ -461,6 +485,10 @@ func resourceWorkflowsWorkflowUpdate(d *schema.ResourceData, meta interface{}) e
updateMask = append(updateMask, "cryptoKeyName")
}

if d.HasChange("call_log_level") {
updateMask = append(updateMask, "callLogLevel")
}

if d.HasChange("user_env_vars") {
updateMask = append(updateMask, "userEnvVars")
}
Expand Down Expand Up @@ -617,6 +645,10 @@ func flattenWorkflowsWorkflowCryptoKeyName(v interface{}, d *schema.ResourceData
return v
}

func flattenWorkflowsWorkflowCallLogLevel(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}

func flattenWorkflowsWorkflowUserEnvVars(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} {
return v
}
Expand Down Expand Up @@ -660,6 +692,10 @@ func expandWorkflowsWorkflowCryptoKeyName(v interface{}, d tpgresource.Terraform
return v, nil
}

func expandWorkflowsWorkflowCallLogLevel(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
return v, nil
}

func expandWorkflowsWorkflowUserEnvVars(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
if v == nil {
return map[string]string{}, nil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ resource "google_workflows_workflow" "example" {
region = "us-central1"
description = "Magic"
service_account = google_service_account.test_account.id
call_log_level = "LOG_ERRORS_ONLY"
labels = {
env = "test"
}
Expand Down
14 changes: 8 additions & 6 deletions google/services/workflows/resource_workflows_workflow_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ func TestAccWorkflowsWorkflow_Update(t *testing.T) {
func testAccWorkflowsWorkflow_Update(name string) string {
return fmt.Sprintf(`
resource "google_workflows_workflow" "example" {
name = "%s"
region = "us-central1"
description = "Magic"
name = "%s"
region = "us-central1"
description = "Magic"
call_log_level = "LOG_ERRORS_ONLY"
user_env_vars = {
url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"
}
Expand Down Expand Up @@ -78,9 +79,10 @@ EOF
func testAccWorkflowsWorkflow_Updated(name string) string {
return fmt.Sprintf(`
resource "google_workflows_workflow" "example" {
name = "%s"
region = "us-central1"
description = "Magic"
name = "%s"
region = "us-central1"
description = "Magic"
call_log_level = "LOG_ERRORS_ONLY"
user_env_vars = {
url = "https://timeapi.io/api/Time/current/zone?timeZone=Europe/Amsterdam"
}
Expand Down
10 changes: 9 additions & 1 deletion website/docs/r/workflows_workflow.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ resource "google_workflows_workflow" "example" {
region = "us-central1"
description = "Magic"
service_account = google_service_account.test_account.id
call_log_level = "LOG_ERRORS_ONLY"
labels = {
env = "test"
}
Expand Down Expand Up @@ -120,13 +121,20 @@ The following arguments are supported:

* `source_contents` -
(Optional)
Workflow code to be executed. The size limit is 32KB.
Workflow code to be executed. The size limit is 128KB.

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

* `call_log_level` -
(Optional)
Describes the level of platform logging to apply to calls and call responses during
executions of this workflow. If both the workflow and the execution specify a logging level,
the execution level takes precedence.
Possible values are: `CALL_LOG_LEVEL_UNSPECIFIED`, `LOG_ALL_CALLS`, `LOG_ERRORS_ONLY`, `LOG_NONE`.

* `user_env_vars` -
(Optional)
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".
Expand Down

0 comments on commit 14e5d8d

Please sign in to comment.