diff --git a/third_party/terraform/resources/resource_cloudbuild_build_trigger.go b/third_party/terraform/resources/resource_cloudbuild_build_trigger.go index 7b5daf704bdd..9f85e9dbf99f 100644 --- a/third_party/terraform/resources/resource_cloudbuild_build_trigger.go +++ b/third_party/terraform/resources/resource_cloudbuild_build_trigger.go @@ -64,8 +64,11 @@ func resourceCloudBuildTrigger() *schema.Resource { Optional: true, }, "args": &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeList, Optional: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, }, }, @@ -294,7 +297,7 @@ func expandCloudbuildBuildTriggerBuild(d *schema.ResourceData) *cloudbuild.Build Name: d.Get(fmt.Sprintf("build.0.step.%d.name", s)).(string), } if v, ok := d.GetOk(fmt.Sprintf("build.0.step.%d.args", s)); ok { - step.Args = strings.Split(v.(string), " ") + step.Args = convertStringArr(v.([]interface{})) } build.Steps = append(build.Steps, step) } @@ -317,7 +320,7 @@ func flattenCloudbuildBuildTriggerBuild(d *schema.ResourceData, config *Config, for i, step := range b.Steps { steps[i] = map[string]interface{}{} steps[i]["name"] = step.Name - steps[i]["args"] = strings.Join(step.Args, " ") + steps[i]["args"] = convertStringArrToInterface(step.Args) } flattened[0]["step"] = steps } diff --git a/third_party/terraform/tests/resource_cloudbuild_build_trigger_test.go b/third_party/terraform/tests/resource_cloudbuild_build_trigger_test.go index 2489a8d4be0a..7a230c1bf34e 100644 --- a/third_party/terraform/tests/resource_cloudbuild_build_trigger_test.go +++ b/third_party/terraform/tests/resource_cloudbuild_build_trigger_test.go @@ -204,15 +204,15 @@ resource "google_cloudbuild_trigger" "build_trigger" { tags = ["team-a", "service-b"] step { name = "gcr.io/cloud-builders/gsutil" - args = "cp gs://mybucket/remotefile.zip localfile.zip " + args = ["cp", "gs://mybucket/remotefile.zip", "localfile.zip"] } step { name = "gcr.io/cloud-builders/go" - args = "build my_package" + args = ["build", "my_package"] } step { name = "gcr.io/cloud-builders/docker" - args = "build -t gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA -f Dockerfile ." + args = ["build", "-t", "gcr.io/$PROJECT_ID/$REPO_NAME:$COMMIT_SHA", "-f", "Dockerfile ."] } } } @@ -253,19 +253,19 @@ resource "google_cloudbuild_trigger" "build_trigger" { tags = ["team-a", "service-b", "updated"] step { name = "gcr.io/cloud-builders/gsutil" - args = "cp gs://mybucket/remotefile.zip localfile-updated.zip " + args = ["cp", "gs://mybucket/remotefile.zip", "localfile-updated.zip "] } step { name = "gcr.io/cloud-builders/go" - args = "build my_package_updated" + args = ["build", "my_package_updated"] } step { name = "gcr.io/cloud-builders/docker" - args = "build -t gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA -f Dockerfile ." + args = ["build", "-t", "gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA", "-f", "Dockerfile ."] } step { name = "gcr.io/$PROJECT_ID/$REPO_NAME:$SHORT_SHA" - args = "test" + args = ["test"] } } }