Skip to content

Commit

Permalink
Moves CB "thirdparty" config to "non-oti-prod" (#70)
Browse files Browse the repository at this point in the history
* Moves CB "thirdparty" config to "non-oti-prod"

cloudbuild-thirdparty.yaml existed only because of required deployments in the
mlab-autojoin project, in which there is no
gcr.io/mlab-autojoin/gcloud-jsonnet-cbif container image, so it manually
pointed to the version of the container image in mlab-oti.

We now have that same need in the measurement-lab project, for which the name
"thirdparty" didn't make sense.

This is an attempt to rename the secondary Cloud Build config file to something
that both the mlab-autojoin and measurement-lab project Cloud Build triggers
can use.

Additionally, I realized that the version terraform that the scripts were
downloading was a bit old. This commit updates the version to the latest, and
additionally makes it an environment variable to avoid so much duplication.

* Escape refs to TF_RELEASE to avoid CB errors

* Removes seconary CB config in favor of CB variable

Rather than having two Cloud Build configurations with the only difference
being the container image path for step #1, this commit removes the secondary
configuration in favor of just creating a user-defined build trigger
substitution in each project pointing to the appropriate container image for
the build.

* Puts an underscore in front of CONTAINER_IMAGE var

* Adds the container image version to the build config

So that the container version is more transparent to a viewer of this
repository, this commit removes the version string from the variable
$_CONTAINER_IMAGE and instead appends it in the build config file. Not only is
this more transparent, but when we need to update the version we just update it
once in this file, rather than having to update variables in build triggers in
every project.
  • Loading branch information
nkinkade committed Mar 7, 2024
1 parent 5a82add commit 3a30053
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
23 changes: 0 additions & 23 deletions cloudbuild-thirdparty.yaml

This file was deleted.

18 changes: 15 additions & 3 deletions cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,28 @@
# hours. Set the timeout to around double that just for room to grow.
timeout: 36000s

# $_CONTAINER_IMAGE is going to be some form of:
#
# gcr.io/<project>/gcloud-jsonnet-cbif
#
# We have this in a Cloud Build user-defined substitution variable because
# this build gets run in more projects that just the standard
# sandbox->staging->prod, but those projects are the only ones where the
# container image is built and pushed to Artifact Registry. The other projects
# are "mlab-autojoin" and "measurement-lab", both of which are production
# projects, so in those we want to use the "mlab-oti" (prod) image. The value of
# this variable is defined in the build trigger of each project.
steps:
- name: gcr.io/$PROJECT_ID/gcloud-jsonnet-cbif:1.1
- name: ${_CONTAINER_IMAGE}:1.1
entrypoint: /bin/bash
args:
- -c
- |-
export TF_RELEASE="1.7.4"
apt update
apt install --yes unzip
curl --remote-name https://releases.hashicorp.com/terraform/1.5.3/terraform_1.5.3_linux_amd64.zip
unzip terraform_1.5.3_linux_amd64.zip
curl --remote-name https://releases.hashicorp.com/terraform/$${TF_RELEASE}/terraform_$${TF_RELEASE}_linux_amd64.zip
unzip terraform_$${TF_RELEASE}_linux_amd64.zip
mv terraform /usr/local/bin/
export PROJECT=$PROJECT_ID
bash scripts/tf_apply.sh $$PROJECT

0 comments on commit 3a30053

Please sign in to comment.