Skip to content

Commit

Permalink
Add tag to image name output (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
baksetercx authored Oct 30, 2024
1 parent 309e926 commit d15013c
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pkg/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,12 +281,14 @@ func Build(c *cli.Context) error {
applicationName,
)

additionalTags := utils.RemoveZeroValues(c.StringSlice("additional-tags"))

buildImageCommandOutput := buildImageCommand(
dockerfilePath,
buildContext,
imageName,
cacheTag,
utils.RemoveZeroValues(c.StringSlice("additional-tags")),
additionalTags,
nil,
)
if command.IsError(buildImageCommandOutput) {
Expand Down Expand Up @@ -343,7 +345,21 @@ func Build(c *cli.Context) error {
}
}

err = os.WriteFile(outputDirectory+"/image-name", []byte(imageName), 0644)
firstAdditionalTagThatsNotCacheTag := func() string {
for _, tag := range additionalTags {
if tag != cacheTag {
return tag
}
}

return cacheTag
}()

err = os.WriteFile(
outputDirectory+"/image-name",
[]byte(imageName+":"+firstAdditionalTagThatsNotCacheTag),
0700,
)
if err != nil {
return cli.Exit(err, 1)
}
Expand Down

0 comments on commit d15013c

Please sign in to comment.