diff --git a/integration/examples/custom/build.sh b/integration/examples/custom/build.sh index 97a2b585891..0eefbc1ff8e 100755 --- a/integration/examples/custom/build.sh +++ b/integration/examples/custom/build.sh @@ -1,16 +1,20 @@ #!/usr/bin/env bash set -e -if ! [ -x "$(command -v ko)" ]; then +if ! [ -x "$(go env GOPATH)/bin/ko" ]; then pushd $(mktemp -d) - go mod init tmp; GOFLAGS= go get github.com/google/ko/cmd/ko@v0.6.0 + curl -L https://github.com/google/ko/archive/v0.8.3.tar.gz | tar --strip-components 1 -zx + go build -o $(go env GOPATH)/bin/ko . popd fi -output=$(ko publish --local --preserve-import-paths --tags= . | tee) +output=$($(go env GOPATH)/bin/ko publish --local --preserve-import-paths --tags= . | tee) ref=$(echo "$output" | tail -n1) docker tag "$ref" "$IMAGE" if [[ "${PUSH_IMAGE}" == "true" ]]; then + echo "Pushing $IMAGE" docker push "$IMAGE" +else + echo "Not pushing $IMAGE" fi diff --git a/integration/examples/custom/k8s/pod.yaml b/integration/examples/custom/k8s/pod.yaml index f44d7ef18a4..8602cefa112 100644 --- a/integration/examples/custom/k8s/pod.yaml +++ b/integration/examples/custom/k8s/pod.yaml @@ -1,8 +1,8 @@ apiVersion: v1 kind: Pod metadata: - name: getting-started + name: getting-started-custom spec: containers: - - name: getting-started - image: github.com/googlecontainertools/skaffold/examples/custom + - name: getting-started-custom + image: ko://github.com/GoogleContainerTools/skaffold/examples/custom diff --git a/integration/examples/custom/skaffold.yaml b/integration/examples/custom/skaffold.yaml index 3fe4ddade23..360aa426752 100644 --- a/integration/examples/custom/skaffold.yaml +++ b/integration/examples/custom/skaffold.yaml @@ -2,7 +2,7 @@ apiVersion: skaffold/v2beta21 kind: Config build: artifacts: - - image: github.com/googlecontainertools/skaffold/examples/custom + - image: ko://github.com/GoogleContainerTools/skaffold/examples/custom custom: buildCommand: ./build.sh dependencies: diff --git a/integration/run_test.go b/integration/run_test.go index 823f25dfd4c..a5e9995d7dc 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -113,7 +113,7 @@ var tests = []struct { { description: "custom builder", dir: "examples/custom", - pods: []string{"getting-started"}, + pods: []string{"getting-started-custom"}, }, { description: "buildpacks Go", diff --git a/pkg/skaffold/kubernetes/loader/load.go b/pkg/skaffold/kubernetes/loader/load.go index ce9dd49b5a4..ec38d73559b 100644 --- a/pkg/skaffold/kubernetes/loader/load.go +++ b/pkg/skaffold/kubernetes/loader/load.go @@ -28,6 +28,7 @@ import ( "k8s.io/client-go/tools/clientcmd/api" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/config" + "github.com/GoogleContainerTools/skaffold/pkg/skaffold/docker" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph" "github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubectl" kubectx "github.com/GoogleContainerTools/skaffold/pkg/skaffold/kubernetes/context" @@ -60,7 +61,7 @@ func NewImageLoader(kubeContext string, cli *kubectl.CLI) *ImageLoader { func imagesToLoad(localImages, deployerImages, images []graph.Artifact) []graph.Artifact { local := map[string]bool{} for _, image := range localImages { - local[image.ImageName] = true + local[docker.SanitizeImageName(image.ImageName)] = true } tracked := map[string]bool{} @@ -72,7 +73,7 @@ func imagesToLoad(localImages, deployerImages, images []graph.Artifact) []graph. var res []graph.Artifact for _, image := range images { - if tracked[image.ImageName] { + if tracked[docker.SanitizeImageName(image.ImageName)] { res = append(res, image) } } diff --git a/pkg/skaffold/kubernetes/loader/load_test.go b/pkg/skaffold/kubernetes/loader/load_test.go index 2129da832a9..f5bacc70831 100644 --- a/pkg/skaffold/kubernetes/loader/load_test.go +++ b/pkg/skaffold/kubernetes/loader/load_test.go @@ -200,6 +200,13 @@ func TestImagesToLoad(t *testing.T) { builtImages: []graph.Artifact{{ImageName: "image1", Tag: "foo"}}, expectedImages: nil, }, + { + name: "single image marked as local, with ko prefix and Go import path with uppercase characters", + localImages: []graph.Artifact{{ImageName: "ko://example.com/Organization/Image1", Tag: "Foo"}}, + deployerImages: []graph.Artifact{{ImageName: "example.com/organization/image1", Tag: "Foo"}}, + builtImages: []graph.Artifact{{ImageName: "ko://example.com/Organization/Image1", Tag: "Foo"}}, + expectedImages: []graph.Artifact{{ImageName: "ko://example.com/Organization/Image1", Tag: "Foo"}}, + }, { name: "two images marked as local", localImages: []graph.Artifact{{ImageName: "image1", Tag: "foo"}, {ImageName: "image2", Tag: "bar"}},