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

Adding "name" to Cloud Build trigger resource #2492

Merged
merged 4 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ features/tools:
* Terraform in Cloud Shell

Importantly, Magic Modules *isn't* full code generation. Every change is made
manually; more than a code generator, Magic Modules is a force multiplier for
manually; more than a code generator, Magic Modules is a force multiplier for
development. While many Magic Modules resources are defined exactly based on the
GCP API, we use Magic Modules to preemptively solve issues across each tool by
encoding our field-tested learnings from other tools in those definitions. In
Expand Down Expand Up @@ -61,6 +61,8 @@ To get started, you'll need:
* You can use `rbenv` to manage your Ruby version(s)
* [`Bundler`](https://github.com/bundler/bundler)
* This can be installed with `gem install bundler`
* If you are getting "Too many open files" ulimit needs to be raised.
* Mac OSX: `ulimit -n 1000`

### Preparing Magic Modules / One-time setup

Expand Down
2 changes: 1 addition & 1 deletion build/ansible
2 changes: 1 addition & 1 deletion build/terraform
2 changes: 1 addition & 1 deletion build/terraform-beta
2 changes: 1 addition & 1 deletion build/terraform-mapper
4 changes: 4 additions & 0 deletions products/cloudbuild/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ objects:
description: |
The unique identifier for the trigger.
output: true
- !ruby/object:Api::Type::String
name: 'name'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: Reviewing in Terraform context
Adding a property to api.yaml will default to making it optional. However since this property is created by the API if it's not specified you will need to also have it marked as Computed in Terraform. If it's not Computed and a user upgrades to this version, subsequent terraform apply runs will attempt to override the name with an empty string as it will detect a difference between what had been specified in the config and what was set in the state from the API.

To do this you can set the property to default_from_api: true in the terraform.yaml. See triggerTemplate.projectId as an example.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Chris! This makes a ton of sense. I'm adding this because creating multiple triggers at once sometimes results in them getting the same computed name. Thanks for reviewing and explaining how to add this default.

I've made the change (I think in the right way). 👍

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks, a much needed addition.

description: |
Name of the trigger. Must be unique within the project.
- !ruby/object:Api::Type::String
name: 'description'
description: |
Expand Down
2 changes: 2 additions & 0 deletions products/cloudbuild/terraform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ overrides: !ruby/object:Overrides::ResourceOverrides
properties:
id: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'trigger_id'
name: !ruby/object:Overrides::Terraform::PropertyOverride
default_from_api: true
build.steps: !ruby/object:Overrides::Terraform::PropertyOverride
name: 'step'
triggerTemplate: !ruby/object:Overrides::Terraform::PropertyOverride
Expand Down