diff --git a/go.mod b/go.mod index 940d351e..05c1ecc4 100644 --- a/go.mod +++ b/go.mod @@ -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 ( @@ -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 @@ -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 ( diff --git a/go.sum b/go.sum index 8ffc1773..0b6f51c2 100644 --- a/go.sum +++ b/go.sum @@ -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= @@ -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= diff --git a/pkg/api/kpm_run.go b/pkg/api/kpm_run.go index ad3a40c7..5b2c29ad 100644 --- a/pkg/api/kpm_run.go +++ b/pkg/api/kpm_run.go @@ -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())) diff --git a/pkg/api/kpm_run_test.go b/pkg/api/kpm_run_test.go index d64d3f15..ac77eeb2 100644 --- a/pkg/api/kpm_run_test.go +++ b/pkg/api/kpm_run_test.go @@ -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")) diff --git a/pkg/api/test_data/test_settings/kcl.yaml b/pkg/api/test_data/test_settings/kcl.yaml new file mode 100644 index 00000000..d61e8904 --- /dev/null +++ b/pkg/api/test_data/test_settings/kcl.yaml @@ -0,0 +1,3 @@ +kcl_cli_configs: + files: + - ./test.k diff --git a/pkg/api/test_data/test_settings/test.k b/pkg/api/test_data/test_settings/test.k new file mode 100644 index 00000000..0a979d4e --- /dev/null +++ b/pkg/api/test_data/test_settings/test.k @@ -0,0 +1 @@ +value = 1