diff --git a/cmd/cue/cmd/testdata/script/def_proto.txtar b/cmd/cue/cmd/testdata/script/def_proto.txtar index c5f207334c0..b57c4ce7724 100644 --- a/cmd/cue/cmd/testdata/script/def_proto.txtar +++ b/cmd/cue/cmd/testdata/script/def_proto.txtar @@ -1,7 +1,3 @@ -env CUE_EXPERIMENT=modules=0 -exec cue def policy.proto -p api -I include -cmp stdout expect-stdout - env CUE_EXPERIMENT=modules exec cue def policy.proto -p api -I include cmp stdout expect-stdout diff --git a/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar b/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar index 7e0bb3da699..d51926b5ef9 100644 --- a/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_majorversion.txtar @@ -1,14 +1,10 @@ env-fill want-module.cue env-fill want-module-experiment.cue -# Without the experiment, the major version is allowed, -# even though it's not particularly useful. -# It feels unnecessary to ask the user to re-run with the experiment. +# No way of disabling the modules experiment. env CUE_EXPERIMENT=modules=0 -exec cue mod init foo.com/bar@v1 -cmp cue.mod/module.cue want-module.cue -exists cue.mod/usr -exists cue.mod/pkg +! exec cue mod init foo.com/bar@v1 +stderr 'cannot change default value of deprecated flag "modules"' # With the experiment, it works as expected. env CUE_EXPERIMENT=modules diff --git a/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar b/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar index 04fc4fe8774..11ddb51638d 100644 --- a/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar +++ b/cmd/cue/cmd/testdata/script/modinit_nomajorversion.txtar @@ -1,12 +1,10 @@ env-fill want-module.cue env-fill want-module-experiment.cue -# Without the experiment, we use the module path as-is. -env CUE_EXPERIMENT=modules=false -exec cue mod init foo.com/bar -cmp cue.mod/module.cue want-module.cue -exists cue.mod/usr -exists cue.mod/pkg +# No way of disabling the modules experiment. +env CUE_EXPERIMENT=modules=0 +! exec cue mod init foo.com/bar +stderr 'cannot change default value of deprecated flag "modules"' # With the experiment, although the major version will be implied # as v0, it's still omitted so that there's a possibility of compatibility diff --git a/cmd/cue/cmd/testdata/script/modpublish_registry_not_enabled.txtar b/cmd/cue/cmd/testdata/script/modpublish_registry_not_enabled.txtar index d75d45a6c62..6dd990e89b1 100644 --- a/cmd/cue/cmd/testdata/script/modpublish_registry_not_enabled.txtar +++ b/cmd/cue/cmd/testdata/script/modpublish_registry_not_enabled.txtar @@ -2,4 +2,4 @@ env CUE_EXPERIMENT=modules=false ! exec cue mod publish v1.0.0 cmp stderr want-stderr -- want-stderr -- -modules experiment not enabled (enable with CUE_EXPERIMENT=modules) +cannot parse CUE_EXPERIMENT: cannot change default value of deprecated flag "modules" diff --git a/cmd/cue/cmd/testdata/script/modtidy_registry_not_enabled.txtar b/cmd/cue/cmd/testdata/script/modtidy_registry_not_enabled.txtar index 6df187a4c97..ee508276eea 100644 --- a/cmd/cue/cmd/testdata/script/modtidy_registry_not_enabled.txtar +++ b/cmd/cue/cmd/testdata/script/modtidy_registry_not_enabled.txtar @@ -3,4 +3,4 @@ env CUE_EXPERIMENT=modules=0 ! exec cue mod tidy cmp stderr want-stderr -- want-stderr -- -modules experiment not enabled (enable with CUE_EXPERIMENT=modules) +cannot parse CUE_EXPERIMENT: cannot change default value of deprecated flag "modules" diff --git a/cmd/cue/cmd/testdata/script/registry_modules_disabled.txtar b/cmd/cue/cmd/testdata/script/registry_modules_disabled.txtar index 1db0c773fd3..9dcf8892e83 100644 --- a/cmd/cue/cmd/testdata/script/registry_modules_disabled.txtar +++ b/cmd/cue/cmd/testdata/script/registry_modules_disabled.txtar @@ -1,35 +1,5 @@ -# When CUE_EXPERIMENT is disabled, the CUE_REGISTRY -# variable is ignored, as are the new fields in module.cue +# When CUE_EXPERIMENT is disabled, we cannot use the cue command. env CUE_EXPERIMENT=modules=false -exec cue export . -cmp stdout expect-stdout - --- expect-stdout -- -"cue.mod/pkg source" --- main.cue -- -package main -import "example.com/e" - -e.foo - --- cue.mod/module.cue -- -module: "test.org" -language: version: "v0.9.0" -// This should be ignored. -deps: "example.com/e": v: "v0.0.1" --- cue.mod/pkg/example.com/e/cue.mod/module.cue -- -module: "example.com/e" -language: version: "v0.8.0" --- cue.mod/pkg/example.com/e/main.cue -- -package e -foo: "cue.mod/pkg source" - --- _registry/example.com_e_v0.0.1/cue.mod/module.cue -- -module: "example.com/e@v0" -language: version: "v0.8.0" - --- _registry/example.com_e_v0.0.1/main.cue -- -package e - -foo: "registry source" +! exec cue export . +stderr 'cannot change default value of deprecated flag "modules"' diff --git a/cmd/cue/cmd/testdata/script/registry_modules_disabled_warning.txtar b/cmd/cue/cmd/testdata/script/registry_modules_disabled_warning.txtar deleted file mode 100644 index 07d8b037999..00000000000 --- a/cmd/cue/cmd/testdata/script/registry_modules_disabled_warning.txtar +++ /dev/null @@ -1,14 +0,0 @@ -env CUE_EXPERIMENT=modules=false -env CUE_REGISTRY=ignored.example.com -exec cue export . -cmp stdout expect-stdout -cmp stderr expect-stderr - --- expect-stdout -- -"ok" --- expect-stderr -- -warning: ignoring CUE_REGISTRY because modules experiment is not enabled. Set CUE_EXPERIMENT=modules to enable it. --- main.cue -- -package main - -"ok" diff --git a/internal/cueexperiment/exp.go b/internal/cueexperiment/exp.go index 535a636ad77..698bf79d11e 100644 --- a/internal/cueexperiment/exp.go +++ b/internal/cueexperiment/exp.go @@ -11,7 +11,7 @@ import ( // When adding, deleting, or modifying entries below, // update cmd/cue/cmd/help.go as well for `cue help environment`. var Flags struct { - Modules bool `envflag:"default:true"` + Modules bool `envflag:"deprecated,default:true"` // YAMLV3Decoder swaps the old internal/third_party/yaml decoder with the new // decoder implemented in internal/encoding/yaml on top of yaml.v3. diff --git a/internal/cueexperiment/exp_test.go b/internal/cueexperiment/exp_test.go index ff4e390709b..e2e4b0a3148 100644 --- a/internal/cueexperiment/exp_test.go +++ b/internal/cueexperiment/exp_test.go @@ -23,10 +23,15 @@ func TestInit(t *testing.T) { qt.Assert(t, qt.IsTrue(Flags.Modules)) qt.Assert(t, qt.IsTrue(Flags.YAMLV3Decoder)) - // Check that we can disable all experiments. - t.Setenv("CUE_EXPERIMENT", "modules=0,yamlv3decoder=0") + // Check that we can disable the YAML v3 experiment. + t.Setenv("CUE_EXPERIMENT", "yamlv3decoder=0") err = initAlways() qt.Assert(t, qt.IsNil(err)) - qt.Assert(t, qt.IsFalse(Flags.Modules)) + qt.Assert(t, qt.IsTrue(Flags.Modules)) qt.Assert(t, qt.IsFalse(Flags.YAMLV3Decoder)) + + // Check that we cannot disable the modules experiment. + t.Setenv("CUE_EXPERIMENT", "modules=0") + err = initAlways() + qt.Assert(t, qt.ErrorMatches(err, `cannot parse CUE_EXPERIMENT: cannot change default value of deprecated flag "modules"`)) }