mirror of https://github.com/databricks/cli.git
Updating messages
This commit is contained in:
parent
d86fb3b88e
commit
b624ce999a
|
@ -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.Mode == config.Production {
|
||||||
if b.Config.Bundle.ClusterId != "" {
|
if b.Config.Bundle.ClusterId != "" {
|
||||||
// Overriding compute via a command-line flag for production works, but is not recommended.
|
// 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 != "" {
|
if v := env.Get(ctx, "DATABRICKS_CLUSTER_ID"); v != "" {
|
||||||
// For historical reasons, we allow setting the cluster ID via the DATABRICKS_CLUSTER_ID
|
// 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.
|
// when development mode is used. Sometimes, this is done by accident, so we log an info message.
|
||||||
if b.Config.Bundle.Mode == config.Development {
|
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 {
|
} else {
|
||||||
// We don't allow using DATABRICKS_CLUSTER_ID in any other mode, it's too error-prone.
|
// 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'")
|
return diag.Warningf("The DATABRICKS_CLUSTER_ID variable is set but is ignored since the current target does not use 'mode: development'")
|
||||||
|
|
|
@ -172,7 +172,7 @@ func TestOverrideComputeModeProduction(t *testing.T) {
|
||||||
m := mutator.OverrideCompute()
|
m := mutator.OverrideCompute()
|
||||||
diags := bundle.Apply(context.Background(), b, m)
|
diags := bundle.Apply(context.Background(), b, m)
|
||||||
require.Len(t, diags, 1)
|
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)
|
assert.Equal(t, "newClusterID", b.Config.Resources.Jobs["job1"].Tasks[0].ExistingClusterId)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue