Skip to content

fix: skip empty image_templates in docker_manifests #5825

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

Merged
merged 1 commit into from
Jun 12, 2025

Conversation

zerospiel
Copy link
Contributor

Skips empty strings of the given image_templates from the docker_manifests section after evaluation.

This allows usage of conditionals for some of the filtered dockers builds (e.g. by ids), such as:

builds:
  - id: amd_build
    goos:
      - linux
    goarch:
      - amd64

  - id: arm_build
    goos:
      - linux
    goarch:
      - arm64
    skip: >-
      {{ if skip }}{{ true }}{{ else }}false{{ end }}

dockers:
  - image_templates:
      - repo/image:tag-amd64
    ids:
      - amd_build
    use: buildx
    build_flag_templates:
      - --platform=linux/amd64

  - image_templates:
      - repo/image:tag-arm64
    ids:
      - arm_build
    goarch: arm64
    use: buildx
    build_flag_templates:
      - --platform=linux/arm64/v8

docker_manifests:
  - name_template: "repo/image:tag"
    image_templates:
      - "repo/image:tag-amd64"
      - >- 
        {{ if skip }}{{""}}{{ else }}repo/image:tag-arm64{{ end }}

Fixes #5824

Skips empty strings of the given image_templates from the
docker_manifests section after evaluation.
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 11, 2025
@zerospiel
Copy link
Contributor Author

The change is literally 3 lines, the rest is the unit tests built specifically for the function, and they took a little more

@caarlos0 caarlos0 added the bug Something isn't working label Jun 11, 2025
Copy link

codecov bot commented Jun 11, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 82.67%. Comparing base (ddb94f4) to head (9f240e4).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5825   +/-   ##
=======================================
  Coverage   82.67%   82.67%           
=======================================
  Files         164      164           
  Lines       16440    16442    +2     
=======================================
+ Hits        13592    13594    +2     
  Misses       2256     2256           
  Partials      592      592           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@caarlos0 caarlos0 merged commit 1a72d4e into goreleaser:main Jun 12, 2025
16 checks passed
@caarlos0
Copy link
Member

thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow building docker manifests having empty template values
2 participants