Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix panic error when 'kpm run <oci_url>' #210

Merged
merged 2 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/sirupsen/logrus v1.9.0
github.com/urfave/cli/v2 v2.25.0
gotest.tools/v3 v3.4.0
kcl-lang.io/kcl-go v0.6.0
kcl-lang.io/kcl-go v0.6.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -765,8 +765,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
kcl-lang.io/kcl-artifact-go v0.6.0 h1:J/1FKzgGRqzFDkq0amBWxCdXXRMrtg5oT3IGtoo9sgU=
kcl-lang.io/kcl-artifact-go v0.6.0/go.mod h1:c07mqi9Hu2UjPW7lYfHhAAWOlZiB7lo7Vkr4jL5ov/M=
kcl-lang.io/kcl-go v0.6.0 h1:gmbTZ5VfLxL2I2lGnVG2Tpin750YMHTFQeINfj7jKBk=
kcl-lang.io/kcl-go v0.6.0/go.mod h1:1/xEscOhVGNabr9+rYC5peFDIjphbthYqk8UyHzaPRk=
kcl-lang.io/kcl-go v0.6.1 h1:we/e3qvllsOoQj0YQht+yNxI+QFLWEmYn4FQ3zAvv9E=
kcl-lang.io/kcl-go v0.6.1/go.mod h1:1/xEscOhVGNabr9+rYC5peFDIjphbthYqk8UyHzaPRk=
oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY=
oras.land/oras-go v1.2.3/go.mod h1:M/uaPdYklze0Vf3AakfarnpoEckvw0ESbRdN8Z1vdJg=
oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU=
Expand Down
7 changes: 4 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,9 @@ func (c *KpmClient) CompileOciPkg(ociSource, version string, opts *opt.CompileOp
localPath := ociOpts.AddStoragePathSuffix(tmpDir)

// 2. Pull the tar.
err = oci.Pull(localPath, ociOpts.Reg, ociOpts.Repo, ociOpts.Tag, c.GetSettings())
err = c.pullTarFromOci(localPath, ociOpts)

if err != (*reporter.KpmEvent)(nil) {
if err != nil {
return nil, err
}

Expand Down Expand Up @@ -1012,10 +1012,11 @@ func (c *KpmClient) pullTarFromOci(localPath string, ociOpts *opt.OciOptions) er
tagSelected = ociOpts.Tag
}

full_repo := utils.JoinPath(ociOpts.Reg, ociOpts.Repo)
reporter.ReportEventTo(
reporter.NewEvent(
reporter.Pulling,
fmt.Sprintf("pulling '%s'.", ociCli.GetReference()),
fmt.Sprintf("pulling '%s:%s' from '%s'.", ociOpts.Repo, tagSelected, full_repo),
),
c.logWriter,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kpm: start to pull 'oci://localhost:5001/test/k8s'.
kpm: the lastest version '1.27' will be pulled.
kpm: pulling 'localhost:5001/test/k8s'.
kpm: pulling '/test/k8s:1.27' from 'localhost:5001/test/k8s'.
kpm: pulled 'oci://localhost:5001/test/k8s' in '<workspace>/localhost:5001/test/k8s' successfully.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kpm: start to pull 'oci://localhost:5001/test/k8s' with tag '1.14'.
kpm: pulling 'localhost:5001/test/k8s'.
kpm: pulling '/test/k8s:1.14' from 'localhost:5001/test/k8s'.
kpm: pulled 'oci://localhost:5001/test/k8s' in '<workspace>/localhost:5001/test/k8s/1.14' successfully.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
kpm: start to pull 'k8s'.
kpm: the lastest version '1.27' will be pulled.
kpm: pulling 'localhost:5001/test/k8s'.
kpm: pulling 'test/k8s:1.27' from 'localhost:5001/test/k8s'.
kpm: pulled 'k8s' in '<workspace>/localhost:5001/test/k8s' successfully.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
kpm: start to pull 'k8s:1.27'.
kpm: pulling 'localhost:5001/test/k8s'.
kpm: pulling 'test/k8s:1.27' from 'localhost:5001/test/k8s'.
kpm: pulled 'k8s:1.27' in '<workspace>/localhost:5001/test/k8s/1.27' successfully.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KPM_HOME=""
KCLVM_VENDOR_HOME=""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kpm run oci://localhost:5001/test/kcl1
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kpm: the lastest version '0.0.1' will be pulled.
kpm: pulling '/test/kcl1:0.0.1' from 'localhost:5001/test/kcl1'.
kpm: downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27'.
The_first_kcl_program: Hello World!
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
KPM_HOME=""
KCLVM_VENDOR_HOME=""
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kpm run oci://localhost:5001/test/kcl1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The_first_kcl_program: Hello World!
Loading