From ef6dec048bb7944cacb459539b5f31a048aea4c3 Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 28 Mar 2024 15:06:19 +0800 Subject: [PATCH 1/4] fix: turned off update indirect dependencies in kcl.mod Signed-off-by: zongz --- .../get_schema_ty/aaa/kcl.mod.lock | 1 - pkg/client/client.go | 84 +++++++++++++------ pkg/client/client_test.go | 2 + .../expect/pkg/kcl.mod.lock | 1 - .../add_with_local_path/init/pkg/kcl.mod.lock | 1 - .../test_cyclic_dependency/aaa/kcl.mod.lock | 1 - .../test_cyclic_dependency/bbb/kcl.mod.lock | 1 - pkg/cmd/cmd_add.go | 2 +- pkg/package/modfile.go | 4 +- pkg/package/package.go | 19 ++++- .../test_suite.stdout | 1 - .../test_suite.stdout | 1 - .../a_kcl_pkg_dep_one_pkg_4/kcl.mod.lock | 1 - .../a_kcl_pkg_dep_one_pkg_5/kcl.mod.lock | 1 - .../test_data/test_kpm_metadata/kcl.mod.lock | 1 - .../kcl.mod.lock | 2 - .../kcl.mod.lock | 2 - .../pkg1/kcl.mod.lock | 2 - .../pkg2/kcl.mod.lock | 1 - .../pkg/pkg2/kcl.mod.lock | 1 - .../pkg1/kcl.mod.lock | 1 - .../test_with_line/kcl.mod.lock | 1 - .../kcl1/kcl.mod.lock | 1 - .../test_update/kcl.mod.lock | 1 - 24 files changed, 80 insertions(+), 53 deletions(-) diff --git a/pkg/api/test_data/test_kpm_package/get_schema_ty/aaa/kcl.mod.lock b/pkg/api/test_data/test_kpm_package/get_schema_ty/aaa/kcl.mod.lock index ba2265e8..7ff35292 100644 --- a/pkg/api/test_data/test_kpm_package/get_schema_ty/aaa/kcl.mod.lock +++ b/pkg/api/test_data/test_kpm_package/get_schema_ty/aaa/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "bbb_0.0.1" version = "0.0.1" sum = "/PGJJE6Rp0lAsq3n9RUZ34jPGfwzYIZESs17L6kSG/Y=" - path = "../bbb" diff --git a/pkg/client/client.go b/pkg/client/client.go index a8e86076..bfdfadad 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -113,6 +113,28 @@ func (c *KpmClient) LoadPkgFromPath(pkgPath string) (*pkg.KclPkg, error) { return nil, reporter.NewErrorEvent(reporter.FailedLoadKclMod, err, fmt.Sprintf("could not load 'kcl.mod.lock' in '%s'", pkgPath)) } + // Align the dependencies between kcl.mod and kcl.mod.lock. + for name, dep := range modFile.Dependencies.Deps { + if dep.Local != nil { + if ldep, ok := deps.Deps[name]; ok { + var localFullPath string + if filepath.IsAbs(dep.Local.Path) { + localFullPath = dep.Local.Path + } else { + localFullPath, err = filepath.Abs(filepath.Join(pkgPath, dep.Local.Path)) + if err != nil { + return nil, reporter.NewErrorEvent(reporter.Bug, err, "internal bugs, please contact us to fix it.") + } + } + ldep.LocalFullPath = localFullPath + dep.LocalFullPath = localFullPath + ldep.Source = dep.Source + deps.Deps[name] = ldep + modFile.Dependencies.Deps[name] = dep + } + } + } + return &pkg.KclPkg{ ModFile: *modFile, HomePath: pkgPath, @@ -194,20 +216,24 @@ func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) erro for name, dep := range kclPkg.Dependencies.Deps { modDep, ok := kclPkg.ModFile.Dependencies.Deps[name] if !ok || !dep.WithTheSameVersion(modDep) { - reporter.ReportMsgTo( - fmt.Sprintf("removing '%s' with version '%s'", name, dep.Version), - c.logWriter, - ) delete(kclPkg.Dependencies.Deps, name) } } // add the dependencies in kcl.mod which not in kcl.mod.lock for name, d := range kclPkg.ModFile.Dependencies.Deps { if _, ok := kclPkg.Dependencies.Deps[name]; !ok { - reporter.ReportMsgTo( - fmt.Sprintf("adding '%s' with version '%s'", name, d.Version), - c.logWriter, - ) + if len(d.Version) == 0 { + reporter.ReportMsgTo( + fmt.Sprintf("adding '%s'", name), + c.logWriter, + ) + } else { + reporter.ReportMsgTo( + fmt.Sprintf("adding '%s' with version '%s'", name, d.Version), + c.logWriter, + ) + } + kclPkg.Dependencies.Deps[name] = d } } @@ -277,10 +303,12 @@ func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) erro } } if update { - // update the kcl.mod and kcl.mod.lock. - err := kclPkg.UpdateModAndLockFile() - if err != nil { - return err + // Generate file kcl.mod.lock. + if !kclPkg.NoSumCheck { + err := kclPkg.LockDepsVersion() + if err != nil { + return err + } } } return nil @@ -293,9 +321,12 @@ func (c *KpmClient) UpdateDeps(kclPkg *pkg.KclPkg) error { return err } - err = kclPkg.UpdateModAndLockFile() - if err != nil { - return err + // Generate file kcl.mod.lock. + if !kclPkg.NoSumCheck { + err := kclPkg.LockDepsVersion() + if err != nil { + return err + } } return nil } @@ -351,7 +382,7 @@ func (c *KpmClient) CompileWithOpts(opts *opt.CompileOptions) (*kcl.KCLResultLis c.noSumCheck = opts.NoSumCheck() - kclPkg, err := pkg.LoadKclPkg(pkgPath) + kclPkg, err := c.LoadPkgFromPath(pkgPath) if err != nil { return nil, err } @@ -818,11 +849,6 @@ func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (* return nil, err } dep.FromKclPkg(kpkg) - abspath, err := filepath.Abs(dep.GetLocalFullPath(homePath)) - if err != nil { - return nil, err - } - dep.Source.Local.Path = abspath } var err error @@ -1007,7 +1033,7 @@ func (c *KpmClient) DownloadFromOci(dep *pkg.Oci, localPath string) (string, err return "", reporter.NewErrorEvent( reporter.InvalidKclPkg, err, - fmt.Sprintf("failed to find the kcl package tar from '%s'.", localPath), + fmt.Sprintf("failed to find the kcl package from '%s'.", localPath), ) } } @@ -1022,7 +1048,7 @@ func (c *KpmClient) DownloadFromOci(dep *pkg.Oci, localPath string) (string, err return "", reporter.NewErrorEvent( reporter.FailedUntarKclPkg, err, - fmt.Sprintf("failed to untar the kcl package tar from '%s' into '%s'.", tarPath, localPath), + fmt.Sprintf("failed to untar the kcl package from '%s' into '%s'.", tarPath, localPath), ) } @@ -1311,18 +1337,22 @@ func (c *KpmClient) downloadDeps(deps pkg.Dependencies, lockDeps pkg.Dependencie // Recursively download the dependencies of the new dependencies. for _, d := range newDepsCopy { - // Load kcl.mod file of the new downloaded dependencies. - deppkg, err := pkg.LoadKclPkg(filepath.Join(c.homePath, d.FullName)) + var err error + var deppkg *pkg.KclPkg if len(d.LocalFullPath) != 0 { - deppkg, err = pkg.LoadKclPkg(d.LocalFullPath) - } + deppkg, err = c.LoadPkgFromPath(d.LocalFullPath) + } else { + // Load kcl.mod file of the new downloaded dependencies. + deppkg, err = c.LoadPkgFromPath(filepath.Join(c.homePath, d.FullName)) + } if err != nil { if os.IsNotExist(err) { continue } return nil, err } + source := fmt.Sprintf("%s@%s", d.Name, d.Version) source = strings.TrimRight(source, "@") err = depGraph.AddVertex(source) diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index 6173b3aa..3ac58773 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -1364,4 +1364,6 @@ func TestAddWithLocalPath(t *testing.T) { assert.Equal(t, len(gotpkg.Dependencies.Deps), len(expectpkg.Dependencies.Deps)) assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].FullName, expectpkg.Dependencies.Deps["dep_pkg"].FullName) assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].Version, expectpkg.Dependencies.Deps["dep_pkg"].Version) + assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].LocalFullPath, filepath.Join(tmppath, "dep_pkg")) + assert.Equal(t, gotpkg.Dependencies.Deps["dep_pkg"].Source.Local.Path, "../dep_pkg") } diff --git a/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod.lock b/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod.lock index 7a5d3c5b..e7aa3a93 100644 --- a/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod.lock +++ b/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod.lock @@ -4,7 +4,6 @@ full_name = "dep_pkg_0.0.1" version = "0.0.1" sum = "C3TjaZJVdt4G8TtbiCxTUO/zAlf7fWJTAvs/CDMnlxY=" - path = "../dep_pkg" [dependencies.helloworld] name = "helloworld" full_name = "helloworld_0.1.1" diff --git a/pkg/client/test_data/add_with_local_path/init/pkg/kcl.mod.lock b/pkg/client/test_data/add_with_local_path/init/pkg/kcl.mod.lock index 0742661b..aae3a352 100644 --- a/pkg/client/test_data/add_with_local_path/init/pkg/kcl.mod.lock +++ b/pkg/client/test_data/add_with_local_path/init/pkg/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "dep_pkg_0.0.1" version = "0.0.1" sum = "C3TjaZJVdt4G8TtbiCxTUO/zAlf7fWJTAvs/CDMnlxY=" - path = "../dep_pkg" diff --git a/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock index 4eb93c26..8d7d71e4 100644 --- a/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock +++ b/pkg/client/test_data/test_cyclic_dependency/aaa/kcl.mod.lock @@ -3,4 +3,3 @@ name = "bbb" full_name = "bbb_" sum = "Cgx5yepaNrS3/p4fK04RQWf1dEpG3j49ntFqzrJJsxU=" - path = "../bbb" diff --git a/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock index e3672021..01e768d3 100644 --- a/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock +++ b/pkg/client/test_data/test_cyclic_dependency/bbb/kcl.mod.lock @@ -4,5 +4,4 @@ full_name = "aaa_0.0.1" version = "0.0.1" sum = "hgAM5wYFzXo83S+OiT0LaBDnHU7Q9vqq3BPXlTDr8TY=" - path = "../aaa" diff --git a/pkg/cmd/cmd_add.go b/pkg/cmd/cmd_add.go index d9e2c605..ec311e7d 100644 --- a/pkg/cmd/cmd_add.go +++ b/pkg/cmd/cmd_add.go @@ -1,5 +1,5 @@ // Copyright 2023 The KCL Authors. All rights reserved. -// Deprecated: The entire contents of this file will be deprecated. +// Deprecated: The entire contents of this file will be deprecated. // Please use the kcl cli - https://github.com/kcl-lang/cli. package cmd diff --git a/pkg/package/modfile.go b/pkg/package/modfile.go index 57391a9a..c92a4275 100644 --- a/pkg/package/modfile.go +++ b/pkg/package/modfile.go @@ -202,7 +202,7 @@ func (d Dependency) WithTheSameVersion(other Dependency) bool { // GetLocalFullPath will get the local path of a dependency. func (dep *Dependency) GetLocalFullPath(rootpath string) string { - if dep.IsFromLocal() { + if len(dep.LocalFullPath) == 0 && dep.IsFromLocal() { if filepath.IsAbs(dep.Source.Local.Path) { return dep.Source.Local.Path } @@ -248,7 +248,7 @@ func (dep *Dependency) GenDepFullName() string { type Source struct { *Git *Oci - *Local + *Local `toml:"-"` } type Local struct { diff --git a/pkg/package/package.go b/pkg/package/package.go index 01058e25..91dd547d 100644 --- a/pkg/package/package.go +++ b/pkg/package/package.go @@ -49,6 +49,23 @@ func LoadKclPkg(pkgPath string) (*KclPkg, error) { return nil, reporter.NewErrorEvent(reporter.FailedLoadKclMod, err, fmt.Sprintf("could not load 'kcl.mod.lock' in '%s'", pkgPath)) } + // Align the dependencies between kcl.mod and kcl.mod.lock. + for name, dep := range modFile.Dependencies.Deps { + if dep.Local != nil { + if ldep, ok := deps.Deps[name]; ok { + abs, err := filepath.Abs(filepath.Join(pkgPath, dep.Local.Path)) + if err != nil { + return nil, reporter.NewErrorEvent(reporter.Bug, err, "internal bugs, please contact us to fix it.") + } + ldep.LocalFullPath = abs + dep.LocalFullPath = abs + ldep.Source = dep.Source + deps.Deps[name] = ldep + modFile.Dependencies.Deps[name] = dep + } + } + } + return &KclPkg{ ModFile: *modFile, HomePath: pkgPath, @@ -165,7 +182,7 @@ func (kclPkg *KclPkg) UpdateModAndLockFile() error { // Generate file kcl.mod.lock. if !kclPkg.NoSumCheck { - err = kclPkg.LockDepsVersion() + err := kclPkg.LockDepsVersion() if err != nil { return err } diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout index 69214529..3877890d 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout @@ -1,5 +1,4 @@ adding 'k8s' with version '1.27' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' apiVersion: v1 kind: Pod metadata: diff --git a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stdout index 101b394a..0c666431 100644 --- a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stdout @@ -1,2 +1 @@ -removing 'k8s' with version '1.27' adding 'k8s' with version '1.14' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_4/kcl.mod.lock b/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_4/kcl.mod.lock index 7321db8b..dbcb2e53 100644 --- a/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_4/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_4/kcl.mod.lock @@ -4,7 +4,6 @@ full_name = "a_kcl_pkg_dep_pkg_name_0.0.1" version = "0.0.1" sum = "CzqJerovhD4TlBCWUTU9ceUlJhNPkhar+HURpeu48NE=" - path = "../a_kcl_pkg_dep_one_pkg_3" [dependencies.k8s] name = "k8s" full_name = "k8s_1.27" diff --git a/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_5/kcl.mod.lock b/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_5/kcl.mod.lock index b3a3d338..d3e7a2a3 100644 --- a/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_5/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/a_kcl_pkg_dep_one_pkg_5/kcl.mod.lock @@ -4,7 +4,6 @@ full_name = "a_kcl_pkg_dep_pkg_name_0.0.1" version = "0.0.1" sum = "AfdOtDGXfOoJvpmJ4uQ/YllHoP2wAzbtQQeXo4s4C/U=" - path = "../a_kcl_pkg_dep_one_pkg_4" [dependencies.k8s] name = "k8s" full_name = "k8s_1.27" diff --git a/test/e2e/test_suites/test_data/test_kpm_metadata/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_metadata/kcl.mod.lock index 7488288e..eeda7f7a 100644 --- a/test/e2e/test_suites/test_data/test_kpm_metadata/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_metadata/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "dep-with-line_0.0.1" version = "0.0.1" sum = "0lzH5VUC9/wM60EnksK/9Oc3/alBezWkElgGM1l0938=" - path = "./dep-with-line" diff --git a/test/e2e/test_suites/test_data/test_kpm_metadata_duplication/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_metadata_duplication/kcl.mod.lock index 68c6dd4a..f3cb9dcb 100644 --- a/test/e2e/test_suites/test_data/test_kpm_metadata_duplication/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_metadata_duplication/kcl.mod.lock @@ -3,9 +3,7 @@ name = "dep-with-line" full_name = "dep-with-line_" sum = "0lzH5VUC9/wM60EnksK/9Oc3/alBezWkElgGM1l0938=" - path = "./dep-with-line" [dependencies.dep_with-line] name = "dep_with-line" full_name = "dep_with-line_" sum = "hiIX1252Xn0QvmGlLhuM5ZsuuV8EpY/fuCgcRKLk3iE=" - path = "./dep_with-line" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_duplication_deps/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_duplication_deps/kcl.mod.lock index 68c6dd4a..f3cb9dcb 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_duplication_deps/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_duplication_deps/kcl.mod.lock @@ -3,9 +3,7 @@ name = "dep-with-line" full_name = "dep-with-line_" sum = "0lzH5VUC9/wM60EnksK/9Oc3/alBezWkElgGM1l0938=" - path = "./dep-with-line" [dependencies.dep_with-line] name = "dep_with-line" full_name = "dep_with-line_" sum = "hiIX1252Xn0QvmGlLhuM5ZsuuV8EpY/fuCgcRKLk3iE=" - path = "./dep_with-line" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod.lock index e59ebe56..9e0d7744 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg1/kcl.mod.lock @@ -4,10 +4,8 @@ full_name = "pkg2_0.0.1" version = "0.0.1" sum = "JbfIAXPJb3L6xX7hi/A5mrXzjpB8eFoKfEmJMdHsewY=" - path = "../pkg2" [dependencies.pkg3] name = "pkg3" full_name = "pkg3_0.0.1" version = "0.0.1" sum = "T29gAv6K/tLithhP5jVHyurV5zRFui+i1ulyMt/ncnM=" - path = "../pkg3" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg2/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg2/kcl.mod.lock index 75909bea..35162faf 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg2/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path/pkg2/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "pkg3_0.0.1" version = "0.0.1" sum = "T29gAv6K/tLithhP5jVHyurV5zRFui+i1ulyMt/ncnM=" - path = "../pkg3" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg/pkg2/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg/pkg2/kcl.mod.lock index 75909bea..35162faf 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg/pkg2/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg/pkg2/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "pkg3_0.0.1" version = "0.0.1" sum = "T29gAv6K/tLithhP5jVHyurV5zRFui+i1ulyMt/ncnM=" - path = "../pkg3" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg1/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg1/kcl.mod.lock index c49fa9ad..b047f2b6 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg1/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_multi_local_path_0/pkg1/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "pkg2_0.0.1" version = "0.0.1" sum = "JbfIAXPJb3L6xX7hi/A5mrXzjpB8eFoKfEmJMdHsewY=" - path = "../pkg/pkg2" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_underline/test_with_line/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_underline/test_with_line/kcl.mod.lock index 0ff143a7..86df8b73 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_underline/test_with_line/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_underline/test_with_line/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "dep-with-line-0.0.1" version = "0.0.1" sum = "0lzH5VUC9/wM60EnksK/9Oc3/alBezWkElgGM1l0938=" - path = "../dep-with-line" diff --git a/test/e2e/test_suites/test_data/test_kpm_run_with_local_dep/kcl1/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kpm_run_with_local_dep/kcl1/kcl.mod.lock index f8b422f3..d0446c0f 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_with_local_dep/kcl1/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kpm_run_with_local_dep/kcl1/kcl.mod.lock @@ -4,4 +4,3 @@ full_name = "kcl2_0.0.1" version = "0.0.1" sum = "Q+ilCTK5EXPn7stwrtY2La1MQdP+wiAq5wHiG91NoB8=" - path = "../kcl2" diff --git a/test/e2e/test_suites/test_data/test_update_with_all/test_update/kcl.mod.lock b/test/e2e/test_suites/test_data/test_update_with_all/test_update/kcl.mod.lock index a2abeec3..08c061f8 100644 --- a/test/e2e/test_suites/test_data/test_update_with_all/test_update/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_update_with_all/test_update/kcl.mod.lock @@ -18,4 +18,3 @@ name = "test_update_1" full_name = "test_update_1_" sum = "PYLgSMWbY5vCU2cyK+hOkZeb0Rp7JW055b0RMQaQ4S8=" - path = "./../test_update_1" From 1fe277ee0b1f736f2b379daab2a4830c33b36c9b Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 28 Mar 2024 17:23:06 +0800 Subject: [PATCH 2/4] fix: fix --no_sum_check Signed-off-by: zongz --- pkg/cmd/cmd_run.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/cmd_run.go b/pkg/cmd/cmd_run.go index 2ad84567..4564e5d5 100644 --- a/pkg/cmd/cmd_run.go +++ b/pkg/cmd/cmd_run.go @@ -1,5 +1,5 @@ // Copyright 2023 The KCL Authors. All rights reserved. -// Deprecated: The entire contents of this file will be deprecated. +// Deprecated: The entire contents of this file will be deprecated. // Please use the kcl cli - https://github.com/kcl-lang/cli. package cmd @@ -95,8 +95,6 @@ func KpmRun(c *cli.Context, kpmcli *client.KpmClient) error { return err } - kpmcli.SetNoSumCheck(c.Bool(FLAG_NO_SUM_CHECK)) - defer func() { // release the lock of the package cache after the function returns. releaseErr := kpmcli.ReleasePackageCacheLock() @@ -106,6 +104,7 @@ func KpmRun(c *cli.Context, kpmcli *client.KpmClient) error { }() kclOpts := CompileOptionFromCli(c) + kclOpts.SetNoSumCheck(c.Bool(FLAG_NO_SUM_CHECK)) runEntry, errEvent := runner.FindRunEntryFrom(c.Args().Slice()) if errEvent != nil { return errEvent From f46ad5c8514a268da03f25391120fe873845ad50 Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 28 Mar 2024 17:32:01 +0800 Subject: [PATCH 3/4] fix: fix e2e test case Signed-off-by: zongz --- .../kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout | 5 +++-- .../test_data/test_kpm_run_with_only_kcl_mod/kcl.mod | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout index 3877890d..7cacad9b 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout @@ -1,4 +1,5 @@ -adding 'k8s' with version '1.27' +adding 'helloworld' with version '0.1.1' +downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' apiVersion: v1 kind: Pod metadata: @@ -8,4 +9,4 @@ spec: - image: nginx name: main-container ports: - - containerPort: 80 + - containerPort: 80 \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/kcl.mod b/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/kcl.mod index 9c529adf..73317ff3 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/kcl.mod +++ b/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/kcl.mod @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -k8s = "1.27" +helloworld = "0.1.1" From eda94094d8f6d2577f4b3076d6a3bca82f16d4db Mon Sep 17 00:00:00 2001 From: zongz Date: Thu, 28 Mar 2024 17:36:37 +0800 Subject: [PATCH 4/4] fix: fix e2e test Signed-off-by: zongz --- .../test_kpm_run_with_only_kcl_mod/test_suite.stdout | 11 +---------- .../test_data/test_kpm_run_with_only_kcl_mod/main.k | 11 ++--------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout index 7cacad9b..04a8d42f 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_with_only_kcl_mod/test_suite.stdout @@ -1,12 +1,3 @@ adding 'helloworld' with version '0.1.1' downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' -apiVersion: v1 -kind: Pod -metadata: - name: web-app -spec: - containers: - - image: nginx - name: main-container - ports: - - containerPort: 80 \ No newline at end of file +a: Hello World! \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/main.k b/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/main.k index 7f748048..0251cdf5 100644 --- a/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/main.k +++ b/test/e2e/test_suites/test_data/test_kpm_run_with_only_kcl_mod/main.k @@ -1,10 +1,3 @@ -import k8s.api.core.v1 as k8core +import helloworld -k8core.Pod { - metadata.name = "web-app" - spec.containers = [{ - name = "main-container" - image = "nginx" - ports = [{containerPort = 80}] - }] -} \ No newline at end of file +a = helloworld.The_first_kcl_program \ No newline at end of file