1
0
mirror of https://github.com/ko-build/ko.git synced 2025-03-11 14:09:45 +02:00

Viper keys are case insensitive. (#150)

* Viper keys are case insensitive.

This fixes an issue where import paths with uppercase (github.com/GoogleCloudPlatform 👀) were being canonicalized by Viper to all lowercase and the baseImageOverrides in `.ko.yaml` were failing to properly identify the base image.

I hit this in: https://github.com/tektoncd/pipeline/pull/2435 trying to opt some of the GCP images out of `:nonroot`.

This also adds some logging to a place where I see a lot of folks have issues with `ko` where we swallow an error.  I hit it experimenting with variants on the `ko publish` import path, and added the logging to debug.

* Drop the new log statement
This commit is contained in:
Matt Moore 2020-04-20 09:13:33 -07:00 committed by GitHub
parent 3e73a508fa
commit f45bc13ded
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,6 +21,7 @@ import (
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"
@ -37,7 +38,13 @@ var (
)
func getBaseImage(s string) (v1.Image, error) {
ref, ok := baseImageOverrides[s]
// Viper configuration file keys are case insensitive, and are
// returned as all lowercase. This means that import paths with
// uppercase must be normalized for matching here, e.g.
// github.com/GoogleCloudPlatform/foo/cmd/bar
// comes through as:
// github.com/googlecloudplatform/foo/cmd/bar
ref, ok := baseImageOverrides[strings.ToLower(s)]
if !ok {
ref = defaultBaseImage
}