diff --git a/pkg/konfluxgen/docker-build.yaml b/pkg/konfluxgen/docker-build.yaml index eb07e412..824279e6 100644 --- a/pkg/konfluxgen/docker-build.yaml +++ b/pkg/konfluxgen/docker-build.yaml @@ -101,6 +101,10 @@ spec: description: Path to a file with build arguments for buildah, see https://www.mankier.com/1/buildah-build#--build-arg-file name: build-args-file type: string + - default: [] + description: Additional image tags + name: additional-tags + type: array results: - description: "" name: IMAGE_URL @@ -393,6 +397,8 @@ spec: params: - name: IMAGE value: $(tasks.build-container.results.IMAGE_URL) + - name: ADDITIONAL_TAGS + value: $(params.additional-tags) runAfter: - build-container taskRef: diff --git a/pkg/konfluxgen/fbc-builder.yaml b/pkg/konfluxgen/fbc-builder.yaml index 10284d89..7867bfa8 100644 --- a/pkg/konfluxgen/fbc-builder.yaml +++ b/pkg/konfluxgen/fbc-builder.yaml @@ -93,6 +93,10 @@ spec: description: Build a source image. name: build-source-image type: string + - default: [] + description: Additional image tags + name: additional-tags + type: array results: - description: "" name: IMAGE_URL @@ -232,6 +236,8 @@ spec: params: - name: IMAGE value: $(tasks.build-container.results.IMAGE_URL) + - name: ADDITIONAL_TAGS + value: $(params.additional-tags) runAfter: - build-container taskRef: diff --git a/pkg/konfluxgen/konfluxgen.go b/pkg/konfluxgen/konfluxgen.go index 0cd3ff74..751d23d5 100644 --- a/pkg/konfluxgen/konfluxgen.go +++ b/pkg/konfluxgen/konfluxgen.go @@ -172,7 +172,7 @@ func Generate(cfg Config) error { } } - applications[appKey][dockerfileComponentKey(cfg.ComponentNameFunc, c.ReleaseBuildConfiguration, ib)] = DockerfileApplicationConfig{ + r := DockerfileApplicationConfig{ ApplicationName: cfg.ApplicationName, ComponentName: Truncate(Sanitize(cfg.ComponentNameFunc(c.ReleaseBuildConfiguration, ib))), ReleaseBuildConfiguration: c.ReleaseBuildConfiguration, @@ -181,7 +181,9 @@ func Generate(cfg Config) error { Nudges: append(cfg.Nudges, cfg.NudgesFunc(c.ReleaseBuildConfiguration, ib)...), Pipeline: pipeline, AdditionalTektonCELExpression: cfg.AdditionalTektonCELExpressionFunc(c.ReleaseBuildConfiguration, ib), + Tags: []string{"latest"}, } + applications[appKey][dockerfileComponentKey(cfg.ComponentNameFunc, c.ReleaseBuildConfiguration, ib)] = r } } @@ -348,6 +350,8 @@ type DockerfileApplicationConfig struct { AdditionalTektonCELExpression string Event PipelineEvent Pipeline Pipeline + + Tags []string } type PipelineEvent string diff --git a/pkg/konfluxgen/pipeline-run.template.yaml b/pkg/konfluxgen/pipeline-run.template.yaml index 6fbd7fb3..fe020016 100644 --- a/pkg/konfluxgen/pipeline-run.template.yaml +++ b/pkg/konfluxgen/pipeline-run.template.yaml @@ -35,6 +35,10 @@ spec: {{{- end }}} - name: revision value: '{{revision}}' + {{{- if eq .Event "push" }}} + - name: additional-tags + value: [{{{ range $tag := .Tags }}} {{{ $tag }}}, {{{ end }}}] + {{{- end }}} pipelineRef: name: {{{ .Pipeline }}} taskRunTemplate: {}