mirror of https://github.com/databricks/cli.git
Fixed bundle not loading when empty variable is defined (#1552)
## Changes Fixes #1544 ## Tests Added regression test
This commit is contained in:
parent
0d64975d36
commit
3d2f7622bc
|
@ -0,0 +1,7 @@
|
|||
variables:
|
||||
a:
|
||||
description: empty variable
|
||||
default:
|
||||
|
||||
bundle:
|
||||
name: empty${var.a}
|
|
@ -193,3 +193,9 @@ func TestVariableTargetOverrides(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestBundleWithEmptyVariableLoads(t *testing.T) {
|
||||
b := load(t, "./variables/empty")
|
||||
diags := bundle.Apply(context.Background(), b, mutator.SetVariables())
|
||||
require.ErrorContains(t, diags.Error(), "no value assigned to required variable a")
|
||||
}
|
||||
|
|
|
@ -282,6 +282,11 @@ func toTypedFloat(dst reflect.Value, src dyn.Value) error {
|
|||
}
|
||||
|
||||
func toTypedInterface(dst reflect.Value, src dyn.Value) error {
|
||||
if src.Kind() == dyn.KindNil {
|
||||
dst.Set(reflect.Zero(dst.Type()))
|
||||
return nil
|
||||
}
|
||||
|
||||
dst.Set(reflect.ValueOf(src.AsAny()))
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -533,3 +533,10 @@ func TestToTypedAnyWithMap(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Equal(t, map[string]any{"foo": "bar", "bar": "baz"}, out)
|
||||
}
|
||||
|
||||
func TestToTypedAnyWithNil(t *testing.T) {
|
||||
var out any
|
||||
err := ToTyped(&out, dyn.NilValue)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, nil, out)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue