Skip to content

Commit 80caaec

Browse files
authored
fix: fix windows path bug (#280)
Signed-off-by: zongz <zongzhe1024@163.com>
1 parent f70f6ff commit 80caaec

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

pkg/api/kpm_run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func RunOciPkg(ociRef, version string, opts *opt.CompileOptions) (*kcl.KCLResult
194194
// clean the temp dir.
195195
defer os.RemoveAll(tmpDir)
196196

197-
localPath := ociOpts.AddStoragePathSuffix(tmpDir)
197+
localPath := ociOpts.SanitizePathWithSuffix(tmpDir)
198198

199199
// 2. Pull the tar.
200200
err = oci.Pull(localPath, ociOpts.Reg, ociOpts.Repo, ociOpts.Tag, kpmcli.GetSettings())

pkg/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ func (c *KpmClient) CompileOciPkg(ociSource, version string, opts *opt.CompileOp
487487
// clean the temp dir.
488488
defer os.RemoveAll(tmpDir)
489489

490-
localPath := ociOpts.AddStoragePathSuffix(tmpDir)
490+
localPath := ociOpts.SanitizePathWithSuffix(tmpDir)
491491

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

1018-
storepath := ociOpts.AddStoragePathSuffix(tmpDir)
1018+
storepath := ociOpts.SanitizePathWithSuffix(tmpDir)
10191019
err = c.pullTarFromOci(storepath, ociOpts)
10201020
if err != nil {
10211021
return err

pkg/opt/opt.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ func ParseOciUrl(ociUrl string) (*OciOptions, *reporter.KpmEvent) {
275275
// }
276276
//
277277
// You will get a path '/usr/test/docker.io/test/testRepo/v0.0.1'.
278+
// Deprecated: This function will be deprecated, use 'SanitizePathWithSuffix' instead.
278279
func (oci *OciOptions) AddStoragePathSuffix(pathPrefix string) string {
279280
return filepath.Join(filepath.Join(filepath.Join(pathPrefix, oci.Reg), oci.Repo), oci.Tag)
280281
}

0 commit comments

Comments
 (0)