diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml index 75a9888488..8ce3ea0f6a 100644 --- a/.github/workflows/e2e.yaml +++ b/.github/workflows/e2e.yaml @@ -50,7 +50,7 @@ jobs: # Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH testimg=$(go run ./ build ./test --platform=${PLATFORM} --preserve-import-paths) - docker run ${testimg} --wait=false 2>&1 | grep "Hello there" + docker run ${testimg} --wait=false 2>&1 | tee >(grep "Hello there") # Log all output too. # Check that symlinks in kodata are chased. # Skip this test on Windows. diff --git a/pkg/commands/options/build.go b/pkg/commands/options/build.go index 799eebd5b2..c0331cebb6 100644 --- a/pkg/commands/options/build.go +++ b/pkg/commands/options/build.go @@ -32,7 +32,7 @@ import ( const ( // configDefaultBaseImage is the default base image if not specified in .ko.yaml. - configDefaultBaseImage = "gcr.io/distroless/static:nonroot" + configDefaultBaseImage = "ghcr.io/distroless/static:latest" ) // BuildOptions represents options for the ko builder. diff --git a/pkg/commands/options/build_test.go b/pkg/commands/options/build_test.go index 1f066cb6e3..60d4ac46a1 100644 --- a/pkg/commands/options/build_test.go +++ b/pkg/commands/options/build_test.go @@ -32,7 +32,7 @@ func TestDefaultBaseImage(t *testing.T) { t.Fatal(err) } - wantDefaultBaseImage := "gcr.io/distroless/base:nonroot" // matches value in ./testdata/.ko.yaml + wantDefaultBaseImage := "alpine" // matches value in ./testdata/config/.ko.yaml if bo.BaseImage != wantDefaultBaseImage { t.Fatalf("wanted BaseImage %s, got %s", wantDefaultBaseImage, bo.BaseImage) } diff --git a/pkg/commands/options/testdata/config/.ko.yaml b/pkg/commands/options/testdata/config/.ko.yaml index cac68c85a4..b65d481c4a 100644 --- a/pkg/commands/options/testdata/config/.ko.yaml +++ b/pkg/commands/options/testdata/config/.ko.yaml @@ -1 +1 @@ -defaultBaseImage: gcr.io/distroless/base:nonroot +defaultBaseImage: alpine diff --git a/test/main.go b/test/main.go index b177f47f89..af9ffe5c30 100644 --- a/test/main.go +++ b/test/main.go @@ -16,12 +16,15 @@ package main import ( "flag" + "fmt" "io/ioutil" "log" "os" "os/signal" "path/filepath" + "runtime" "syscall" + "time" // Give this an interesting import _ "github.com/google/go-containerregistry/pkg/registry" @@ -40,6 +43,24 @@ func main() { log.Println("version =", version) + if runtime.GOOS == "windows" { + // Go seems to not load location data from Windows, so timezone + // conversion fails unless tzdata is embedded in the Go program + // with the go build tag `timetzdata`. Since we want to test + // loading tzdata provided by the base image below, we'll just + // skip that for Windows here. + // See https://github.com/google/ko/issues/739 + log.Println("skipping timezone conversion on Windows") + } else { + // Exercise timezone conversions, which demonstrates tzdata is provided + // by the base image. + now := time.Now() + loc, _ := time.LoadLocation("UTC") + fmt.Printf("UTC Time: %s\n", now.In(loc)) + loc, _ = time.LoadLocation("America/New_York") + fmt.Printf("New York Time: %s\n", now.In(loc)) + } + dp := os.Getenv("KO_DATA_PATH") file := filepath.Join(dp, *f) bytes, err := ioutil.ReadFile(file)