Skip to content

Commit

Permalink
Viper keys are case insensitive. (ko-build#150)
Browse files Browse the repository at this point in the history
* 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: tektoncd/pipeline#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
  • Loading branch information
mattmoor authored Apr 20, 2020
1 parent 3e73a50 commit f45bc13
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pkg/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"os"
"os/signal"
"strconv"
"strings"
"syscall"
"time"

Expand All @@ -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
}
Expand Down

0 comments on commit f45bc13

Please sign in to comment.