mirror of
https://github.com/ko-build/ko.git
synced 2025-11-26 22:40:38 +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:
2
.github/workflows/e2e.yaml
vendored
2
.github/workflows/e2e.yaml
vendored
@@ -50,7 +50,7 @@ jobs:
|
|||||||
|
|
||||||
# Build and run the test/ binary, which should log "Hello there" served from KO_DATA_PATH
|
# 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)
|
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.
|
# Check that symlinks in kodata are chased.
|
||||||
# Skip this test on Windows.
|
# Skip this test on Windows.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
// configDefaultBaseImage is the default base image if not specified in .ko.yaml.
|
// 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.
|
// BuildOptions represents options for the ko builder.
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestDefaultBaseImage(t *testing.T) {
|
|||||||
t.Fatal(err)
|
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 {
|
if bo.BaseImage != wantDefaultBaseImage {
|
||||||
t.Fatalf("wanted BaseImage %s, got %s", wantDefaultBaseImage, bo.BaseImage)
|
t.Fatalf("wanted BaseImage %s, got %s", wantDefaultBaseImage, bo.BaseImage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
defaultBaseImage: gcr.io/distroless/base:nonroot
|
defaultBaseImage: alpine
|
||||||
|
|||||||
21
test/main.go
21
test/main.go
@@ -16,12 +16,15 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
// Give this an interesting import
|
// Give this an interesting import
|
||||||
_ "github.com/google/go-containerregistry/pkg/registry"
|
_ "github.com/google/go-containerregistry/pkg/registry"
|
||||||
@@ -40,6 +43,24 @@ func main() {
|
|||||||
|
|
||||||
log.Println("version =", version)
|
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")
|
dp := os.Getenv("KO_DATA_PATH")
|
||||||
file := filepath.Join(dp, *f)
|
file := filepath.Join(dp, *f)
|
||||||
bytes, err := ioutil.ReadFile(file)
|
bytes, err := ioutil.ReadFile(file)
|
||||||
|
|||||||
Reference in New Issue
Block a user