Skip to content

Commit

Permalink
feat: the checksum calculation during compilation is removed
Browse files Browse the repository at this point in the history
Signed-off-by: zongz <[email protected]>
  • Loading branch information
zong-zhe committed May 23, 2024
1 parent 0b0b423 commit 0195cb7
Show file tree
Hide file tree
Showing 104 changed files with 485 additions and 417 deletions.
2 changes: 1 addition & 1 deletion pkg/api/kpm_pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (pkg *KclPackage) UpdateDependencyInPath(pkg_path string) error {
if err != nil {
return err
}
return kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
return kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
}

// GetPkgName returns the name of the package.
Expand Down
13 changes: 6 additions & 7 deletions pkg/api/kpm_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func TestPackageApi(t *testing.T) {
assert.Equal(t, err, nil)
pkg, err := GetKclPackage(pkg_path)
assert.Equal(t, err, nil)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
assert.Equal(t, err, nil)
assert.Equal(t, pkg.GetPkgName(), "kcl_pkg")
assert.Equal(t, pkg.GetVersion(), "0.0.1")
Expand All @@ -29,12 +29,11 @@ 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")

assert.Equal(t, dep.GetLocalFullPath(""), filepath.Join(kcl_pkg_path, "k8s_1.27"))
assert.Equal(t, dep.GetLocalFullPath(), filepath.Join(kcl_pkg_path, "k8s_1.27"))

schemas, err := pkg.GetAllSchemaTypeMapping()
assert.Equal(t, err, nil)
Expand Down Expand Up @@ -80,7 +79,7 @@ func TestGetAllSchemaTypesMappingNamed(t *testing.T) {
kpmcli, err := client.NewKpmClient()
assert.Equal(t, err, nil)

err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
assert.Equal(t, err, nil)

schemas, err := pkg.GetSchemaTypeMappingNamed("SchemaWithSameName")
Expand All @@ -104,7 +103,7 @@ func TestGetSchemaTypeMappingWithFilters(t *testing.T) {
assert.Equal(t, err, nil)
kpmcli, err := client.NewKpmClient()
assert.Equal(t, err, nil)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
assert.Equal(t, err, nil)

filterFunc := func(kt *KclType) bool {
Expand Down Expand Up @@ -155,7 +154,7 @@ func TestGetFullSchemaTypeMappingWithFilters(t *testing.T) {
assert.Equal(t, err, nil)
kpmcli, err := client.NewKpmClient()
assert.Equal(t, err, nil)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
assert.Equal(t, err, nil)

filterFunc := func(kt *KclType) bool {
Expand All @@ -176,7 +175,7 @@ func TestGetSchemaTypeUnderEmptyDir(t *testing.T) {
assert.Equal(t, err, nil)
kpmcli, err := client.NewKpmClient()
assert.Equal(t, err, nil)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, true)
err = kpmcli.ResolvePkgDepsMetadata(pkg.pkg, &pkg.pkg.Dependencies, true)
assert.Equal(t, err, nil)
schemas, err := pkg.GetSchemaTypeMappingNamed("SchemaInMain")
assert.Equal(t, err, nil)
Expand Down
3 changes: 1 addition & 2 deletions pkg/api/kpm_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
37 changes: 17 additions & 20 deletions pkg/api/test_data/test_run_pkg_in_path/expected
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkg/api/test_data/test_run_pkg_in_path/expected.json
Original file line number Diff line number Diff line change
@@ -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}]}]}}}}}
{"a":{"containers":{"flaskdemo":{"image":"kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe","ports":[{"containerPort":5000,"protocol":"TCP"}]}},"labels":{"app":"flask-demo"},"name":"flask-demo","replicas":1,"service":{"ports":[{"port":5000,"protocol":"TCP","targetPort":5000}],"type":"NodePort"}}}
2 changes: 1 addition & 1 deletion pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
13 changes: 6 additions & 7 deletions pkg/api/test_data/test_run_pkg_in_path/test_kcl/kcl.mod.lock
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions pkg/api/test_data/test_run_pkg_in_path/test_kcl/main.k
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import konfig.base.examples.native.nginx_deployment as nd
import flask_demo_kcl_manifests as flask

demo = nd.demo
a = flask.config
37 changes: 17 additions & 20 deletions pkg/api/test_data/test_run_tar_in_path/expected
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion pkg/api/test_data/test_run_tar_in_path/expected.json
Original file line number Diff line number Diff line change
@@ -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}]}]}}}}}
{"a":{"containers":{"flaskdemo":{"image":"kcllang/flask_demo:8d31498e765ff67a2fa9933d4adffe067544b2fe","ports":[{"containerPort":5000,"protocol":"TCP"}]}},"labels":{"app":"flask-demo"},"name":"flask-demo","replicas":1,"service":{"ports":[{"port":5000,"protocol":"TCP","targetPort":5000}],"type":"NodePort"}}}
Binary file modified pkg/api/test_data/test_run_tar_in_path/test.tar
Binary file not shown.
Loading

0 comments on commit 0195cb7

Please sign in to comment.