Skip to content

Commit

Permalink
fix: settings options without entry features in the run with opt API.
Browse files Browse the repository at this point in the history
Signed-off-by: peefy <[email protected]>
  • Loading branch information
Peefy committed Nov 1, 2023
1 parent 55b49ae commit d19a2aa
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 14 deletions.
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ go 1.19

require (
github.com/BurntSushi/toml v1.2.1
github.com/docker/distribution v2.8.1+incompatible
github.com/docker/distribution v2.8.2+incompatible
github.com/opencontainers/image-spec v1.1.0-rc4
github.com/otiai10/copy v1.9.0
github.com/sirupsen/logrus v1.9.0
github.com/urfave/cli/v2 v2.25.0
gotest.tools/v3 v3.4.0
kcl-lang.io/kcl-go v0.6.1
kcl-lang.io/kcl-go v0.7.0-alpha.1.0.20231031031432-25d679a46c78
)

require (
Expand All @@ -30,7 +30,7 @@ require (
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/cli v23.0.1+incompatible // indirect
github.com/docker/docker v23.0.1+incompatible // indirect
github.com/docker/docker v23.0.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.7.0 // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-metrics v0.0.1 // indirect
Expand Down Expand Up @@ -91,7 +91,7 @@ require (
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
kcl-lang.io/kcl-artifact-go v0.6.0 // indirect
kcl-lang.io/kcl-artifact-go v0.7.0-alpha.1 // indirect
)

require (
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/distribution/distribution/v3 v3.0.0-20221208165359-362910506bc2 h1:aBfCb7iqHmDEIp6fBvC/hQUddQfg+3qdYjwzaiP9Hnc=
github.com/docker/cli v23.0.1+incompatible h1:LRyWITpGzl2C9e9uGxzisptnxAn1zfZKXy13Ul2Q5oM=
github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8=
github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68=
github.com/docker/distribution v2.8.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v23.0.1+incompatible h1:vjgvJZxprTTE1A37nm+CLNAdwu6xZekyoiVlUZEINcY=
github.com/docker/docker v23.0.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/distribution v2.8.2+incompatible h1:T3de5rq0dB1j30rp0sA2rER+m322EBzniBPB6ZIzuh8=
github.com/docker/distribution v2.8.2+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
github.com/docker/docker v23.0.3+incompatible h1:9GhVsShNWz1hO//9BNg/dpMnZW25KydO4wtVxWAIbho=
github.com/docker/docker v23.0.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker-credential-helpers v0.7.0 h1:xtCHsjxogADNZcdv1pKUHXryefjlVRqWqIhk/uXJp0A=
github.com/docker/docker-credential-helpers v0.7.0/go.mod h1:rETQfLdHNT3foU5kuNkFR1R1V12OJRRO5lzt2D1b5X0=
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
Expand Down Expand Up @@ -763,10 +763,10 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
kcl-lang.io/kcl-artifact-go v0.6.0 h1:J/1FKzgGRqzFDkq0amBWxCdXXRMrtg5oT3IGtoo9sgU=
kcl-lang.io/kcl-artifact-go v0.6.0/go.mod h1:c07mqi9Hu2UjPW7lYfHhAAWOlZiB7lo7Vkr4jL5ov/M=
kcl-lang.io/kcl-go v0.6.1 h1:we/e3qvllsOoQj0YQht+yNxI+QFLWEmYn4FQ3zAvv9E=
kcl-lang.io/kcl-go v0.6.1/go.mod h1:1/xEscOhVGNabr9+rYC5peFDIjphbthYqk8UyHzaPRk=
kcl-lang.io/kcl-artifact-go v0.7.0-alpha.1 h1:b9EPI/JBeR7cB/cViVXHaKfKpTbMKqRAtXNlePjswsk=
kcl-lang.io/kcl-artifact-go v0.7.0-alpha.1/go.mod h1:c07mqi9Hu2UjPW7lYfHhAAWOlZiB7lo7Vkr4jL5ov/M=
kcl-lang.io/kcl-go v0.7.0-alpha.1.0.20231031031432-25d679a46c78 h1:uvXbJL230YqW8BHPAyq6MMxaa6QXQEqYbH74YAjkMIQ=
kcl-lang.io/kcl-go v0.7.0-alpha.1.0.20231031031432-25d679a46c78/go.mod h1:71orQfLXck+KxhKs/OJE8pCtWN3x1M29AMYQnUctIKs=
oras.land/oras-go v1.2.3 h1:v8PJl+gEAntI1pJ/LCrDgsuk+1PKVavVEPsYIHFE5uY=
oras.land/oras-go v1.2.3/go.mod h1:M/uaPdYklze0Vf3AakfarnpoEckvw0ESbRdN8Z1vdJg=
oras.land/oras-go/v2 v2.3.0 h1:lqX1aXdN+DAmDTKjiDyvq85cIaI4RkIKp/PghWlAGIU=
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/kpm_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ func RunWithOpt(opts *opt.CompileOptions) (*kcl.KCLResultList, error) {
opts.Merge(kcl.WithKFilenames(filepath.Join(opts.PkgPath(), entry)))
}
}
} else {
// no entry
} else if !opts.HasSettingsYaml() && len(opts.KFilenameList) == 0 {
// If no entry, no kcl files and no settings files.
opts.Merge(kcl.WithKFilenames(opts.PkgPath()))
}
opts.Merge(kcl.WithWorkDir(opts.PkgPath()))
Expand Down
9 changes: 9 additions & 0 deletions pkg/api/kpm_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ func TestRunWithOpts(t *testing.T) {
assert.Equal(t, utils.RmNewline(string(result.GetRawJsonResult())), utils.RmNewline(string(expectedJson)))
}

func TestRunWithSettingsOpts(t *testing.T) {
pkgPath := getTestDir("test_settings")
opts := opt.DefaultCompileOptions()
opts.Merge(kcl.WithSettings(filepath.Join(pkgPath, "kcl.yaml")))
opts.SetHasSettingsYaml(true)
_, err := RunWithOpt(opts)
assert.Equal(t, err, nil)
}

func TestRunTarPkg(t *testing.T) {
pkgPath := getTestDir("test_run_tar_in_path")
tarPath, _ := filepath.Abs(filepath.Join(pkgPath, "test.tar"))
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/test_data/test_settings/kcl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kcl_cli_configs:
files:
- ./test.k
1 change: 1 addition & 0 deletions pkg/api/test_data/test_settings/test.k
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
value = 1

0 comments on commit d19a2aa

Please sign in to comment.