Skip to content

Commit

Permalink
Merge pull request ko-build#247 from jonjohnsonjr/filepath
Browse files Browse the repository at this point in the history
Stop using filepath.Join in publisher
  • Loading branch information
imjasonh authored Nov 17, 2020
2 parents ea5dc20 + c183e84 commit bd1ec54
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/commands/options/publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package options
import (
"crypto/md5" //nolint: gosec // No strong cryptography needed.
"encoding/hex"
"path/filepath"
"path"

"github.com/google/ko/pkg/publish"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -71,15 +71,15 @@ func AddPublishArg(cmd *cobra.Command, po *PublishOptions) {
func packageWithMD5(base, importpath string) string {
hasher := md5.New() //nolint: gosec // No strong cryptography needed.
hasher.Write([]byte(importpath))
return filepath.Join(base, filepath.Base(importpath)+"-"+hex.EncodeToString(hasher.Sum(nil)))
return path.Join(base, path.Base(importpath)+"-"+hex.EncodeToString(hasher.Sum(nil)))
}

func preserveImportPath(base, importpath string) string {
return filepath.Join(base, importpath)
return path.Join(base, importpath)
}

func baseImportPaths(base, importpath string) string {
return filepath.Join(base, filepath.Base(importpath))
return path.Join(base, path.Base(importpath))
}

func bareDockerRepo(base, _ string) string {
Expand Down
4 changes: 2 additions & 2 deletions pkg/publish/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"fmt"
"log"
"net/http"
"path/filepath"
"path"
"strings"

"github.com/google/go-containerregistry/pkg/authn"
Expand Down Expand Up @@ -59,7 +59,7 @@ type Namer func(string, string) string
// name for maximum clarity, e.g.
// gcr.io/foo/github.com/bar/baz/cmd/blah
// ^--base--^ ^-------import path-------^
func identity(base, in string) string { return filepath.Join(base, in) }
func identity(base, in string) string { return path.Join(base, in) }

// As some registries do not support pushing an image by digest, the default tag for pushing
// is the 'latest' tag.
Expand Down

0 comments on commit bd1ec54

Please sign in to comment.