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

Have kind.local test use --platform=all #208

Merged
merged 1 commit into from
Sep 29, 2020
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: 1 addition & 1 deletion integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ROOT_DIR="$(pwd)"
echo "Running smoke test."
go install ./cmd/ko
# Travis runs this against a kind cluster so properly use the kind publisher.
KO_DOCKER_REPO=kind.local ko apply -f ./cmd/ko/test
KO_DOCKER_REPO=kind.local ko apply --platform=all -f ./cmd/ko/test
kubectl wait --timeout=10s --for=condition=Ready pod/kodata

echo "Moving GOPATH into /tmp/ to test modules behavior."
Expand Down
39 changes: 37 additions & 2 deletions pkg/publish/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package publish
import (
"fmt"
"log"
"os"
"strings"

"github.com/google/go-containerregistry/pkg/name"
Expand Down Expand Up @@ -50,8 +51,42 @@ func (t *kindPublisher) Publish(br build.Result, s string) (name.Reference, erro
s = strings.ToLower(s)

// There's no way to write an index to a kind, so attempt to downcast it to an image.
img, ok := br.(v1.Image)
if !ok {
var img v1.Image
switch i := br.(type) {
case v1.Image:
img = i
case v1.ImageIndex:
im, err := i.IndexManifest()
if err != nil {
return nil, err
}
goos, goarch := os.Getenv("GOOS"), os.Getenv("GOARCH")
if goos == "" {
goos = "linux"
}
if goarch == "" {
goarch = "amd64"
}
for _, manifest := range im.Manifests {
if manifest.Platform == nil {
continue
}
if manifest.Platform.OS != goos {
continue
}
if manifest.Platform.Architecture != goarch {
continue
}
img, err = i.Image(manifest.Digest)
if err != nil {
return nil, err
}
break
}
if img == nil {
return nil, fmt.Errorf("failed to find %s/%s image in index for image: %v", goos, goarch, s)
}
default:
return nil, fmt.Errorf("failed to interpret %s result as image: %v", s, br)
}

Expand Down