Skip to content

Commit

Permalink
Ensure that the tag is explicit in the error message when validating …
Browse files Browse the repository at this point in the history
…a docker image
  • Loading branch information
torrefatto committed Feb 15, 2024
1 parent b7b0f37 commit 51f5e58
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/koyeb/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1230,18 +1230,18 @@ func checkDockerImage(ctx *CLIContext, source *koyeb.DockerSource) error {
res, resp, err := req.Execute()
if err != nil {
return errors.NewCLIErrorFromAPIError(
fmt.Sprintf("Error while checking the validity of the docker image `%s`", source.GetImage()),
fmt.Sprintf("Error while checking the validity of the docker image `%s`", getImageRef(source)),
err,
resp,
)
}

if !res.GetSuccess() {
return &errors.CLIError{
What: fmt.Sprintf("Error while checking the validity of the docker image `%s`", source.GetImage()),
What: fmt.Sprintf("Error while checking the validity of the docker image `%s`", getImageRef(source)),
Why: res.GetReason(),
Additional: []string{
fmt.Sprintf("Make sure the image name `%s` is correct and that the image exists.", source.GetImage()),
fmt.Sprintf("Make sure the image name `%s` is correct and that the image exists.", getImageRef(source)),
"If the image requires authentication, make sure to provide the parameter --docker-private-registry-secret.",
},
Orig: nil,
Expand All @@ -1250,3 +1250,12 @@ func checkDockerImage(ctx *CLIContext, source *koyeb.DockerSource) error {
}
return nil
}

func getImageRef(source *koyeb.DockerSource) string {
ref := source.GetImage()
parts := strings.Split(ref, ":")
if len(parts) == 1 {
return fmt.Sprintf("%s:latest", ref)
}
return ref
}

0 comments on commit 51f5e58

Please sign in to comment.