mirror of https://github.com/databricks/cli.git
Fixed detecting full syntax variable override which includes type field
This commit is contained in:
parent
e220f9ddd6
commit
e3e29ea78d
|
@ -409,18 +409,33 @@ func (r *Root) MergeTargetOverrides(name string) error {
|
||||||
var variableKeywords = []string{"default", "lookup"}
|
var variableKeywords = []string{"default", "lookup"}
|
||||||
|
|
||||||
// isFullVariableOverrideDef checks if the given value is a full syntax varaible override.
|
// isFullVariableOverrideDef checks if the given value is a full syntax varaible override.
|
||||||
// A full syntax variable override is a map with only one of the following
|
// A full syntax variable override is a map with either 1 of 2 keys.
|
||||||
// keys: "default", "lookup".
|
// If it's 2 keys, the keys should be "default" and "type".
|
||||||
|
// If it's 1 key, the key should be one of the following keys: "default", "lookup".
|
||||||
func isFullVariableOverrideDef(v dyn.Value) bool {
|
func isFullVariableOverrideDef(v dyn.Value) bool {
|
||||||
mv, ok := v.AsMap()
|
mv, ok := v.AsMap()
|
||||||
if !ok {
|
if !ok {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if mv.Len() != 1 {
|
// If the map has more than 2 keys, it is not a full variable override.
|
||||||
|
if mv.Len() > 2 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the map has 2 keys, one of them should be "default" and the other is "type"
|
||||||
|
if mv.Len() == 2 {
|
||||||
|
if _, ok := mv.GetByString("type"); !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, ok := mv.GetByString("default"); !ok {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
for _, keyword := range variableKeywords {
|
for _, keyword := range variableKeywords {
|
||||||
if _, ok := mv.GetByString(keyword); ok {
|
if _, ok := mv.GetByString(keyword); ok {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue