Skip to content

Commit

Permalink
Tag images with 'latest' tag (#226)
Browse files Browse the repository at this point in the history
Signed-off-by: Pierangelo Di Pilato <[email protected]>
  • Loading branch information
pierDipi authored Sep 3, 2024
1 parent 3cba828 commit e9f6e14
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
6 changes: 6 additions & 0 deletions pkg/konfluxgen/docker-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,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
Expand Down Expand Up @@ -400,6 +404,8 @@ spec:
params:
- name: IMAGE
value: $(tasks.build-container.results.IMAGE_URL)
- name: ADDITIONAL_TAGS
value: $(params.additional-tags)
runAfter:
- build-container
taskRef:
Expand Down
6 changes: 6 additions & 0 deletions pkg/konfluxgen/fbc-builder.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 5 additions & 1 deletion pkg/konfluxgen/konfluxgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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,
Expand All @@ -182,7 +182,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
}
}

Expand Down Expand Up @@ -349,6 +351,8 @@ type DockerfileApplicationConfig struct {
AdditionalTektonCELExpression string
Event PipelineEvent
Pipeline Pipeline

Tags []string
}

type PipelineEvent string
Expand Down
4 changes: 4 additions & 0 deletions pkg/konfluxgen/pipeline-run.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: {}
Expand Down

0 comments on commit e9f6e14

Please sign in to comment.