Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a trigger_template pointing at a different project on google_cloudbuild_trigger creates trigger pointing to host project #1555

Closed
chrisfowles opened this issue May 29, 2018 · 2 comments

Comments

@chrisfowles
Copy link

Terraform Version

Terraform v0.11.7

Affected Resource(s)

  • google_cloudbuild_trigger

Terraform Configuration Files

resource "google_cloudbuild_trigger" "cloudbuild" {
  project = "allegedly-emerging-tiger"

  trigger_template = {
    branch_name = "master"
    project     = "routinely-included-fawn"
    repo_name   = "python-appengine-flask-hello"
  }
}

Debug Output

2018-05-29T15:19:48.652+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: -----------------------------------------------------
2018-05-29T15:19:48.695+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: 2018/05/29 15:19:48 [INFO] build trigger request: {"build":{},"triggerTemplate":{"branchName":"master","projectId":"allegedly-emerging-tiger","repoName":"python-appengine-flask-hello"}}
2018-05-29T15:19:48.696+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: 2018/05/29 15:19:48 [DEBUG] Google API Request Details:
2018-05-29T15:19:48.696+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: ---[ REQUEST ]---------------------------------------
2018-05-29T15:19:48.696+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: POST /v1/projects/allegedly-emerging-tiger/triggers?alt=json HTTP/1.1
2018-05-29T15:19:48.696+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: Host: cloudbuild.googleapis.com
2018-05-29T15:19:48.696+1000 [DEBUG] plugin.terraform-provider-google_v1.13.0_x4: User-Agent: google-api-go-client/0.5 Terraform/0.11.3-dev (+https://www.terraform.io)

Expected Behavior

Trigger should have been created for repo in routinely-included-fawn within container build for allegedly-emerging-tiger project.

Actual Behavior

Trigger was created for repo in llegedly-emerging-tiger.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

References

Bug in #1357

	tmpl := &cloudbuild.RepoSource{}
	if v, ok := d.GetOk("project"); ok {
		tmpl.ProjectId = v.(string)
	} else {
		tmpl.ProjectId = project
	}

should probably be

	tmpl := &cloudbuild.RepoSource{}
	if v, ok := d.GetOk("trigger_template.0.project"); ok {
		tmpl.ProjectId = v.(string)
	} else {
		tmpl.ProjectId = project
	}
@jamielennox
Copy link
Contributor

working with @chrisfowles on this and it seems to solve the problem for us.

rosbo pushed a commit that referenced this issue May 29, 2018
…#1556)

When creating a trigger by using the project defined in the schema we
enforce that the repo must be in that same project. We should be looking
at the project defined in the trigger_template data and falling back to
that first project if not found.

Closes: #1555
@ghost
Copy link

ghost commented Nov 18, 2018

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants