Skip to content

Commit

Permalink
Stop using filepath.Join in publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjohnsonjr committed Nov 17, 2020
1 parent ea5dc20 commit c183e84
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 c183e84

Please sign in to comment.