From c049d701d9820d1d4c34ed0a0e419ac355869161 Mon Sep 17 00:00:00 2001 From: Grigory Panov Date: Tue, 1 Sep 2026 18:18:08 +0200 Subject: [PATCH] Deprecate setup-local --constraints-only in favour of --no-dbconnect *Why* `databricks environments setup-local` now has the orthogonal `--no-dbconnect` flag, which skips the databricks-connect dependency with identical behaviour to the older `--constraints-only`. Keeping two visible spellings for one behaviour is confusing, but `--constraints-only` may already live in users' scripts and CI, so it cannot simply be removed. *What* Mark `--constraints-only` deprecated via cobra's `MarkDeprecated`, which hides it from `--help` and prints a one-line stderr notice ("Flag --constraints-only has been deprecated, use --no-dbconnect instead") once per run when it is used. The flag stays defined and its behaviour is unchanged, so existing callers keep working; actual removal is a separate, later step. Adds a changelog fragment. *Verification* - New unit test asserts the flag stays defined but hidden with the deprecation notice. - Regenerated acceptance goldens: `--constraints-only` dropped from the `help` listing; the `constraints-only` and `constraints-only-existing` runs now show the stderr deprecation line (stdout JSON unchanged, schemaVersion still 1). - `gofmt`, `go vet ./cmd/environments`, `go test ./cmd/environments`, and `go build ./...` all clean. Co-authored-by: Isaac --- .../setup-local-deprecate-constraints-only.md | 1 + .../constraints-only-existing/output.txt | 1 + .../localenv/constraints-only/output.txt | 1 + acceptance/localenv/help/output.txt | 1 - cmd/environments/sync.go | 5 +++++ cmd/environments/sync_test.go | 21 +++++++++++++++++++ 6 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .nextchanges/cli/setup-local-deprecate-constraints-only.md create mode 100644 cmd/environments/sync_test.go diff --git a/.nextchanges/cli/setup-local-deprecate-constraints-only.md b/.nextchanges/cli/setup-local-deprecate-constraints-only.md new file mode 100644 index 00000000000..c76e0e80ac2 --- /dev/null +++ b/.nextchanges/cli/setup-local-deprecate-constraints-only.md @@ -0,0 +1 @@ +Deprecated the `databricks environments setup-local --constraints-only` flag in favour of the orthogonal `--no-dbconnect`. The flag still works (it remains a hidden alias with identical behaviour) but is hidden from `--help` and now prints a one-line deprecation notice; it will be removed in a later release. diff --git a/acceptance/localenv/constraints-only-existing/output.txt b/acceptance/localenv/constraints-only-existing/output.txt index 365bc747bdc..68d94ccc50e 100644 --- a/acceptance/localenv/constraints-only-existing/output.txt +++ b/acceptance/localenv/constraints-only-existing/output.txt @@ -1,5 +1,6 @@ >>> [CLI] environments setup-local --serverless-version 4 --constraints-only --dry-run --output json +Flag --constraints-only has been deprecated, use --no-dbconnect instead { "schemaVersion": 1, "command": "environments setup-local", diff --git a/acceptance/localenv/constraints-only/output.txt b/acceptance/localenv/constraints-only/output.txt index 7fb5072d708..efcd88fd74e 100644 --- a/acceptance/localenv/constraints-only/output.txt +++ b/acceptance/localenv/constraints-only/output.txt @@ -1,5 +1,6 @@ >>> [CLI] environments setup-local --serverless-version 4 --constraints-only --dry-run --output json +Flag --constraints-only has been deprecated, use --no-dbconnect instead { "schemaVersion": 1, "command": "environments setup-local", diff --git a/acceptance/localenv/help/output.txt b/acceptance/localenv/help/output.txt index 7d455e00d42..b3831ec2384 100644 --- a/acceptance/localenv/help/output.txt +++ b/acceptance/localenv/help/output.txt @@ -18,7 +18,6 @@ Examples: Flags: --cluster-id string cluster ID to use as the compute target --cluster-name string cluster name to use as the compute target (resolved to an ID via the Clusters API) - --constraints-only apply the Python version and constraints without adding the databricks-connect dependency --dry-run compute the plan without writing files or provisioning -h, --help help for setup-local --job-task string job task to use as the compute target, as . (the task key is required) diff --git a/cmd/environments/sync.go b/cmd/environments/sync.go index b7c6935c460..6db6c0e3d4c 100644 --- a/cmd/environments/sync.go +++ b/cmd/environments/sync.go @@ -60,6 +60,11 @@ func addComputeFlags(cmd *cobra.Command) { cmd.Flags().String("serverless-version", "", "serverless version to use as the compute target (e.g. 5)") cmd.Flags().String("job-task", "", "job task to use as the compute target, as . (the task key is required)") cmd.Flags().Bool("constraints-only", false, "apply the Python version and constraints without adding the databricks-connect dependency") + // --constraints-only is superseded by the orthogonal --no-dbconnect (identical + // behaviour). Keep it defined so existing scripts and CI keep working, but hide + // it from --help and emit a one-line deprecation notice on stderr when it is + // used. MarkDeprecated does both; removal is a separate, later step. + cmd.Flags().MarkDeprecated("constraints-only", "use --no-dbconnect instead") // The negative flags (--no-constraints, --no-dbconnect, --no-provision) are // orthogonal and compose. --no-dbconnect and the older --constraints-only are // equivalent (both skip the databricks-connect dependency). diff --git a/cmd/environments/sync_test.go b/cmd/environments/sync_test.go new file mode 100644 index 00000000000..4c84c898090 --- /dev/null +++ b/cmd/environments/sync_test.go @@ -0,0 +1,21 @@ +package environments + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestSetupLocalConstraintsOnlyDeprecated pins --constraints-only as a hidden, +// deprecated alias for --no-dbconnect: the flag is kept defined so scripts and CI +// that already pass it keep working, but it is hidden from --help and pflag prints +// a one-line deprecation notice pointing at --no-dbconnect when it is used. +func TestSetupLocalConstraintsOnlyDeprecated(t *testing.T) { + cmd := newSetupLocalCommand() + + f := cmd.Flags().Lookup("constraints-only") + require.NotNil(t, f, "--constraints-only must remain defined for backward compatibility") + assert.True(t, f.Hidden, "--constraints-only should be hidden from --help") + assert.Equal(t, "use --no-dbconnect instead", f.Deprecated, "--constraints-only should carry the deprecation notice") +}