From 80caaec14121afc6133ba707f054694aaf18aa70 Mon Sep 17 00:00:00 2001 From: zongz <68977949+zong-zhe@users.noreply.github.com> Date: Mon, 18 Mar 2024 14:19:15 +0800 Subject: [PATCH] fix: fix windows path bug (#280) Signed-off-by: zongz --- pkg/api/kpm_run.go | 2 +- pkg/client/client.go | 4 ++-- pkg/opt/opt.go | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/api/kpm_run.go b/pkg/api/kpm_run.go index 3450f2cc..80612cb5 100644 --- a/pkg/api/kpm_run.go +++ b/pkg/api/kpm_run.go @@ -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()) diff --git a/pkg/client/client.go b/pkg/client/client.go index 0a185a08..084cff01 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -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) @@ -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 diff --git a/pkg/opt/opt.go b/pkg/opt/opt.go index b8ca9d1c..a4b928cd 100644 --- a/pkg/opt/opt.go +++ b/pkg/opt/opt.go @@ -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) }