1
0
mirror of https://github.com/ko-build/ko.git synced 2025-11-23 22:35:11 +02:00

Update base image to ghcr.io/distroless/static:latest (#737)

* Update base image to ghcr.io/distroless/static:latest

* Add more logging to e2e for windows

* skip timezone conversion on Windows
This commit is contained in:
Jason Hall
2022-06-30 15:12:39 -04:00
committed by GitHub
parent 79a463dc23
commit a61e14dc6a
5 changed files with 25 additions and 4 deletions

View File

@@ -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.

View File

@@ -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.

View File

@@ -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)
}

View File

@@ -1 +1 @@
defaultBaseImage: gcr.io/distroless/base:nonroot
defaultBaseImage: alpine

View File

@@ -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)