Skip to content
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

fix: Sanitize image names when default repo unset #6678

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/skaffold/build/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"golang.org/x/sync/errgroup"

"github.com/GoogleContainerTools/skaffold/pkg/skaffold/constants"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/event"
eventV2 "github.com/GoogleContainerTools/skaffold/pkg/skaffold/event/v2"
"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
Expand Down Expand Up @@ -152,5 +153,6 @@ func performBuild(ctx context.Context, cw io.Writer, tags tag.ImageTags, artifac
if !present {
return "", fmt.Errorf("unable to find tag for image %s", artifact.ImageName)
}
tag = docker.SanitizeImageName(tag)
return build(ctx, cw, artifact, tag)
}
12 changes: 12 additions & 0 deletions pkg/skaffold/build/scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ func TestGetBuild(t *testing.T) {
expectedTag: "skaffold/image1:v0.0.1@sha256:abac",
expectedOut: "Building [skaffold/image1]...\nbuild succeeds",
},
{
description: "tag with ko scheme prefix and Go import path with uppercase characters is sanitized",
buildArtifact: func(ctx context.Context, out io.Writer, artifact *latestV1.Artifact, tag string) (string, error) {
out.Write([]byte("build succeeds"))
return fmt.Sprintf("%s@sha256:abac", tag), nil
},
tags: tag.ImageTags{
"skaffold/image1": "ko://github.com/GoogleContainerTools/skaffold/cmd/skaffold:v0.0.1",
},
expectedTag: "github.com/googlecontainertools/skaffold/cmd/skaffold:v0.0.1@sha256:abac",
expectedOut: "Building [skaffold/image1]...\nbuild succeeds",
},
{
description: "build fails",
buildArtifact: func(ctx context.Context, out io.Writer, artifact *latestV1.Artifact, tag string) (string, error) {
Expand Down