-
Notifications
You must be signed in to change notification settings - Fork 346
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
Adds ability for user to define additional tags for images #1388
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
"fmt" | ||
"os" | ||
"path/filepath" | ||
"strings" | ||
|
||
"github.com/loft-sh/devpod/pkg/devcontainer/config" | ||
"github.com/loft-sh/devpod/pkg/driver" | ||
|
@@ -70,7 +71,6 @@ | |
} | ||
|
||
if isDockerComposeConfig(substitutedConfig.Config) { | ||
r.Log.Debug("Tagging image prebuild=%s buildInfo=%s", prebuildImage, buildInfo.ImageName) | ||
err = dockerDriver.TagDevContainer(ctx, buildInfo.ImageName, prebuildImage) | ||
if err != nil { | ||
return "", errors.Wrap(err, "tag image") | ||
|
@@ -87,10 +87,27 @@ | |
) | ||
} | ||
|
||
// Setup all image tags (prebuild and any user defined tags) | ||
ImageRefs := []string{prebuildImage} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: imageRefs over ImageRefs |
||
|
||
imageRepoName := strings.Split(prebuildImage, ":") | ||
if buildInfo.Tags != nil { | ||
for _, tag := range buildInfo.Tags { | ||
ImageRefs = append(ImageRefs, imageRepoName[0]+":"+tag) | ||
} | ||
} | ||
|
||
// tag the image | ||
for _, imageRef := range ImageRefs { | ||
err = dockerDriver.TagDevContainer(ctx, prebuildImage, imageRef) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to check err is not nil or log here |
||
} | ||
|
||
// push the image to the registry | ||
err = dockerDriver.PushDevContainer(ctx, prebuildImage) | ||
if err != nil { | ||
return "", errors.Wrap(err, "push image") | ||
for _, imageRef := range ImageRefs { | ||
err = dockerDriver.PushDevContainer(ctx, imageRef) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this could be a one liner with err check |
||
if err != nil { | ||
return "", errors.Wrap(err, "push image") | ||
} | ||
} | ||
|
||
return prebuildImage, nil | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd.Tag is initialised as []string{} so won't be nil, I think it would be better to check
len(cmd.Tag) > 0