mirror of https://github.com/databricks/cli.git
Refine `mode: production` diagnostic output (#2236)
## Changes This refines the `mode: production` diagnostic output now that the `Detail` property is rendered as output. This is a follow-up to https://github.com/databricks/cli/pull/1712.
This commit is contained in:
parent
f99716b0a5
commit
6e18d94264
|
@ -144,8 +144,11 @@ func validateProductionMode(ctx context.Context, b *bundle.Bundle, isPrincipalUs
|
|||
|
||||
// We need to verify that there is only a single deployment of the current target.
|
||||
// The best way to enforce this is to explicitly set root_path.
|
||||
advice := fmt.Sprintf(
|
||||
"set 'workspace.root_path' to make sure only one copy is deployed. A common practice is to use a username or principal name in this path, i.e. root_path: /Workspace/Users/%s/.bundle/${bundle.name}/${bundle.target}",
|
||||
advice := "set 'workspace.root_path' to make sure only one copy is deployed"
|
||||
adviceDetail := fmt.Sprintf(
|
||||
"A common practice is to use a username or principal name in this path, i.e. use\n"+
|
||||
"\n"+
|
||||
" root_path: /Workspace/Users/%s/.bundle/${bundle.name}/${bundle.target}",
|
||||
b.Config.Workspace.CurrentUser.UserName,
|
||||
)
|
||||
if !isExplicitRootSet(b) {
|
||||
|
@ -154,9 +157,21 @@ func validateProductionMode(ctx context.Context, b *bundle.Bundle, isPrincipalUs
|
|||
// and neither is setting a principal.
|
||||
// We only show a warning for these cases since we didn't historically
|
||||
// report an error for them.
|
||||
return diag.Recommendationf("target with 'mode: production' should %s", advice)
|
||||
return diag.Diagnostics{
|
||||
{
|
||||
Severity: diag.Recommendation,
|
||||
Summary: "target with 'mode: production' should " + advice,
|
||||
Detail: adviceDetail,
|
||||
},
|
||||
}
|
||||
}
|
||||
return diag.Diagnostics{
|
||||
{
|
||||
Severity: diag.Error,
|
||||
Summary: "target with 'mode: production' must " + advice,
|
||||
Detail: adviceDetail,
|
||||
},
|
||||
}
|
||||
return diag.Errorf("target with 'mode: production' must %s", advice)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -329,7 +329,7 @@ func TestProcessTargetModeProduction(t *testing.T) {
|
|||
b := mockBundle(config.Production)
|
||||
|
||||
diags := validateProductionMode(context.Background(), b, false)
|
||||
require.ErrorContains(t, diags.Error(), "target with 'mode: production' must set 'workspace.root_path' to make sure only one copy is deployed. A common practice is to use a username or principal name in this path, i.e. root_path: /Workspace/Users/lennart@company.com/.bundle/${bundle.name}/${bundle.target}")
|
||||
assert.ErrorContains(t, diags.Error(), "A common practice is to use a username or principal name in this path, i.e. use\n\n root_path: /Workspace/Users/lennart@company.com/.bundle/${bundle.name}/${bundle.target}")
|
||||
|
||||
b.Config.Workspace.StatePath = "/Shared/.bundle/x/y/state"
|
||||
b.Config.Workspace.ArtifactPath = "/Shared/.bundle/x/y/artifacts"
|
||||
|
@ -337,7 +337,7 @@ func TestProcessTargetModeProduction(t *testing.T) {
|
|||
b.Config.Workspace.ResourcePath = "/Shared/.bundle/x/y/resources"
|
||||
|
||||
diags = validateProductionMode(context.Background(), b, false)
|
||||
require.ErrorContains(t, diags.Error(), "target with 'mode: production' must set 'workspace.root_path' to make sure only one copy is deployed. A common practice is to use a username or principal name in this path, i.e. root_path: /Workspace/Users/lennart@company.com/.bundle/${bundle.name}/${bundle.target}")
|
||||
assert.ErrorContains(t, diags.Error(), "A common practice is to use a username or principal name in this path, i.e. use\n\n root_path: /Workspace/Users/lennart@company.com/.bundle/${bundle.name}/${bundle.target}")
|
||||
|
||||
permissions := []resources.Permission{
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue