Updating messages

This commit is contained in:
Lennart Kats 2024-12-04 21:06:22 +01:00
parent d86fb3b88e
commit b624ce999a
No known key found for this signature in database
GPG Key ID: 1EB8B57673197023
2 changed files with 6 additions and 3 deletions

View File

@ -44,14 +44,17 @@ func (m *overrideCompute) Apply(ctx context.Context, b *bundle.Bundle) diag.Diag
if b.Config.Bundle.Mode == config.Production {
if b.Config.Bundle.ClusterId != "" {
// Overriding compute via a command-line flag for production works, but is not recommended.
diags = diags.Extend(diag.Warningf("Overriding compute for a target that uses 'mode: production' is not recommended"))
diags = diags.Extend(diag.Diagnostics{{
Summary: "Setting a cluster override for a target that uses 'mode: production' is not recommended",
Detail: "It is recommended to always use the same compute for production target for consistency.",
}})
}
}
if v := env.Get(ctx, "DATABRICKS_CLUSTER_ID"); v != "" {
// For historical reasons, we allow setting the cluster ID via the DATABRICKS_CLUSTER_ID
// when development mode is used. Sometimes, this is done by accident, so we log an info message.
if b.Config.Bundle.Mode == config.Development {
cmdio.LogString(ctx, "Overriding compute because DATABRICKS_CLUSTER_ID is set. It is recommended to use --cluster-id instead, which works in any target mode.")
cmdio.LogString(ctx, "Setting a cluster override because DATABRICKS_CLUSTER_ID is set. It is recommended to use --cluster-id instead, which works in any target mode.")
} else {
// We don't allow using DATABRICKS_CLUSTER_ID in any other mode, it's too error-prone.
return diag.Warningf("The DATABRICKS_CLUSTER_ID variable is set but is ignored since the current target does not use 'mode: development'")

View File

@ -172,7 +172,7 @@ func TestOverrideComputeModeProduction(t *testing.T) {
m := mutator.OverrideCompute()
diags := bundle.Apply(context.Background(), b, m)
require.Len(t, diags, 1)
assert.Equal(t, "Overriding compute for a target that uses 'mode: production' is not recommended", diags[0].Summary)
assert.Equal(t, "Setting a cluster override for a target that uses 'mode: production' is not recommended", diags[0].Summary)
assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)
}