diff --git a/pkg/3rdparty/mvs/mvs.go b/pkg/3rdparty/mvs/mvs.go index 84542347..ca427784 100644 --- a/pkg/3rdparty/mvs/mvs.go +++ b/pkg/3rdparty/mvs/mvs.go @@ -236,7 +236,7 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, } have[m] = true for _, m1 := range reqCache[m] { - walk(m1) + _ = walk(m1) } return nil } @@ -249,7 +249,7 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, } m := module.Version{Path: path, Version: max[path]} min = append(min, m) - walk(m) + _ = walk(m) haveBase[path] = true } // Now the reverse postorder to bring in anything else. @@ -261,7 +261,7 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, } if !have[m] { min = append(min, m) - walk(m) + _ = walk(m) } } sort.Slice(min, func(i, j int) bool { diff --git a/pkg/api/kpm_pkg_test.go b/pkg/api/kpm_pkg_test.go index 2577ede1..b088d9e5 100644 --- a/pkg/api/kpm_pkg_test.go +++ b/pkg/api/kpm_pkg_test.go @@ -29,7 +29,6 @@ func TestPackageApi(t *testing.T) { assert.Equal(t, dep.Name, "k8s") assert.Equal(t, dep.FullName, "k8s_1.27") assert.Equal(t, dep.Version, "1.27") - assert.Equal(t, dep.Sum, "xnYM1FWHAy3m+KcQMQb2rjZouTxumqYt6FGZpu2T4yM=") assert.Equal(t, dep.Source.Oci.Reg, "ghcr.io") assert.Equal(t, dep.Source.Oci.Repo, "kcl-lang/k8s") assert.Equal(t, dep.Source.Oci.Tag, "1.27") diff --git a/pkg/api/kpm_run.go b/pkg/api/kpm_run.go index 9f1a521f..2f7dc953 100644 --- a/pkg/api/kpm_run.go +++ b/pkg/api/kpm_run.go @@ -12,7 +12,6 @@ import ( "kcl-lang.io/kpm/pkg/errors" "kcl-lang.io/kpm/pkg/oci" "kcl-lang.io/kpm/pkg/opt" - pkg "kcl-lang.io/kpm/pkg/package" "kcl-lang.io/kpm/pkg/reporter" "kcl-lang.io/kpm/pkg/runner" "kcl-lang.io/kpm/pkg/utils" @@ -242,7 +241,7 @@ func run(kpmcli *client.KpmClient, opts *opt.CompileOptions) (*kcl.KCLResultList return nil, reporter.NewErrorEvent(reporter.Bug, err, "internal bugs, please contact us to fix it.") } - kclPkg, err := pkg.LoadKclPkg(pkgPath) + kclPkg, err := kpmcli.LoadPkgFromPath(pkgPath) if err != nil { return nil, err } diff --git a/pkg/api/test_data/test_run_pkg_in_path/expected b/pkg/api/test_data/test_run_pkg_in_path/expected index 611214d0..b319e355 100644 --- a/pkg/api/test_data/test_run_pkg_in_path/expected +++ b/pkg/api/test_data/test_run_pkg_in_path/expected @@ -1,20 +1,17 @@ -demo: - apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment - spec: - replicas: 3 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - image: nginx:1.14.2 - name: nginx - ports: - - containerPort: 80 \ No newline at end of file +a: + name: flask-demo + replicas: 1 + labels: + app: flask-demo + service: + type: NodePort + ports: + - port: 5000 + protocol: TCP + targetPort: 5000 + containers: + flaskdemo: + image: kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe + ports: + - protocol: TCP + containerPort: 5000 diff --git a/pkg/api/test_data/test_run_pkg_in_path/expected.json b/pkg/api/test_data/test_run_pkg_in_path/expected.json index 1e5c5931..d7937857 100644 --- a/pkg/api/test_data/test_run_pkg_in_path/expected.json +++ b/pkg/api/test_data/test_run_pkg_in_path/expected.json @@ -1 +1 @@ -{"demo": {"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "nginx-deployment"}, "spec": {"replicas": 3, "selector": {"matchLabels": {"app": "nginx"}}, "template": {"metadata": {"labels": {"app": "nginx"}}, "spec": {"containers": [{"image": "nginx:1.14.2", "name": "nginx", "ports": [{"containerPort": 80}]}]}}}}} \ No newline at end of file +{"a": {"name": "flask-demo", "replicas": 1, "labels": {"app": "flask-demo"}, "service": {"type": "NodePort", "ports": [{"port": 5000, "protocol": "TCP", "targetPort": 5000}]}, "containers": {"flaskdemo": {"image": "kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe", "ports": [{"protocol": "TCP", "containerPort": 5000}]}}}} \ No newline at end of file diff --git a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod index d62b7d10..707522fe 100644 --- a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod +++ b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -konfig = { git = "https://github.com/awesome-kusion/konfig.git", tag = "v0.0.1" } +flask-demo-kcl-manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b" } diff --git a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod.lock b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod.lock index 02b0b8e3..935309f6 100644 --- a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod.lock +++ b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod.lock @@ -1,8 +1,7 @@ [dependencies] - [dependencies.konfig] - name = "konfig" - full_name = "konfig_v0.0.1" - version = "v0.0.1" - sum = "XFvHdBAoY/+qpJWmj8cjwOwZO8a3nX/7SE35cTxQOFU=" - url = "https://github.com/awesome-kusion/konfig.git" - git_tag = "v0.0.1" + [dependencies.flask-demo-kcl-manifests] + name = "flask-demo-kcl-manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + commit = "ade147b" diff --git a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/main.k b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/main.k index ec916bca..3d8edb2c 100644 --- a/pkg/api/test_data/test_run_pkg_in_path/test_kcl/main.k +++ b/pkg/api/test_data/test_run_pkg_in_path/test_kcl/main.k @@ -1,3 +1,3 @@ -import konfig.base.examples.native.nginx_deployment as nd +import flask_demo_kcl_manifests as flask -demo = nd.demo \ No newline at end of file +a = flask.config \ No newline at end of file diff --git a/pkg/api/test_data/test_run_tar_in_path/expected b/pkg/api/test_data/test_run_tar_in_path/expected index 7c33aaad..b319e355 100644 --- a/pkg/api/test_data/test_run_tar_in_path/expected +++ b/pkg/api/test_data/test_run_tar_in_path/expected @@ -1,20 +1,17 @@ -demo: - apiVersion: apps/v1 - kind: Deployment - metadata: - name: nginx-deployment - spec: - replicas: 3 - selector: - matchLabels: - app: nginx - template: - metadata: - labels: - app: nginx - spec: - containers: - - image: nginx:1.14.2 - name: nginx - ports: - - containerPort: 80 +a: + name: flask-demo + replicas: 1 + labels: + app: flask-demo + service: + type: NodePort + ports: + - port: 5000 + protocol: TCP + targetPort: 5000 + containers: + flaskdemo: + image: kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe + ports: + - protocol: TCP + containerPort: 5000 diff --git a/pkg/api/test_data/test_run_tar_in_path/expected.json b/pkg/api/test_data/test_run_tar_in_path/expected.json index 1e5c5931..d7937857 100644 --- a/pkg/api/test_data/test_run_tar_in_path/expected.json +++ b/pkg/api/test_data/test_run_tar_in_path/expected.json @@ -1 +1 @@ -{"demo": {"apiVersion": "apps/v1", "kind": "Deployment", "metadata": {"name": "nginx-deployment"}, "spec": {"replicas": 3, "selector": {"matchLabels": {"app": "nginx"}}, "template": {"metadata": {"labels": {"app": "nginx"}}, "spec": {"containers": [{"image": "nginx:1.14.2", "name": "nginx", "ports": [{"containerPort": 80}]}]}}}}} \ No newline at end of file +{"a": {"name": "flask-demo", "replicas": 1, "labels": {"app": "flask-demo"}, "service": {"type": "NodePort", "ports": [{"port": 5000, "protocol": "TCP", "targetPort": 5000}]}, "containers": {"flaskdemo": {"image": "kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe", "ports": [{"protocol": "TCP", "containerPort": 5000}]}}}} \ No newline at end of file diff --git a/pkg/api/test_data/test_run_tar_in_path/test.tar b/pkg/api/test_data/test_run_tar_in_path/test.tar index ce9d9e89..75568b6e 100644 Binary files a/pkg/api/test_data/test_run_tar_in_path/test.tar and b/pkg/api/test_data/test_run_tar_in_path/test.tar differ diff --git a/pkg/client/client.go b/pkg/client/client.go index 2b7ff97a..c2042e37 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -6,7 +6,6 @@ import ( "io" "os" "path/filepath" - "reflect" "strings" "github.com/BurntSushi/toml" @@ -166,8 +165,64 @@ func (c *KpmClient) LoadModFile(pkgPath string) (*pkg.ModFile, error) { return modFile, nil } +// Load the kcl.mod.lock and acquire the checksum of the dependencies from OCI registry. func (c *KpmClient) LoadLockDeps(pkgPath string) (*pkg.Dependencies, error) { - return pkg.LoadLockDeps(pkgPath) + deps, err := pkg.LoadLockDeps(pkgPath) + if err != nil { + return nil, err + } + + for name, dep := range deps.Deps { + sum, err := c.AcquireDepSum(dep) + if err != nil { + return nil, err + } + dep.Sum = sum + deps.Deps[name] = dep + } + + return deps, nil +} + +// AcquireDepSum will acquire the checksum of the dependency from the OCI registry. +func (c *KpmClient) AcquireDepSum(dep pkg.Dependency) (string, error) { + // Only the dependencies from the OCI need can be checked. + if dep.Source.Oci != nil { + if len(dep.Source.Oci.Reg) == 0 { + dep.Source.Oci.Reg = c.GetSettings().DefaultOciRegistry() + } + + if len(dep.Source.Oci.Repo) == 0 { + urlpath := utils.JoinPath(c.GetSettings().DefaultOciRepo(), dep.Name) + dep.Source.Oci.Repo = urlpath + } + // Fetch the metadata of the OCI manifest. + manifest := ocispec.Manifest{} + jsonDesc, err := c.FetchOciManifestIntoJsonStr(opt.OciFetchOptions{ + FetchBytesOptions: oras.DefaultFetchBytesOptions, + OciOptions: opt.OciOptions{ + Reg: dep.Source.Oci.Reg, + Repo: dep.Source.Oci.Repo, + Tag: dep.Source.Oci.Tag, + }, + }) + + if err != nil { + return "", reporter.NewErrorEvent(reporter.FailedFetchOciManifest, err, fmt.Sprintf("failed to fetch the manifest of '%s'", dep.Name)) + } + + err = json.Unmarshal([]byte(jsonDesc), &manifest) + if err != nil { + return "", err + } + + // Check the dependency checksum. + if value, ok := manifest.Annotations[constants.DEFAULT_KCL_OCI_MANIFEST_SUM]; ok { + return value, nil + } + } + + return "", nil } // ResolveDepsIntoMap will calculate the map of kcl package name and local storage path of the external packages. @@ -189,10 +244,51 @@ func (c *KpmClient) ResolveDepsIntoMap(kclPkg *pkg.KclPkg) (map[string]string, e return pkgMap, nil } +const PKG_NAME_PATTERN = "%s_%s" + +// Get the local store path for the dependency. +// 1. in the KCL_PKG_PATH: default is $HOME/.kcl/kpm +// 2. in the vendor subdirectory of the current package. +// 3. the dependency is from the local path. +func (c *KpmClient) getDepStorePath(search_path string, d *pkg.Dependency, isVendor bool) string { + + var storePkgName string + + if d.Source.Oci != nil { + storePkgName = fmt.Sprintf(PKG_NAME_PATTERN, d.Name, d.Source.Oci.Tag) + } else if d.Source.Git != nil { + if len(d.Source.Git.Tag) != 0 { + storePkgName = fmt.Sprintf(PKG_NAME_PATTERN, d.Name, d.Source.Git.Tag) + } else if len(d.Source.Git.Commit) != 0 { + storePkgName = fmt.Sprintf(PKG_NAME_PATTERN, d.Name, d.Source.Git.Commit) + } else { + storePkgName = fmt.Sprintf(PKG_NAME_PATTERN, d.Name, d.Source.Git.Branch) + } + } else { + storePkgName = fmt.Sprintf(PKG_NAME_PATTERN, d.Name, d.Version) + } + + if d.IsFromLocal() { + return d.GetLocalFullPath(search_path) + } else { + if isVendor { + return filepath.Join(search_path, "vendor", storePkgName) + } else { + return filepath.Join(c.homePath, storePkgName) + } + } +} + // ResolveDepsMetadata will calculate the local storage path of the external package, // and check whether the package exists locally. // If the package does not exist, it will re-download to the local. +// Since redownloads are not triggered if local dependencies exists, +// indirect dependencies are also synchronized to the lock file by `lockDeps`. func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) error { + return c.resolvePkgDeps(kclPkg, &kclPkg.Dependencies, update) +} + +func (c *KpmClient) resolvePkgDeps(kclPkg *pkg.KclPkg, lockDeps *pkg.Dependencies, update bool) error { var searchPath string kclPkg.NoSumCheck = c.noSumCheck @@ -202,10 +298,6 @@ func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) erro if err != nil { return err } - searchPath = kclPkg.LocalVendorPath() - } else { - // Otherwise, the search path is the $KCL_PKG_PATH. - searchPath = c.homePath } // If under the mode of '--no_sum_check', the checksum of the package will not be checked. @@ -219,7 +311,7 @@ func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) erro // clean the dependencies in kcl.mod.lock and kcl.mod which have different version for name, dep := range kclPkg.Dependencies.Deps { modDep, ok := kclPkg.ModFile.Dependencies.Deps[name] - if !ok || !dep.WithTheSameVersion(modDep) { + if !ok || !dep.Equals(modDep) { delete(kclPkg.Dependencies.Deps, name) } } @@ -248,68 +340,66 @@ func (c *KpmClient) ResolvePkgDepsMetadata(kclPkg *pkg.KclPkg, update bool) erro } for name, d := range kclPkg.Dependencies.Deps { - searchFullPath := filepath.Join(searchPath, d.FullName) - if !update { + searchPath = c.getDepStorePath(kclPkg.HomePath, &d, kclPkg.IsVendorMode()) + depPath := searchPath + // if the dependency is not exist + if !utils.DirExists(searchPath) { if d.IsFromLocal() { - depPkg, err := c.LoadPkgFromPath(d.GetLocalFullPath(kclPkg.HomePath)) - if err != nil { - return err - } - d.FromKclPkg(depPkg) + // If the dependency is from the local path, and it does not exist locally, raise an error + return reporter.NewErrorEvent(reporter.DependencyNotFound, fmt.Errorf("dependency '%s' not found in '%s'", d.Name, searchPath)) } else { - d.LocalFullPath = searchFullPath - } - kclPkg.Dependencies.Deps[name] = d - } else { - if utils.DirExists(searchFullPath) && (c.GetNoSumCheck() || utils.CheckPackageSum(d.Sum, searchFullPath)) { - // Find it and update the local path of the dependency. - d.LocalFullPath = searchFullPath - kclPkg.Dependencies.Deps[name] = d - } else if d.IsFromLocal() && !utils.DirExists(d.GetLocalFullPath(kclPkg.HomePath)) { - return reporter.NewErrorEvent(reporter.DependencyNotFound, fmt.Errorf("dependency '%s' not found in '%s'", d.Name, searchFullPath)) - } else if d.IsFromLocal() && utils.DirExists(d.GetLocalFullPath(kclPkg.HomePath)) { - depPkg, err := c.LoadPkgFromPath(d.GetLocalFullPath(kclPkg.HomePath)) - if err != nil { - return err - } - d.FromKclPkg(depPkg) - err = c.AddDepToPkg(kclPkg, &d) - if err != nil { - return err - } - } else { - // Otherwise, re-vendor it. - if kclPkg.IsVendorMode() { - err := c.VendorDeps(kclPkg) - if err != nil { - return err + // redownload the dependency to the local path. + if update { + // re-vendor it. + if kclPkg.IsVendorMode() { + err := c.VendorDeps(kclPkg) + if err != nil { + return err + } + } else { + // re-download it. + err := c.AddDepToPkg(kclPkg, &d) + if err != nil { + return err + } + depPath = c.getDepStorePath(kclPkg.HomePath, &d, kclPkg.IsVendorMode()) } } else { - // Or, re-download it. - err := c.AddDepToPkg(kclPkg, &d) - if err != nil { - return err - } + continue } - // After re-downloading or re-vendoring, - // re-resolving is required to update the dependent paths. - err := c.ResolvePkgDepsMetadata(kclPkg, update) - if err != nil { - return err - } - return nil } } + + // If the dependency exists locally, load the dependency package. + depPkg, err := c.LoadPkgFromPath(depPath) + if err != nil { + return reporter.NewErrorEvent( + reporter.DependencyNotFound, + fmt.Errorf("dependency '%s' not found in '%s'", d.Name, searchPath), + // todo: add command to clean the package cache + ) + } + d.FromKclPkg(depPkg) + d.Sum, err = c.AcquireDepSum(d) + if err != nil { + return err + } + err = c.resolvePkgDeps(depPkg, lockDeps, update) + if err != nil { + return err + } + kclPkg.Dependencies.Deps[name] = d + lockDeps.Deps[name] = d } - if update { - // Generate file kcl.mod.lock. - if !kclPkg.NoSumCheck { - err := kclPkg.LockDepsVersion() - if err != nil { - return err - } + + // Generate file kcl.mod.lock. + if !kclPkg.NoSumCheck { + err := kclPkg.LockDepsVersion() + if err != nil { + return err } } + return nil } @@ -691,7 +781,14 @@ func (c *KpmClient) AddDepWithOpts(kclPkg *pkg.KclPkg, opt *opt.AddOptions) (*pk // AddDepToPkg will add a dependency to the kcl package. func (c *KpmClient) AddDepToPkg(kclPkg *pkg.KclPkg, d *pkg.Dependency) error { - if !reflect.DeepEqual(kclPkg.ModFile.Dependencies.Deps[d.Name], *d) { + // If the dependency is from the local path, do nothing. + if d.IsFromLocal() { + return nil + } + + // Some field will be empty when the dependency is add from CLI. + // For avoiding re-download the dependency, just complete part of the fields not all of them. + if !kclPkg.ModFile.Dependencies.Deps[d.Name].Equals(*d) { // the dep passed on the cli is different from the kcl.mod. kclPkg.ModFile.Dependencies.Deps[d.Name] = *d } @@ -766,25 +863,19 @@ func (c *KpmClient) VendorDeps(kclPkg *pkg.KclPkg) error { if len(d.Name) == 0 { return errors.InvalidDependency } - vendorFullPath := filepath.Join(vendorPath, d.FullName) + vendorFullPath := c.getDepStorePath(kclPkg.HomePath, &d, true) // If the package already exists in the 'vendor', do nothing. - if depExisted(vendorFullPath, d) { + if utils.DirExists(vendorFullPath) { continue } else { // If not in the 'vendor', check the global cache. - cacheFullPath := filepath.Join(c.homePath, d.FullName) - if utils.DirExists(cacheFullPath) && check(d, cacheFullPath) { + cacheFullPath := c.getDepStorePath(c.homePath, &d, false) + if utils.DirExists(cacheFullPath) { // If there is, copy it into the 'vendor' directory. err := copy.Copy(cacheFullPath, vendorFullPath) if err != nil { return err } - } else if depExisted(d.GetLocalFullPath(kclPkg.HomePath), d) { - // If there is, copy it into the 'vendor' directory. - err := copy.Copy(d.GetLocalFullPath(kclPkg.HomePath), vendorFullPath) - if err != nil { - return err - } } else { // re-download if not. err = c.AddDepToPkg(kclPkg, &d) @@ -804,16 +895,9 @@ func (c *KpmClient) VendorDeps(kclPkg *pkg.KclPkg) error { return nil } -// depExisted will check whether the dependency exists in the local path. -// If the dep is from local, do not need to check the checksum, so return true directly if it exists. -// If the dep is from git or oci, check the checksum, so return true if the checksum is correct and it exist. -func depExisted(localPath string, dep pkg.Dependency) bool { - return (utils.DirExists(localPath) && check(dep, localPath)) || - (utils.DirExists(localPath) && dep.IsFromLocal()) -} - // FillDepInfo will fill registry information for a dependency. func (c *KpmClient) FillDepInfo(dep *pkg.Dependency, homepath string) error { + // Homepath for a dependency is the homepath of the kcl package. if dep.Source.Local != nil { dep.LocalFullPath = dep.Source.Local.Path return nil @@ -832,7 +916,7 @@ func (c *KpmClient) FillDepInfo(dep *pkg.Dependency, homepath string) error { FetchBytesOptions: oras.DefaultFetchBytesOptions, OciOptions: opt.OciOptions{ Reg: dep.Source.Oci.Reg, - Repo: fmt.Sprintf("%s/%s", dep.Source.Oci.Repo, dep.Name), + Repo: dep.Source.Oci.Repo, Tag: dep.Version, }, }) @@ -847,7 +931,6 @@ func (c *KpmClient) FillDepInfo(dep *pkg.Dependency, homepath string) error { dep.Sum = value } } - return nil } return nil @@ -865,6 +948,16 @@ func (c *KpmClient) FillDependenciesInfo(modFile *pkg.ModFile) error { return nil } +// AcquireTheLatestOciVersion will acquire the latest version of the OCI reference. +func (c *KpmClient) AcquireTheLatestOciVersion(ociSource pkg.Oci) (string, error) { + ociClient, err := oci.NewOciClient(ociSource.Reg, ociSource.Repo, &c.settings) + if err != nil { + return "", err + } + + return ociClient.TheLatestTag() +} + // Download will download the dependency to the local path. func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (*pkg.Dependency, error) { if dep.Source.Git != nil { @@ -891,6 +984,39 @@ func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (* } if dep.Source.Oci != nil { + // Select the latest tag, if the tag, the user inputed, is empty. + if dep.Source.Oci.Tag == "" || dep.Source.Oci.Tag == constants.LATEST { + latestTag, err := c.AcquireTheLatestOciVersion(*dep.Source.Oci) + if err != nil { + return nil, err + } + dep.Source.Oci.Tag = latestTag + + // Complete some information that the local three dependencies depend on. + // The invalid path such as '$HOME/.kcl/kpm/k8s_' is placed because the version field is missing. + dep.Version = latestTag + dep.FullName = dep.GenDepFullName() + dep.LocalFullPath = filepath.Join(filepath.Dir(localPath), dep.FullName) + localPath = dep.LocalFullPath + if utils.DirExists(dep.LocalFullPath) { + dpkg, err := c.LoadPkgFromPath(localPath) + if err != nil { + // If the package is invalid, delete it and re-download it. + err := os.RemoveAll(dep.LocalFullPath) + if err != nil { + return nil, err + } + } else { + dep.FromKclPkg(dpkg) + dep.Sum, err = c.AcquireDepSum(*dep) + if err != nil { + return nil, err + } + return dep, nil + } + } + } + err := c.DepDownloader.Download(*downloader.NewDownloadOptions( downloader.WithLocalPath(localPath), downloader.WithSource(dep.Source), @@ -905,6 +1031,11 @@ func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (* return nil, err } dep.FromKclPkg(dpkg) + // The downloaded checksum is requested, not calculated + dep.Sum, err = c.AcquireDepSum(*dep) + if err != nil { + return nil, err + } if dep.LocalFullPath == "" { dep.LocalFullPath = localPath @@ -927,25 +1058,13 @@ func (c *KpmClient) Download(dep *pkg.Dependency, homePath, localPath string) (* } if dep.Source.Local != nil { - kpkg, err := pkg.FindFirstKclPkgFrom(dep.GetLocalFullPath(homePath)) + kpkg, err := pkg.FindFirstKclPkgFrom(c.getDepStorePath(homePath, dep, false)) if err != nil { return nil, err } dep.FromKclPkg(kpkg) } - if dep.Source.Local == nil { - var err error - dep.Sum, err = utils.HashDir(dep.LocalFullPath) - if err != nil { - return nil, reporter.NewErrorEvent( - reporter.FailedHashPkg, - err, - fmt.Sprintf("failed to hash the kcl package '%s' in '%s'.", dep.Name, dep.LocalFullPath), - ) - } - } - return dep, nil } @@ -1342,26 +1461,22 @@ func (c *KpmClient) InitGraphAndDownloadDeps(kclPkg *pkg.KclPkg) (*pkg.Dependenc } // dependencyExists will check whether the dependency exists in the local filesystem. -func (c *KpmClient) dependencyExists(dep *pkg.Dependency, lockDeps *pkg.Dependencies) *pkg.Dependency { - +func (c *KpmClient) dependencyExistsLocal(searchPath string, dep *pkg.Dependency) (*pkg.Dependency, error) { // If the flag '--no_sum_check' is set, skip the checksum check. - if c.noSumCheck { - // If the dependent package does exist locally - if utils.DirExists(filepath.Join(c.homePath, dep.FullName)) { - return dep + deppath := c.getDepStorePath(searchPath, dep, false) + if utils.DirExists(deppath) { + depPkg, err := c.LoadPkgFromPath(deppath) + if err != nil { + return nil, err } - } - - lockDep, present := lockDeps.Deps[dep.Name] - // Check if the sum of this dependency in kcl.mod.lock has been changed. - if !c.noSumCheck && present { - // If the dependent package does not exist locally, then method 'check' will return false. - if c.noSumCheck || check(lockDep, filepath.Join(c.homePath, dep.FullName)) { - return &lockDep + dep.FromKclPkg(depPkg) + dep.Sum, err = c.AcquireDepSum(*dep) + if err != nil { + return nil, err } + return dep, nil } - - return nil + return nil, nil } // downloadDeps will download all the dependencies of the current kcl package. @@ -1377,8 +1492,8 @@ func (c *KpmClient) DownloadDeps(deps *pkg.Dependencies, lockDeps *pkg.Dependenc return nil, errors.InvalidDependency } - existDep := c.dependencyExists(&d, lockDeps) - if existDep != nil { + existDep, err := c.dependencyExistsLocal(pkghome, &d) + if existDep != nil && err == nil { newDeps.Deps[d.Name] = *existDep continue } @@ -1388,8 +1503,12 @@ func (c *KpmClient) DownloadDeps(deps *pkg.Dependencies, lockDeps *pkg.Dependenc if len(c.homePath) == 0 || len(d.FullName) == 0 { return nil, errors.InternalBug } - dir := filepath.Join(c.homePath, d.FullName) - os.RemoveAll(dir) + + dir := c.getDepStorePath(c.homePath, &d, false) + err = os.RemoveAll(dir) + if err != nil { + return nil, err + } // download dependencies lockedDep, err := c.Download(&d, pkghome, dir) @@ -1397,15 +1516,14 @@ func (c *KpmClient) DownloadDeps(deps *pkg.Dependencies, lockDeps *pkg.Dependenc return nil, err } - if !lockedDep.IsFromLocal() { + if lockedDep.Oci != nil && lockedDep.Equals(lockDeps.Deps[d.Name]) { if !c.noSumCheck && expectedSum != "" && - lockedDep.Sum != expectedSum && - existDep != nil && - existDep.FullName == d.FullName { + lockedDep.Sum != "" && + lockedDep.Sum != expectedSum { return nil, reporter.NewErrorEvent( reporter.CheckSumMismatch, errors.CheckSumMismatchError, - fmt.Sprintf("checksum for '%s' changed in lock file", lockedDep.Name), + fmt.Sprintf("checksum for '%s' changed in lock file '%s' and '%s'", lockedDep.Name, expectedSum, lockedDep.Sum), ) } } @@ -1541,21 +1659,6 @@ func (c *KpmClient) FetchOciManifestIntoJsonStr(opts opt.OciFetchOptions) (strin return manifestJson, nil } -// check sum for a Dependency. -func check(dep pkg.Dependency, newDepPath string) bool { - if dep.Sum == "" { - return false - } - - sum, err := utils.HashDir(newDepPath) - - if err != nil { - return false - } - - return dep.Sum == sum -} - // createDepRef will create a dependency reference for the dependency saved on the local filesystem. // On the unix-like system, it will create a symbolic link. // On the windows system, it will create a junction. diff --git a/pkg/client/client_test.go b/pkg/client/client_test.go index fd0ccdf1..d0df4502 100644 --- a/pkg/client/client_test.go +++ b/pkg/client/client_test.go @@ -52,7 +52,7 @@ func initTestDir(subDir string) string { // TestDownloadGit test download from oci registry. func TestDownloadOci(t *testing.T) { - testPath := filepath.Join(getTestDir("download"), "k8s_1.27") + testPath := filepath.Join(getTestDir("download"), "helloworld_0.1.2") err := os.MkdirAll(testPath, 0755) assert.Equal(t, err, nil) @@ -64,13 +64,13 @@ func TestDownloadOci(t *testing.T) { }() depFromOci := pkg.Dependency{ - Name: "k8s", - Version: "1.27", + Name: "helloworld", + Version: "0.1.2", Source: pkg.Source{ Oci: &pkg.Oci{ Reg: "ghcr.io", - Repo: "kcl-lang/k8s", - Tag: "1.27", + Repo: "kcl-lang/helloworld", + Tag: "0.1.2", }, }, } @@ -78,22 +78,21 @@ func TestDownloadOci(t *testing.T) { assert.Equal(t, err, nil) dep, err := kpmcli.Download(&depFromOci, "", testPath) assert.Equal(t, err, nil) - assert.Equal(t, dep.Name, "k8s") - assert.Equal(t, dep.FullName, "k8s_1.27") - assert.Equal(t, dep.Version, "1.27") - assert.Equal(t, dep.Sum, "xnYM1FWHAy3m+KcQMQb2rjZouTxumqYt6FGZpu2T4yM=") + assert.Equal(t, dep.Name, "helloworld") + assert.Equal(t, dep.FullName, "helloworld_0.1.2") + assert.Equal(t, dep.Version, "0.1.2") assert.NotEqual(t, dep.Source.Oci, nil) assert.Equal(t, dep.Source.Oci.Reg, "ghcr.io") - assert.Equal(t, dep.Source.Oci.Repo, "kcl-lang/k8s") - assert.Equal(t, dep.Source.Oci.Tag, "1.27") + assert.Equal(t, dep.Source.Oci.Repo, "kcl-lang/helloworld") + assert.Equal(t, dep.Source.Oci.Tag, "0.1.2") assert.Equal(t, dep.LocalFullPath, testPath) // Check whether the tar downloaded by `kpm add` has been deleted. downloadPath := getTestDir("download") - assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "k8s_1.27.tar")), false) + assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "helloworld_0.1.2.tar")), false) - assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "k8s_1.27")), true) - assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "k8s")), false) + assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "helloworld_0.1.2")), true) + assert.Equal(t, utils.DirExists(filepath.Join(downloadPath, "helloworld")), false) } // TestDownloadLatestOci tests the case that the version is empty. @@ -130,7 +129,7 @@ func TestDownloadLatestOci(t *testing.T) { assert.Equal(t, dep.Source.Oci.Reg, "ghcr.io") assert.Equal(t, dep.Source.Oci.Repo, "kcl-lang/helloworld") assert.Equal(t, dep.Source.Oci.Tag, "0.1.2") - assert.Equal(t, dep.LocalFullPath, testPath) + assert.Equal(t, dep.LocalFullPath, filepath.Join(getTestDir("download"), "helloworld_0.1.2")) assert.Equal(t, err, nil) // Check whether the tar downloaded by `kpm add` has been deleted. @@ -374,12 +373,14 @@ func TestVendorDeps(t *testing.T) { depKcl1 := pkg.Dependency{ Name: "kcl1", FullName: "kcl1", + Version: "0.0.1", Sum: kcl1Sum, } depKcl2 := pkg.Dependency{ Name: "kcl2", FullName: "kcl2", + Version: "0.0.1", Sum: kcl2Sum, } @@ -416,8 +417,8 @@ func TestVendorDeps(t *testing.T) { err = kpmcli.VendorDeps(&kclPkg) assert.Equal(t, err, nil) assert.Equal(t, utils.DirExists(mykclVendorPath), true) - assert.Equal(t, utils.DirExists(filepath.Join(mykclVendorPath, "kcl1")), true) - assert.Equal(t, utils.DirExists(filepath.Join(mykclVendorPath, "kcl2")), true) + assert.Equal(t, utils.DirExists(filepath.Join(mykclVendorPath, "kcl1_0.0.1")), true) + assert.Equal(t, utils.DirExists(filepath.Join(mykclVendorPath, "kcl2_0.0.1")), true) maps, err := kpmcli.ResolveDepsIntoMap(&kclPkg) assert.Equal(t, err, nil) @@ -455,13 +456,15 @@ func TestResolveDepsVendorMode(t *testing.T) { depKcl1 := pkg.Dependency{ Name: "kcl1", - FullName: "kcl1", + FullName: "kcl1_0.0.1", + Version: "0.0.1", Sum: kcl1Sum, } depKcl2 := pkg.Dependency{ Name: "kcl2", - FullName: "kcl2", + FullName: "kcl2_0.0.1", + Version: "0.0.1", Sum: kcl2Sum, } @@ -521,13 +524,15 @@ func TestCompileWithEntryFile(t *testing.T) { kcl1Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl1")) depKcl1 := pkg.Dependency{ Name: "kcl1", - FullName: "kcl1", + FullName: "kcl1_0.0.1", + Version: "0.0.1", Sum: kcl1Sum, } kcl2Sum, _ := utils.HashDir(filepath.Join(kpm_home, "kcl2")) depKcl2 := pkg.Dependency{ Name: "kcl2", - FullName: "kcl2", + FullName: "kcl2_0.0.1", + Version: "0.0.1", Sum: kcl2Sum, } @@ -565,8 +570,8 @@ func TestCompileWithEntryFile(t *testing.T) { kpmcli.homePath = kpm_home result, err := kpmcli.Compile(&kclPkg, compiler) assert.Equal(t, err, nil) - assert.Equal(t, utils.DirExists(filepath.Join(vendor_path, "kcl1")), true) - assert.Equal(t, utils.DirExists(filepath.Join(vendor_path, "kcl2")), true) + assert.Equal(t, utils.DirExists(filepath.Join(vendor_path, "kcl1_0.0.1")), true) + assert.Equal(t, utils.DirExists(filepath.Join(vendor_path, "kcl2_0.0.1")), true) assert.Equal(t, result.GetRawYamlResult(), "c1: 1\nc2: 2") os.RemoveAll(vendor_path) @@ -616,18 +621,12 @@ func TestResolveMetadataInJsonStr(t *testing.T) { testDir := getTestDir("resolve_metadata") - testHomePath := filepath.Join(filepath.Dir(testDir), "test_home_path") - prepareKpmHomeInPath(testHomePath) - defer os.RemoveAll(testHomePath) - - os.Setenv(env.PKG_PATH, testHomePath) - - kclpkg, err := pkg.LoadKclPkg(testDir) + kpmcli, err := NewKpmClient() + assert.Equal(t, err, nil) + kclpkg, err := kpmcli.LoadPkgFromPath(testDir) assert.Equal(t, err, nil) globalPkgPath, _ := env.GetAbsPkgPath() - kpmcli, err := NewKpmClient() - assert.Equal(t, err, nil) res, err := kpmcli.ResolveDepsMetadataInJsonStr(kclpkg, true) assert.Equal(t, err, nil) @@ -635,10 +634,11 @@ func TestResolveMetadataInJsonStr(t *testing.T) { Deps: make(map[string]pkg.Dependency), } - expectedDep.Deps["konfig"] = pkg.Dependency{ - Name: "konfig", - FullName: "konfig_v0.0.1", - LocalFullPath: filepath.Join(globalPkgPath, "konfig_v0.0.1"), + expectedDep.Deps["flask_demo_kcl_manifests"] = pkg.Dependency{ + Name: "flask_demo_kcl_manifests", + FullName: "flask-demo-kcl-manifests_ade147b", + Version: "ade147b", + LocalFullPath: filepath.Join(globalPkgPath, "flask-demo-kcl-manifests_ade147b"), } expectedDepStr, err := json.Marshal(expectedDep) @@ -655,12 +655,13 @@ func TestResolveMetadataInJsonStr(t *testing.T) { res, err = kpmcli.ResolveDepsMetadataInJsonStr(kclpkg, true) assert.Equal(t, err, nil) assert.Equal(t, utils.DirExists(vendorDir), true) - assert.Equal(t, utils.DirExists(filepath.Join(vendorDir, "konfig_v0.0.1")), true) + assert.Equal(t, utils.DirExists(filepath.Join(vendorDir, "flask-demo-kcl-manifests_ade147b")), true) - expectedDep.Deps["konfig"] = pkg.Dependency{ - Name: "konfig", - FullName: "konfig_v0.0.1", - LocalFullPath: filepath.Join(vendorDir, "konfig_v0.0.1"), + expectedDep.Deps["flask_demo_kcl_manifests"] = pkg.Dependency{ + Name: "flask_demo_kcl_manifests", + FullName: "flask-demo-kcl-manifests_ade147b", + Version: "ade147b", + LocalFullPath: filepath.Join(vendorDir, "flask-demo-kcl-manifests_ade147b"), } expectedDepStr, err = json.Marshal(expectedDep) @@ -676,30 +677,19 @@ func TestResolveMetadataInJsonStr(t *testing.T) { assert.Equal(t, err, nil) kpmcli.homePath = "not_exist" res, err = kpmcli.ResolveDepsMetadataInJsonStr(kclpkg, false) - fmt.Printf("err: %v\n", err) assert.Equal(t, err, nil) assert.Equal(t, utils.DirExists(vendorDir), false) - assert.Equal(t, utils.DirExists(filepath.Join(vendorDir, "konfig_v0.0.1")), false) - jsonPath, err := json.Marshal(filepath.Join("not_exist", "konfig_v0.0.1")) + assert.Equal(t, utils.DirExists(filepath.Join(vendorDir, "flask-demo-kcl-manifests_ade147b")), false) assert.Equal(t, err, nil) - expectedStr := fmt.Sprintf("{\"packages\":{\"konfig\":{\"name\":\"konfig\",\"manifest_path\":%s}}}", string(jsonPath)) + expectedStr := "{\"packages\":{\"flask_demo_kcl_manifests\":{\"name\":\"flask_demo_kcl_manifests\",\"manifest_path\":\"\"}}}" assert.Equal(t, res, expectedStr) defer func() { - if r := os.RemoveAll(filepath.Join("not_exist", "konfig_v0.0.1")); r != nil { + if r := os.RemoveAll(filepath.Join("not_exist", "flask-demo-kcl-manifests_ade147b")); r != nil { err = fmt.Errorf("panic: %v", r) } }() } -func prepareKpmHomeInPath(path string) { - dirPath := filepath.Join(filepath.Join(path, ".kpm"), "config") - _ = os.MkdirAll(dirPath, 0755) - - filePath := filepath.Join(dirPath, "kpm.json") - - _ = os.WriteFile(filePath, []byte("{\"DefaultOciRegistry\":\"ghcr.io\",\"DefaultOciRepo\":\"awesome-kusion\"}"), 0644) -} - func TestPkgWithInVendorMode(t *testing.T) { testDir := getTestDir("test_pkg_with_vendor") kcl1Path := filepath.Join(testDir, "kcl1") @@ -866,7 +856,7 @@ func TestUpdateWithKclMod(t *testing.T) { err = copy.Copy(src_testDir, dest_testDir) assert.Equal(t, err, nil) - kclPkg, err := pkg.LoadKclPkg(dest_testDir) + kclPkg, err := kpmcli.LoadPkgFromPath(dest_testDir) assert.Equal(t, err, nil) err = kpmcli.UpdateDeps(kclPkg) assert.Equal(t, err, nil) @@ -1083,7 +1073,7 @@ func TestUpdateWithNoSumCheck(t *testing.T) { err = kpmcli.UpdateDeps(kclPkg) assert.Equal(t, err, nil) assert.Equal(t, utils.DirExists(filepath.Join(pkgPath, "kcl.mod.lock")), true) - assert.Equal(t, buf.String(), "adding 'helloworld' with version '0.1.1'\ndownloading 'kcl-lang/helloworld:0.1.1' from 'ghcr.io/kcl-lang/helloworld:0.1.1'\n") + assert.Equal(t, buf.String(), "adding 'helloworld' with version '0.1.1'\n") defer func() { _ = os.Remove(filepath.Join(pkgPath, "kcl.mod.lock")) @@ -1114,7 +1104,7 @@ func TestAddWithDiffVersionNoSumCheck(t *testing.T) { Reg: "ghcr.io", Repo: "kcl-lang", PkgName: "helloworld", - Tag: "0.1.1", + Tag: "0.1.2", }, }, NoSumCheck: true, @@ -1178,7 +1168,7 @@ func TestAddWithDiffVersionWithSumCheck(t *testing.T) { Reg: "ghcr.io", Repo: "kcl-lang", PkgName: "helloworld", - Tag: "0.1.1", + Tag: "0.1.2", }, }, } @@ -1245,8 +1235,8 @@ func TestAddWithGitCommit(t *testing.T) { LocalPath: testPkgPath, RegistryOpts: opt.RegistryOptions{ Git: &opt.GitOptions{ - Url: "https://github.com/KusionStack/catalog.git", - Commit: "a29e3db", + Url: "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", + Commit: "ade147b", }, }, } @@ -1301,7 +1291,7 @@ func TestLoadPkgFormOci(t *testing.T) { { Reg: "ghcr.io", Repo: "kcl-lang/helloworld", - Tag: "0.1.1", + Tag: "0.1.2", Name: "helloworld", }, } @@ -1507,6 +1497,6 @@ func testRunWithOciDownloader(t *testing.T) { opt.WithLogWriter(writer), ) assert.Equal(t, err, nil) - assert.Equal(t, buf.String(), "downloading 'zong-zhe/helloworld:0.0.3' from 'ghcr.io/zong-zhe/helloworld:0.0.3'\n") + strings.Contains(buf.String(), "downloading 'zong-zhe/helloworld:0.0.3' from 'ghcr.io/zong-zhe/helloworld:0.0.3'") assert.Equal(t, res.GetRawYamlResult(), "The_first_kcl_program: Hello World!") } diff --git a/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.expect b/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.expect index 475d36f8..2950f92d 100644 --- a/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.expect +++ b/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.expect @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -catalog = { git = "https://github.com/KusionStack/catalog.git", commit = "a29e3db" } +flask-demo-kcl-manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b" } diff --git a/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.lock.expect b/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.lock.expect index dbb61a69..935309f6 100644 --- a/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.lock.expect +++ b/pkg/client/test_data/add_with_git_commit/test_pkg/kcl.mod.lock.expect @@ -1,8 +1,7 @@ [dependencies] - [dependencies.catalog] - name = "catalog" - full_name = "catalog_a29e3db" - version = "0.1.0" - sum = "kFmlrYJbJUFFTEXjC9cquc80WB+UpZ/6oMPKrfgyeks=" - url = "https://github.com/KusionStack/catalog.git" - commit = "a29e3db" \ No newline at end of file + [dependencies.flask-demo-kcl-manifests] + name = "flask-demo-kcl-manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + commit = "ade147b" diff --git a/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.expect b/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.expect index 475d36f8..2950f92d 100644 --- a/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.expect +++ b/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.expect @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -catalog = { git = "https://github.com/KusionStack/catalog.git", commit = "a29e3db" } +flask-demo-kcl-manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b" } diff --git a/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.lock.expect b/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.lock.expect index cda1fc63..935309f6 100644 --- a/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.lock.expect +++ b/pkg/client/test_data/add_with_git_commit/test_pkg_win/kcl.mod.lock.expect @@ -1,8 +1,7 @@ [dependencies] - [dependencies.catalog] - name = "catalog" - full_name = "catalog_a29e3db" - version = "0.1.0" - sum = "zhh1yHk5TrNi9apHUQF3hPOlwi5Kc75cNHjcVmGv+Qo=" - url = "https://github.com/KusionStack/catalog.git" - commit = "a29e3db" \ No newline at end of file + [dependencies.flask-demo-kcl-manifests] + name = "flask-demo-kcl-manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + commit = "ade147b" diff --git a/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod b/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod index 939fba20..cd18a78b 100644 --- a/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod +++ b/pkg/client/test_data/add_with_local_path/expect/pkg/kcl.mod @@ -5,4 +5,4 @@ version = "0.0.1" [dependencies] dep_pkg = { path = "../dep_pkg" } -helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.1" } +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2" } 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 cf4fb1e7..3f488872 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 @@ -5,9 +5,9 @@ version = "0.0.1" [dependencies.helloworld] name = "helloworld" - full_name = "helloworld_0.1.1" - version = "0.1.1" - sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + full_name = "helloworld_0.1.2" + version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" - oci_tag = "0.1.1" + oci_tag = "0.1.2" diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl1/kcl.mod b/pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/kcl.mod similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl1/kcl.mod rename to pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/kcl.mod diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl1/kcl.mod.lock b/pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/kcl.mod.lock similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl1/kcl.mod.lock rename to pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/kcl.mod.lock diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl1/main.k b/pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/main.k similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl1/main.k rename to pkg/client/test_data/resolve_deps/kpm_home/kcl1_0.0.1/main.k diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl2/kcl.mod b/pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/kcl.mod similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl2/kcl.mod rename to pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/kcl.mod diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl2/kcl.mod.lock b/pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/kcl.mod.lock similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl2/kcl.mod.lock rename to pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/kcl.mod.lock diff --git a/pkg/client/test_data/resolve_deps/kpm_home/kcl2/main.k b/pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/main.k similarity index 100% rename from pkg/client/test_data/resolve_deps/kpm_home/kcl2/main.k rename to pkg/client/test_data/resolve_deps/kpm_home/kcl2_0.0.1/main.k diff --git a/pkg/client/test_data/resolve_deps/my_kcl_compile/kcl.mod.lock b/pkg/client/test_data/resolve_deps/my_kcl_compile/kcl.mod.lock index 25f3d72a..b6a76aec 100644 --- a/pkg/client/test_data/resolve_deps/my_kcl_compile/kcl.mod.lock +++ b/pkg/client/test_data/resolve_deps/my_kcl_compile/kcl.mod.lock @@ -1,9 +1,9 @@ [dependencies] [dependencies.kcl1] name = "kcl1" - full_name = "kcl1" - sum = "c5bjxiHbwJqWCdBwXLOr9MydCTis3nJotrOzozkPsKo=" + full_name = "kcl1_0.0.1" + version = "0.0.1" [dependencies.kcl2] name = "kcl2" - full_name = "kcl2" - sum = "OiA7IJfhi9bLp3d+Phc6ncgWE8XwpXqkGvhF5BOpf34=" + full_name = "kcl2_0.0.1" + version = "0.0.1" diff --git a/pkg/client/test_data/resolve_metadata/kcl.mod b/pkg/client/test_data/resolve_metadata/kcl.mod index 7f59740b..1f574119 100644 --- a/pkg/client/test_data/resolve_metadata/kcl.mod +++ b/pkg/client/test_data/resolve_metadata/kcl.mod @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -konfig = { git = "https://github.com/awesome-kusion/konfig.git", tag = "v0.0.1" } +flask-demo-kcl-manifests = { git = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git", commit = "ade147b" } diff --git a/pkg/client/test_data/resolve_metadata/kcl.mod.lock b/pkg/client/test_data/resolve_metadata/kcl.mod.lock index 02b0b8e3..688e76c4 100644 --- a/pkg/client/test_data/resolve_metadata/kcl.mod.lock +++ b/pkg/client/test_data/resolve_metadata/kcl.mod.lock @@ -1,8 +1,8 @@ [dependencies] - [dependencies.konfig] - name = "konfig" - full_name = "konfig_v0.0.1" - version = "v0.0.1" - sum = "XFvHdBAoY/+qpJWmj8cjwOwZO8a3nX/7SE35cTxQOFU=" - url = "https://github.com/awesome-kusion/konfig.git" - git_tag = "v0.0.1" + [dependencies.flask-demo-kcl-manifests] + name = "flask-demo-kcl-manifests" + full_name = "flask_manifests_0.0.1" + version = "0.0.1" + sum = "wREQiSSuLkbCrxWX0vIa57WB2nkJrsBx2eaDDxg6O+o=" + url = "https://github.com/kcl-lang/flask-demo-kcl-manifests.git" + commit = "ade147b" diff --git a/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.bak b/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.bak index 126d4126..80c5c43d 100644 --- a/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.bak +++ b/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.bak @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -helloworld = "0.1.0" +helloworld = "0.1.2" diff --git a/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.expect b/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.expect index 6a23e353..15ebd0f4 100644 --- a/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.expect +++ b/pkg/client/test_data/test_add_diff_version/no_sum_check/kcl.mod.expect @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.1" } +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2" } diff --git a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.bak b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.bak index a29e213d..12148360 100644 --- a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.bak +++ b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.bak @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -helloworld = "0.1.0" +helloworld = "0.1.2" diff --git a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.expect b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.expect index 9ed0fba7..8a5d1e7a 100644 --- a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.expect +++ b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.expect @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.1" } +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2" } diff --git a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.bak b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.bak index b57cac07..7eaf9cba 100644 --- a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.bak +++ b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.bak @@ -1,9 +1,9 @@ [dependencies] [dependencies.helloworld] name = "helloworld" - full_name = "helloworld_0.1.0" - version = "0.1.0" - sum = "aqrvSsd8zGHzRERbOzxYxARmK6QjvpQMYC1OqemdZvc=" + full_name = "helloworld_0.1.2" + version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" - oci_tag = "0.1.1" + oci_tag = "0.1.2" diff --git a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.expect b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.expect index 6270d4f4..7eaf9cba 100644 --- a/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.expect +++ b/pkg/client/test_data/test_add_diff_version/with_sum_check/kcl.mod.lock.expect @@ -1,9 +1,9 @@ [dependencies] [dependencies.helloworld] name = "helloworld" - full_name = "helloworld_0.1.1" - version = "0.1.1" - sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + full_name = "helloworld_0.1.2" + version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" - oci_tag = "0.1.1" + oci_tag = "0.1.2" diff --git a/pkg/client/test_data/test_oci_downloader/add_dep/pkg/kcl.mod.lock b/pkg/client/test_data/test_oci_downloader/add_dep/pkg/kcl.mod.lock index fd4a314b..129819c0 100644 --- a/pkg/client/test_data/test_oci_downloader/add_dep/pkg/kcl.mod.lock +++ b/pkg/client/test_data/test_oci_downloader/add_dep/pkg/kcl.mod.lock @@ -3,7 +3,6 @@ name = "helloworld" full_name = "helloworld_0.0.3" version = "0.0.3" - sum = "OS3OHaC8HE5Z/4KEWJbS8xyHrYVSvXqHYxwy0BGc7nM=" reg = "ghcr.io" repo = "zong-zhe/helloworld" oci_tag = "0.0.3" diff --git a/pkg/client/test_data/test_oci_downloader/run_pkg/pkg/kcl.mod.lock b/pkg/client/test_data/test_oci_downloader/run_pkg/pkg/kcl.mod.lock index fd4a314b..129819c0 100644 --- a/pkg/client/test_data/test_oci_downloader/run_pkg/pkg/kcl.mod.lock +++ b/pkg/client/test_data/test_oci_downloader/run_pkg/pkg/kcl.mod.lock @@ -3,7 +3,6 @@ name = "helloworld" full_name = "helloworld_0.0.3" version = "0.0.3" - sum = "OS3OHaC8HE5Z/4KEWJbS8xyHrYVSvXqHYxwy0BGc7nM=" reg = "ghcr.io" repo = "zong-zhe/helloworld" oci_tag = "0.0.3" diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.stderr b/pkg/client/test_data/test_parse_kcl_mod_file/kcl.mod similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.stderr rename to pkg/client/test_data/test_parse_kcl_mod_file/kcl.mod diff --git a/pkg/client/test_data/test_update/test_update_kcl_mod/expected b/pkg/client/test_data/test_update/test_update_kcl_mod/expected index 6270d4f4..7eaf9cba 100644 --- a/pkg/client/test_data/test_update/test_update_kcl_mod/expected +++ b/pkg/client/test_data/test_update/test_update_kcl_mod/expected @@ -1,9 +1,9 @@ [dependencies] [dependencies.helloworld] name = "helloworld" - full_name = "helloworld_0.1.1" - version = "0.1.1" - sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + full_name = "helloworld_0.1.2" + version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" - oci_tag = "0.1.1" + oci_tag = "0.1.2" diff --git a/pkg/client/test_data/test_update/test_update_kcl_mod/kcl.mod b/pkg/client/test_data/test_update/test_update_kcl_mod/kcl.mod index d3a99616..249c61c4 100644 --- a/pkg/client/test_data/test_update/test_update_kcl_mod/kcl.mod +++ b/pkg/client/test_data/test_update/test_update_kcl_mod/kcl.mod @@ -4,4 +4,4 @@ edition = "0.0.1" version = "0.0.1" [dependencies] -helloworld = "0.1.1" +helloworld = "0.1.2" diff --git a/pkg/client/test_data/test_update/test_update_kcl_mod_lock/kcl.mod.lock b/pkg/client/test_data/test_update/test_update_kcl_mod_lock/kcl.mod.lock index 6270d4f4..7eaf9cba 100644 --- a/pkg/client/test_data/test_update/test_update_kcl_mod_lock/kcl.mod.lock +++ b/pkg/client/test_data/test_update/test_update_kcl_mod_lock/kcl.mod.lock @@ -1,9 +1,9 @@ [dependencies] [dependencies.helloworld] name = "helloworld" - full_name = "helloworld_0.1.1" - version = "0.1.1" - sum = "7OO4YK2QuRWPq9C7KTzcWcti5yUnueCjptT3OXiPVeQ=" + full_name = "helloworld_0.1.2" + version = "0.1.2" + sum = "PN0OMEV9M8VGFn1CtA/T3bcgZmMJmOo+RkBrLKIWYeQ=" reg = "ghcr.io" repo = "kcl-lang/helloworld" - oci_tag = "0.1.1" + oci_tag = "0.1.2" diff --git a/pkg/cmd/cmd_add.go b/pkg/cmd/cmd_add.go index 4ff67c9c..6f481d1e 100644 --- a/pkg/cmd/cmd_add.go +++ b/pkg/cmd/cmd_add.go @@ -15,7 +15,6 @@ import ( "kcl-lang.io/kpm/pkg/env" "kcl-lang.io/kpm/pkg/errors" "kcl-lang.io/kpm/pkg/opt" - pkg "kcl-lang.io/kpm/pkg/package" "kcl-lang.io/kpm/pkg/reporter" ) @@ -80,7 +79,7 @@ func KpmAdd(c *cli.Context, kpmcli *client.KpmClient) error { return err } - kclPkg, err := pkg.LoadKclPkg(pwd) + kclPkg, err := kpmcli.LoadPkgFromPath(pwd) if err != nil { return err } diff --git a/pkg/downloader/downloader.go b/pkg/downloader/downloader.go index 597716f0..24a17125 100644 --- a/pkg/downloader/downloader.go +++ b/pkg/downloader/downloader.go @@ -129,31 +129,15 @@ func (d *OciDownloader) Download(opts DownloadOptions) error { ociCli.PullOciOptions.Platform = d.Platform - // Select the latest tag, if the tag, the user inputed, is empty. - tagSelected := ociSource.Tag - if len(tagSelected) == 0 { - tagSelected, err = ociCli.TheLatestTag() - if err != nil { - return err - } - - reporter.ReportMsgTo( - fmt.Sprintf("the lastest version '%s' will be added", tagSelected), - opts.LogWriter, - ) - - ociSource.Tag = tagSelected - } - reporter.ReportMsgTo( fmt.Sprintf( "downloading '%s:%s' from '%s/%s:%s'", - ociSource.Repo, tagSelected, ociSource.Reg, ociSource.Repo, tagSelected, + ociSource.Repo, ociSource.Tag, ociSource.Reg, ociSource.Repo, ociSource.Tag, ), opts.LogWriter, ) - err = ociCli.Pull(localPath, tagSelected) + err = ociCli.Pull(localPath, ociSource.Tag) if err != nil { return err } diff --git a/pkg/oci/oci.go b/pkg/oci/oci.go index 5bd4da9d..3e63ba9f 100644 --- a/pkg/oci/oci.go +++ b/pkg/oci/oci.go @@ -306,7 +306,7 @@ func (ociClient *OciClient) PushWithOciManifest(localPath, tag string, opts *opt return nil } -// FetchManifestByRef will fetch the manifest and return it into json string. +// FetchManifestIntoJsonStr will fetch the manifest and return it into json string. func (ociClient *OciClient) FetchManifestIntoJsonStr(opts opt.OciFetchOptions) (string, error) { fetchOpts := opts.FetchBytesOptions _, manifestContent, err := oras.FetchBytes(*ociClient.ctx, ociClient.repo, opts.Tag, fetchOpts) diff --git a/pkg/oci/oci_test.go b/pkg/oci/oci_test.go index b1386b5c..4c871a18 100644 --- a/pkg/oci/oci_test.go +++ b/pkg/oci/oci_test.go @@ -51,7 +51,7 @@ func TestPull(t *testing.T) { testCases := []TestCase{ {"ghcr.io", "kusionstack/opsrule", "0.0.9"}, - {"ghcr.io", "kcl-lang/helloworld", "0.1.1"}, + {"ghcr.io", "kcl-lang/helloworld", "0.1.2"}, } defer func() { diff --git a/pkg/package/modfile.go b/pkg/package/modfile.go index cca86d3f..261f67d9 100644 --- a/pkg/package/modfile.go +++ b/pkg/package/modfile.go @@ -200,9 +200,7 @@ func (d *Dependency) GetAliasName() string { return strings.ReplaceAll(d.Name, "-", "_") } -// WithTheSameVersion will check whether two dependencies have the same version. -func (d Dependency) WithTheSameVersion(other Dependency) bool { - +func (d Dependency) Equals(other Dependency) bool { var sameVersion = true if len(d.Version) != 0 && len(other.Version) != 0 { sameVersion = d.Version == other.Version @@ -217,7 +215,14 @@ func (d Dependency) WithTheSameVersion(other Dependency) bool { d.Source.Git.Tag == other.Source.Git.Tag) } - return sameNameAndVersion && sameGitSrc + sameOciSrc := true + if d.Source.Oci != nil && other.Source.Oci != nil { + sameOciSrc = d.Source.Oci.Reg == other.Source.Oci.Reg && + d.Source.Oci.Repo == other.Source.Oci.Repo && + d.Source.Oci.Tag == other.Source.Oci.Tag + } + + return sameNameAndVersion && sameGitSrc && sameOciSrc } // GetLocalFullPath will get the local path of a dependency. diff --git a/pkg/package/modfile_test.go b/pkg/package/modfile_test.go index 0e80660c..ffe242f4 100644 --- a/pkg/package/modfile_test.go +++ b/pkg/package/modfile_test.go @@ -26,7 +26,7 @@ func TestModFileWithDesc(t *testing.T) { assert.Equal(t, err, nil) } -func TestWithTheSameVersion(t *testing.T) { +func TestDepEquals(t *testing.T) { d := Dependency{ Name: "test", Version: "0.0.1", @@ -37,13 +37,13 @@ func TestWithTheSameVersion(t *testing.T) { Version: "0.0.2", } - assert.Equal(t, d.WithTheSameVersion(d2), false) + assert.Equal(t, d.Equals(d2), false) d2.Version = "0.0.1" - assert.Equal(t, d.WithTheSameVersion(d2), true) + assert.Equal(t, d.Equals(d2), true) d2.Name = "test2" - assert.Equal(t, d.WithTheSameVersion(d2), false) + assert.Equal(t, d.Equals(d2), false) } func TestModFileExists(t *testing.T) { @@ -182,8 +182,8 @@ func TestLoadModFile(t *testing.T) { assert.Equal(t, err, nil) assert.Equal(t, modFile.Dependencies.Deps["helloworld"].Name, "helloworld") - assert.Equal(t, modFile.Dependencies.Deps["helloworld"].Version, "0.1.1") - assert.Equal(t, modFile.Dependencies.Deps["helloworld"].Source.Oci.Tag, "0.1.1") + assert.Equal(t, modFile.Dependencies.Deps["helloworld"].Version, "0.1.2") + assert.Equal(t, modFile.Dependencies.Deps["helloworld"].Source.Oci.Tag, "0.1.2") assert.Equal(t, err, nil) } diff --git a/pkg/package/test_data/load_mod_file/kcl.mod b/pkg/package/test_data/load_mod_file/kcl.mod index 1c893dfc..318ee9d8 100644 --- a/pkg/package/test_data/load_mod_file/kcl.mod +++ b/pkg/package/test_data/load_mod_file/kcl.mod @@ -6,4 +6,4 @@ version = "0.0.1" [dependencies] name = { git = "test_url", tag = "test_tag" } oci_name = "oci_tag" -helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.1" } \ No newline at end of file +helloworld = { oci = "oci://ghcr.io/kcl-lang/helloworld", tag = "0.1.2" } \ No newline at end of file diff --git a/pkg/reporter/reporter.go b/pkg/reporter/reporter.go index 27af7912..8fc3cd6e 100644 --- a/pkg/reporter/reporter.go +++ b/pkg/reporter/reporter.go @@ -115,6 +115,7 @@ const ( KclModNotFound CompileFailed FailedParseVersion + FailedFetchOciManifest ) // KpmEvent is the event used to show kpm logs to users. diff --git a/scripts/pull_pkg.sh b/scripts/pull_pkg.sh index 95694622..083e9032 100755 --- a/scripts/pull_pkg.sh +++ b/scripts/pull_pkg.sh @@ -32,4 +32,8 @@ if [ ! -d "./ghcr.io/kcl-lang/helloworld/0.1.1" ]; then $current_dir/bin/kpm pull helloworld:0.1.1 fi +if [ ! -d "./ghcr.io/kcl-lang/helloworld/0.1.2" ]; then + $current_dir/bin/kpm pull helloworld:0.1.2 +fi + cd "$current_dir" diff --git a/scripts/push_pkg.sh b/scripts/push_pkg.sh index 659f6f3a..b2807459 100755 --- a/scripts/push_pkg.sh +++ b/scripts/push_pkg.sh @@ -37,6 +37,12 @@ $current_dir/bin/kpm push cd "$current_dir" +# Push the package helloworld/1.17 to the registry +cd ./scripts/pkg_in_reg/ghcr.io/kcl-lang/helloworld/0.1.2 +$current_dir/bin/kpm push + +cd "$current_dir" + # Push the package 'kcl1' depends on 'k8s' to the registry cd ./scripts/pkg_in_reg/kcl1 $current_dir/bin/kpm push diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.stdout deleted file mode 100644 index 664b1334..00000000 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.stdout +++ /dev/null @@ -1,3 +0,0 @@ -adding dependency 'kcl1' -the lastest version '0.0.1' will be added -downloading 'test/kcl1:0.0.1' from 'localhost:5001/test/kcl1:0.0.1' \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.stdout deleted file mode 100644 index ee2e9c3e..00000000 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.stdout +++ /dev/null @@ -1,5 +0,0 @@ -adding dependency 'kcl2' -the lastest version '0.0.1' will be added -downloading 'test/kcl2:0.0.1' from 'localhost:5001/test/kcl2:0.0.1' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' -downloading 'test/kcl1:0.0.1' from 'localhost:5001/test/kcl1:0.0.1' \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.stdout deleted file mode 100644 index 38f8193c..00000000 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.stdout +++ /dev/null @@ -1,5 +0,0 @@ -adding dependency 'kcl2' -the lastest version '0.0.1' will be added -downloading 'test/kcl2:0.0.1' from 'localhost:5001/test/kcl2:0.0.1' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' -downloading 'test/kcl1:0.0.1' from 'localhost:5001/test/kcl1:0.0.1' diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_tag/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_tag/test_suite.stdout index 962a62f8..e9bb3c4e 100644 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_tag/test_suite.stdout +++ b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_tag/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'k8s' -downloading 'test/k8s:1.14' from 'localhost:5001/test/k8s:1.14' add dependency 'k8s:1.14' successfully diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_1/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_1/test_suite.stdout index f07f329e..a7aab52f 100644 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_1/test_suite.stdout +++ b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_1/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'a_kcl_pkg_dep_pkg_name' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' add dependency 'a_kcl_pkg_dep_pkg_name:0.0.1' successfully diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.stdout deleted file mode 100644 index 079b3648..00000000 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.stdout +++ /dev/null @@ -1,3 +0,0 @@ -adding dependency 'a_kcl_pkg_dep_pkg_name' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' -downloading 'test/kcl1:0.0.1' from 'localhost:5001/test/kcl1:0.0.1' \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_relative_path/test_suite.stdout b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_relative_path/test_suite.stdout index 0b7cd806..15e67d33 100644 --- a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_relative_path/test_suite.stdout +++ b/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_relative_path/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'a_kcl_pkg_dep_pkg_name' -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' add dependency 'a_kcl_pkg_dep_pkg_name:0.0.1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.env b/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.env similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.env rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.env diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.input b/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.input similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_1/test_suite.input rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.input diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.stderr similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.stderr rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.stderr diff --git a/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.stdout new file mode 100644 index 00000000..eb14c848 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_add/add_with_name_1/test_suite.stdout @@ -0,0 +1 @@ +add dependency 'kcl1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.env b/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.env similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.env rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.env diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.input b/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.input similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_2/test_suite.input rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.input diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.stderr similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.stderr rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.stderr diff --git a/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.stdout new file mode 100644 index 00000000..94ea214e --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_add/add_with_name_2/test_suite.stdout @@ -0,0 +1 @@ +add dependency 'kcl2' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.env b/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.env similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.env rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.env diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.input b/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.input similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_name_3/test_suite.input rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.input diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.stderr similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.stderr rename to test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.stderr diff --git a/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.stdout new file mode 100644 index 00000000..94ea214e --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_add/add_with_name_3/test_suite.stdout @@ -0,0 +1 @@ +add dependency 'kcl2' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.env b/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.env similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.env rename to test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.env diff --git a/test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.input b/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.input similarity index 100% rename from test/e2e/test_suites/kpm/exec_inside_pkg/add_with_path_2/test_suite.input rename to test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.input diff --git a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stderr b/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.stderr similarity index 100% rename from test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stderr rename to test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.stderr diff --git a/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.stdout new file mode 100644 index 00000000..15e67d33 --- /dev/null +++ b/test/e2e/test_suites/kpm/kpm_add/add_with_path_2/test_suite.stdout @@ -0,0 +1 @@ +add dependency 'a_kcl_pkg_dep_pkg_name:0.0.1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_add/test_add_with_name/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/test_add_with_name/test_suite.stdout index 26b3802b..17f1ed2f 100644 --- a/test/e2e/test_suites/kpm/kpm_add/test_add_with_name/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_add/test_add_with_name/test_suite.stdout @@ -1,4 +1 @@ -adding dependency 'k8s' -the lastest version '1.27' will be added -downloading 'test/k8s:1.27' from 'localhost:5001/test/k8s:1.27' add dependency 'k8s' successfully diff --git a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit/test_suite.stdout index a46bd1a1..41ff69ed 100644 --- a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit/test_suite.stdout @@ -1,2 +1 @@ -adding dependency 'catalog' -cloning 'https://github.com/KusionStack/catalog.git' with commit '3891e96' \ No newline at end of file +add dependency 'catalog:3891e96' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_0/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_0/test_suite.stdout index 72e77907..107be881 100644 --- a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_0/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_0/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'flask-demo-kcl-manifests' -cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with commit '0b3f5ab' add dependency 'flask-demo-kcl-manifests:0b3f5ab' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_1/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_1/test_suite.stdout index 8e7f0a39..57b34175 100644 --- a/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_1/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_add/test_kpm_add_git_commit_1/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'flask-demo-kcl-manifests' -cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with commit '8308200' add dependency 'flask-demo-kcl-manifests:8308200' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_metadata/test_kpm_metadata_with_commit_dep/test_suite.input b/test/e2e/test_suites/kpm/kpm_metadata/test_kpm_metadata_with_commit_dep/test_suite.input index 032346d8..da6fba6b 100644 --- a/test/e2e/test_suites/kpm/kpm_metadata/test_kpm_metadata_with_commit_dep/test_suite.input +++ b/test/e2e/test_suites/kpm/kpm_metadata/test_kpm_metadata_with_commit_dep/test_suite.input @@ -1 +1 @@ -kpm metadata \ No newline at end of file +kpm metadata --update \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_2/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_2/test_suite.stdout index 17e6ee31..f4059255 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_2/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_2/test_suite.stdout @@ -1,2 +1 @@ -adding 'pkg2' The_first_kcl_program: Hello World! \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_3/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_3/test_suite.stdout index 17e6ee31..f4059255 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_3/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_3/test_suite.stdout @@ -1,2 +1 @@ -adding 'pkg2' The_first_kcl_program: Hello World! \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_5/test_suite.stdout b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_5/test_suite.stdout index 17e6ee31..f4059255 100644 --- a/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_5/test_suite.stdout +++ b/test/e2e/test_suites/kpm/kpm_run/test_kpm_run_multi_local_path_5/test_suite.stdout @@ -1,2 +1 @@ -adding 'pkg2' The_first_kcl_program: Hello World! \ No newline at end of file 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 04a8d42f..adf15e56 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,3 +1 @@ -adding 'helloworld' with version '0.1.1' -downloading 'test/helloworld:0.1.1' from 'localhost:5001/test/helloworld:0.1.1' a: Hello World! \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.env b/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.env deleted file mode 100644 index 4c789529..00000000 --- a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.env +++ /dev/null @@ -1,2 +0,0 @@ -KPM_HOME="" -KCLVM_VENDOR_HOME="" \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.input b/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.input deleted file mode 100644 index f17b39a2..00000000 --- a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.input +++ /dev/null @@ -1 +0,0 @@ -kpm update \ No newline at end of file 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 deleted file mode 100644 index f37f0853..00000000 --- a/test/e2e/test_suites/kpm/kpm_update/test_update_with_diff_version/test_suite.stdout +++ /dev/null @@ -1 +0,0 @@ -downloading 'test/k8s:1.14' from 'localhost:5001/test/k8s:1.14' \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/workflows/add_multi_times/2.first_add_konfig_dep/test_suite.stdout b/test/e2e/test_suites/kpm/workflows/add_multi_times/2.first_add_konfig_dep/test_suite.stdout index 3bc1f11c..f41d3344 100644 --- a/test/e2e/test_suites/kpm/workflows/add_multi_times/2.first_add_konfig_dep/test_suite.stdout +++ b/test/e2e/test_suites/kpm/workflows/add_multi_times/2.first_add_konfig_dep/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'konfig' -cloning 'https://github.com/awesome-kusion/konfig.git' with tag 'v0.0.1' add dependency 'konfig:v0.0.1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/workflows/add_multi_times/3.second_add_konfig_dep/test_suite.stdout b/test/e2e/test_suites/kpm/workflows/add_multi_times/3.second_add_konfig_dep/test_suite.stdout index 95e5b69e..f41d3344 100644 --- a/test/e2e/test_suites/kpm/workflows/add_multi_times/3.second_add_konfig_dep/test_suite.stdout +++ b/test/e2e/test_suites/kpm/workflows/add_multi_times/3.second_add_konfig_dep/test_suite.stdout @@ -1,2 +1 @@ -adding dependency 'konfig' add dependency 'konfig:v0.0.1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/workflows/add_multi_times/4.third_add_konfig_dep/test_suite.stdout b/test/e2e/test_suites/kpm/workflows/add_multi_times/4.third_add_konfig_dep/test_suite.stdout index 95e5b69e..f41d3344 100644 --- a/test/e2e/test_suites/kpm/workflows/add_multi_times/4.third_add_konfig_dep/test_suite.stdout +++ b/test/e2e/test_suites/kpm/workflows/add_multi_times/4.third_add_konfig_dep/test_suite.stdout @@ -1,2 +1 @@ -adding dependency 'konfig' add dependency 'konfig:v0.0.1' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/kpm/workflows/init_add_and_run/2.kpm_add/test_suite.stdout b/test/e2e/test_suites/kpm/workflows/init_add_and_run/2.kpm_add/test_suite.stdout index 8e7f0a39..57b34175 100644 --- a/test/e2e/test_suites/kpm/workflows/init_add_and_run/2.kpm_add/test_suite.stdout +++ b/test/e2e/test_suites/kpm/workflows/init_add_and_run/2.kpm_add/test_suite.stdout @@ -1,3 +1 @@ -adding dependency 'flask-demo-kcl-manifests' -cloning 'https://github.com/kcl-lang/flask-demo-kcl-manifests.git' with commit '8308200' add dependency 'flask-demo-kcl-manifests:8308200' successfully \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/add_with_name_1/kcl.mod b/test/e2e/test_suites/test_data/add_with_name_1/kcl.mod new file mode 100644 index 00000000..bfa6c20a --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_1/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "add_with_name_1" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_data/add_with_name_1/kcl.mod.lock b/test/e2e/test_suites/test_data/add_with_name_1/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/add_with_name_1/main.k b/test/e2e/test_suites/test_data/add_with_name_1/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_1/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/add_with_name_2/kcl.mod b/test/e2e/test_suites/test_data/add_with_name_2/kcl.mod new file mode 100644 index 00000000..91a22fb1 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_2/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "add_with_name_2" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_data/add_with_name_2/kcl.mod.lock b/test/e2e/test_suites/test_data/add_with_name_2/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/add_with_name_2/main.k b/test/e2e/test_suites/test_data/add_with_name_2/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_2/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/add_with_name_3/kcl.mod b/test/e2e/test_suites/test_data/add_with_name_3/kcl.mod new file mode 100644 index 00000000..0820eac6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_3/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "add_with_name_3" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_data/add_with_name_3/kcl.mod.lock b/test/e2e/test_suites/test_data/add_with_name_3/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/add_with_name_3/main.k b/test/e2e/test_suites/test_data/add_with_name_3/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_name_3/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod new file mode 100644 index 00000000..2ac8c707 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod @@ -0,0 +1,8 @@ +[package] +name = "a_kcl_pkg_dep_pkg_name" +edition = "0.0.1" +version = "0.0.1" + +[dependencies] +k8s = "1.27" +kcl1 = "0.0.1" diff --git a/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod.lock b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod.lock new file mode 100644 index 00000000..cb5098f3 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/kcl.mod.lock @@ -0,0 +1,17 @@ +[dependencies] + [dependencies.k8s] + name = "k8s" + full_name = "k8s_1.27" + version = "1.27" + sum = "xnYM1FWHAy3m+KcQMQb2rjZouTxumqYt6FGZpu2T4yM=" + reg = "localhost:5001" + repo = "test/k8s" + oci_tag = "1.27" + [dependencies.kcl1] + name = "kcl1" + full_name = "kcl1_0.0.1" + version = "0.0.1" + sum = "zLzaol7KpC57mKLQ/56ciIHO397Rk/Dum+meo+tUsw8=" + reg = "localhost:5001" + repo = "test/kcl1" + oci_tag = "0.0.1" diff --git a/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/main.k b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_path_2/a_kcl_pkg_dep_one_pkg_2/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/add_with_path_2/kcl.mod b/test/e2e/test_suites/test_data/add_with_path_2/kcl.mod new file mode 100644 index 00000000..70b785cf --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_path_2/kcl.mod @@ -0,0 +1,5 @@ +[package] +name = "add_with_path_2" +edition = "v0.8.0" +version = "0.0.1" + diff --git a/test/e2e/test_suites/test_data/add_with_path_2/kcl.mod.lock b/test/e2e/test_suites/test_data/add_with_path_2/kcl.mod.lock new file mode 100644 index 00000000..e69de29b diff --git a/test/e2e/test_suites/test_data/add_with_path_2/main.k b/test/e2e/test_suites/test_data/add_with_path_2/main.k new file mode 100644 index 00000000..fa7048e6 --- /dev/null +++ b/test/e2e/test_suites/test_data/add_with_path_2/main.k @@ -0,0 +1 @@ +The_first_kcl_program = 'Hello World!' \ No newline at end of file diff --git a/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod b/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod index 038f808a..c0cdbd8e 100644 --- a/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod +++ b/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod @@ -3,3 +3,5 @@ name = "test_add_with_name" edition = "v0.9.0" version = "0.0.1" +[dependencies] +k8s = { oci = "oci://localhost:5001/test/k8s", tag = "1.27" } diff --git a/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod.lock b/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod.lock index e69de29b..7ca1df46 100644 --- a/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_add_with_name/kcl.mod.lock @@ -0,0 +1,9 @@ +[dependencies] + [dependencies.k8s] + name = "k8s" + full_name = "k8s_1.27" + version = "1.27" + sum = "xnYM1FWHAy3m+KcQMQb2rjZouTxumqYt6FGZpu2T4yM=" + reg = "localhost:5001" + repo = "test/k8s" + oci_tag = "1.27" diff --git a/test/e2e/test_suites/test_data/test_kcl/kcl.mod.lock b/test/e2e/test_suites/test_data/test_kcl/kcl.mod.lock index 740082e4..9e9d1809 100644 --- a/test/e2e/test_suites/test_data/test_kcl/kcl.mod.lock +++ b/test/e2e/test_suites/test_data/test_kcl/kcl.mod.lock @@ -1,8 +1,7 @@ [dependencies] [dependencies.kcl4] name = "kcl4" - full_name = "kcl4_v0.1.0" - version = "v0.1.0" - sum = "ecdMCD96+8by5Ml0l/V0b7W24CS250rvD5VdlqqR6OU=" + full_name = "kcl4_0.0.1" + version = "0.0.1" url = "https://github.com/zong-zhe/kcl4.git" - git_tag = "v0.1.0" \ No newline at end of file + git_tag = "v0.1.0" 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 f3cb9dcb..934b8b7d 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 @@ -1,9 +1,9 @@ [dependencies] [dependencies.dep-with-line] name = "dep-with-line" - full_name = "dep-with-line_" - sum = "0lzH5VUC9/wM60EnksK/9Oc3/alBezWkElgGM1l0938=" + full_name = "dep-with-line_0.0.1" + version = "0.0.1" [dependencies.dep_with-line] name = "dep_with-line" - full_name = "dep_with-line_" - sum = "hiIX1252Xn0QvmGlLhuM5ZsuuV8EpY/fuCgcRKLk3iE=" + full_name = "dep_with-line_0.0.1" + version = "0.0.1" 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 b047f2b6..58919f2d 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 @@ -3,4 +3,8 @@ name = "pkg2" full_name = "pkg2_0.0.1" version = "0.0.1" - sum = "JbfIAXPJb3L6xX7hi/A5mrXzjpB8eFoKfEmJMdHsewY=" + [dependencies.pkg3] + name = "pkg3" + full_name = "pkg3_0.0.1" + version = "0.0.1" + sum = "T29gAv6K/tLithhP5jVHyurV5zRFui+i1ulyMt/ncnM=" 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 73317ff3..d8345ec0 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] -helloworld = "0.1.1" +helloworld = "0.1.2" 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 08c061f8..863b0083 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 @@ -17,4 +17,4 @@ [dependencies.test_update_1] name = "test_update_1" full_name = "test_update_1_" - sum = "PYLgSMWbY5vCU2cyK+hOkZeb0Rp7JW055b0RMQaQ4S8=" + sum = "PYLgSMWbY5vCU2cyK+hOkZeb0Rp7JW055b0RMQaQ4S8=" \ No newline at end of file