diff --git a/internal/pipe/ko/ko.go b/internal/pipe/ko/ko.go index 5c0706f08..446237c78 100644 --- a/internal/pipe/ko/ko.go +++ b/internal/pipe/ko/ko.go @@ -49,8 +49,9 @@ var ( azureKeychain, ) - errNoRepository = errors.New("ko: missing repository: please set either the repository field or a $KO_DOCKER_REPO environment variable") - errInvalidMainPath = errors.New("ko: invalid Main path: ko.main (or build.main if ko.main is not set) should be a relative path") + errNoRepository = errors.New("ko: missing repository: please set either the repository field or a $KO_DOCKER_REPO environment variable") + errInvalidMainPath = errors.New("ko: invalid Main path: ko.main (or build.main if ko.main is not set) should be a relative path") + errInvalidMainGoPath = errors.New("ko: invalid Main path: your path should point to a directory instead of a .go file") ) // Pipe that build OCI compliant images with ko. @@ -437,7 +438,7 @@ func validateMainPath(path string) error { } // paths sure can have dots in them, but if the path ends in .go, it's propably a file that one misundertood as a valid value if strings.HasSuffix(path, ".go") { - return errInvalidMainPath + return errInvalidMainGoPath } return nil } diff --git a/internal/pipe/ko/ko_test.go b/internal/pipe/ko/ko_test.go index db00e4dc4..2fa475fa9 100644 --- a/internal/pipe/ko/ko_test.go +++ b/internal/pipe/ko/ko_test.go @@ -353,7 +353,7 @@ func TestKoValidateMainPathIssue4382(t *testing.T) { require.ErrorIs(t, validateMainPath("app/"), errInvalidMainPath) require.ErrorIs(t, validateMainPath("/src/"), errInvalidMainPath) require.ErrorIs(t, validateMainPath("/src/app"), errInvalidMainPath) - require.ErrorIs(t, validateMainPath("./testdata/app/main.go"), errInvalidMainPath) + require.ErrorIs(t, validateMainPath("./testdata/app/main.go"), errInvalidMainGoPath) // testing with real context ctxOk := testctx.NewWithCfg(config.Project{