Skip to content
Open
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
3 changes: 3 additions & 0 deletions .kokoro/docker/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ steps:
dir: '.kokoro/docker'
- name: gcr.io/cloud-builders/docker
args: ['tag', 'gcr.io/$PROJECT_ID/python-samples-testing-docker', 'gcr.io/$PROJECT_ID/python-samples-testing-docker:$SHORT_SHA']
- name: gcr.io/cloud-builders/docker
args: ['tag', 'gcr.io/$PROJECT_ID/python-samples-testing-docker', 'gcr.io/$PROJECT_ID/python-samples-testing-docker:infrastructure-public-image-$SHORT_SHA']
Comment on lines +23 to +24
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This new step duplicates the image name gcr.io/$PROJECT_ID/python-samples-testing-docker, which is also used in the preceding step and in the images list. This repetition makes the configuration harder to maintain and more prone to errors if the image name ever needs to change.

To improve maintainability, I recommend defining the base image name as a user-defined substitution variable at the top of your cloudbuild.yaml file.

For example:

substitutions:
  _IMAGE_NAME: 'gcr.io/$PROJECT_ID/python-samples-testing-docker'

You can then use ${_IMAGE_NAME} throughout the file, which will make future updates much easier and safer. For example:

...
    - name: gcr.io/cloud-builders/docker
      args: ['tag', '${_IMAGE_NAME}', '${_IMAGE_NAME}:$SHORT_SHA']
    - name: gcr.io/cloud-builders/docker
      args: ['tag', '${_IMAGE_NAME}', '${_IMAGE_NAME}:infrastructure-public-image-$SHORT_SHA']
images:
     - '${_IMAGE_NAME}'
     - '${_IMAGE_NAME}:infrastructure-public-image-$SHORT_SHA'

While this change is outside the scope of a direct code suggestion for this PR, I strongly recommend applying this refactoring for better long-term maintainability.

images:
- 'gcr.io/$PROJECT_ID/python-samples-testing-docker'
- 'gcr.io/$PROJECT_ID/python-samples-testing-docker:infrastructure-public-image-$SHORT_SHA'

options:
logging: CLOUD_LOGGING_ONLY