Skip to content

Commit

Permalink
Always clean Dir for packages.Load
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr authored and halvards committed Dec 19, 2021
1 parent 8135bf2 commit 73a4629
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions pkg/build/gobuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func NewGo(ctx context.Context, dir string, options ...Option) (Interface, error
}

func (g *gobuild) qualifyLocalImport(importpath string) (string, error) {
dir := g.dir
if filepath.Clean(g.dir) == "." {
dir := filepath.Clean(g.dir)
if dir == "." {
dir = ""
}
cfg := &packages.Config{
Expand Down Expand Up @@ -203,8 +203,8 @@ func (g *gobuild) IsSupportedReference(s string) error {
if !ref.IsStrict() {
return errors.New("importpath does not start with ko://")
}
dir := g.dir
if filepath.Clean(g.dir) == "." {
dir := filepath.Clean(g.dir)
if dir == "." {
dir = ""
}
pkgs, err := packages.Load(&packages.Config{Dir: dir, Mode: packages.NeedName}, ref.Path())
Expand Down Expand Up @@ -446,8 +446,8 @@ func tarBinary(name, binary string, platform *v1.Platform) (*bytes.Buffer, error
}

func (g *gobuild) kodataPath(ref reference) (string, error) {
dir := g.dir
if filepath.Clean(g.dir) == "." {
dir := filepath.Clean(g.dir)
if dir == "." {
dir = ""
}
pkgs, err := packages.Load(&packages.Config{Dir: dir, Mode: packages.NeedFiles}, ref.Path())
Expand Down
4 changes: 2 additions & 2 deletions pkg/commands/options/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ func createBuildConfigMap(workingDirectory string, configs []build.Config) (map[
// local import paths, therefore add a "./" equivalent as a prefix to
// the constructured import path
localImportPath := fmt.Sprint(".", string(filepath.Separator), path)
dir := baseDir
if filepath.Clean(dir) == "." {
dir := filepath.Clean(baseDir)
if dir == "." {
dir = ""
}
pkgs, err := packages.Load(&packages.Config{Mode: packages.NeedName, Dir: dir}, localImportPath)
Expand Down

0 comments on commit 73a4629

Please sign in to comment.