Skip to content

Commit

Permalink
fix: fix windows path bug (#280)
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed Mar 18, 2024
1 parent f70f6ff commit 80caaec
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/api/kpm_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func RunOciPkg(ociRef, version string, opts *opt.CompileOptions) (*kcl.KCLResult
// clean the temp dir.
defer os.RemoveAll(tmpDir)

localPath := ociOpts.AddStoragePathSuffix(tmpDir)
localPath := ociOpts.SanitizePathWithSuffix(tmpDir)

// 2. Pull the tar.
err = oci.Pull(localPath, ociOpts.Reg, ociOpts.Repo, ociOpts.Tag, kpmcli.GetSettings())
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ func (c *KpmClient) CompileOciPkg(ociSource, version string, opts *opt.CompileOp
// clean the temp dir.
defer os.RemoveAll(tmpDir)

localPath := ociOpts.AddStoragePathSuffix(tmpDir)
localPath := ociOpts.SanitizePathWithSuffix(tmpDir)

// 2. Pull the tar.
err = c.pullTarFromOci(localPath, ociOpts)
Expand Down Expand Up @@ -1015,7 +1015,7 @@ func (c *KpmClient) PullFromOci(localPath, source, tag string) error {
// clean the temp dir.
defer os.RemoveAll(tmpDir)

storepath := ociOpts.AddStoragePathSuffix(tmpDir)
storepath := ociOpts.SanitizePathWithSuffix(tmpDir)
err = c.pullTarFromOci(storepath, ociOpts)
if err != nil {
return err
Expand Down
1 change: 1 addition & 0 deletions pkg/opt/opt.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ func ParseOciUrl(ociUrl string) (*OciOptions, *reporter.KpmEvent) {
// }
//
// You will get a path '/usr/test/docker.io/test/testRepo/v0.0.1'.
// Deprecated: This function will be deprecated, use 'SanitizePathWithSuffix' instead.
func (oci *OciOptions) AddStoragePathSuffix(pathPrefix string) string {
return filepath.Join(filepath.Join(filepath.Join(pathPrefix, oci.Reg), oci.Repo), oci.Tag)
}
Expand Down

0 comments on commit 80caaec

Please sign in to comment.