mirror of https://github.com/databricks/cli.git
Add nil check
This commit is contained in:
parent
2dad625b84
commit
821239e45d
|
@ -158,6 +158,9 @@ func isRunAsSet(r config.Resources) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func isExplicitRootSet(b *bundle.Bundle) bool {
|
func isExplicitRootSet(b *bundle.Bundle) bool {
|
||||||
|
if b.Config.Targets == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
targetConfig := b.Config.Targets[b.Config.Bundle.Target]
|
targetConfig := b.Config.Targets[b.Config.Bundle.Target]
|
||||||
if targetConfig.Workspace == nil {
|
if targetConfig.Workspace == nil {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -32,10 +32,7 @@ func mockBundle(mode config.Mode) *bundle.Bundle {
|
||||||
Branch: "main",
|
Branch: "main",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Targets: map[string]*config.Target{
|
Workspace: config.Workspace{
|
||||||
"": {},
|
|
||||||
},
|
|
||||||
Workspace: config.Workspace{
|
|
||||||
CurrentUser: &config.User{
|
CurrentUser: &config.User{
|
||||||
ShortName: "lennart",
|
ShortName: "lennart",
|
||||||
User: &iam.User{
|
User: &iam.User{
|
||||||
|
@ -337,8 +334,12 @@ func TestProcessTargetModeProductionOkWithRootPath(t *testing.T) {
|
||||||
require.Error(t, diags.Error())
|
require.Error(t, diags.Error())
|
||||||
|
|
||||||
// ... but we're okay if we specify a root path
|
// ... but we're okay if we specify a root path
|
||||||
b.Config.Targets[""].Workspace = &config.Workspace{
|
b.Config.Targets = map[string]*config.Target{
|
||||||
RootPath: "some-root-path",
|
"": {
|
||||||
|
Workspace: &config.Workspace{
|
||||||
|
RootPath: "some-root-path",
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
diags = validateProductionMode(context.Background(), b, false)
|
diags = validateProductionMode(context.Background(), b, false)
|
||||||
require.NoError(t, diags.Error())
|
require.NoError(t, diags.Error())
|
||||||
|
|
Loading…
Reference in New Issue