mirror of https://github.com/databricks/cli.git
fix logic for dedup
This commit is contained in:
parent
5bf916357a
commit
e31dcc2724
|
@ -81,28 +81,21 @@ func validateSingleResourceDefined(r *config.Root, ext, typ string) diag.Diagnos
|
||||||
return diag.FromErr(err)
|
return diag.FromErr(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
valid := true
|
typeMatch := true
|
||||||
seenKeys := map[string]struct{}{}
|
seenKeys := map[string]struct{}{}
|
||||||
for _, rr := range resources {
|
for _, rr := range resources {
|
||||||
if len(seenKeys) == 0 {
|
// case: The resource is not of the correct type.
|
||||||
seenKeys[rr.key] = struct{}{}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, ok := seenKeys[rr.key]; !ok {
|
|
||||||
valid = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
|
|
||||||
if rr.typ != typ {
|
if rr.typ != typ {
|
||||||
valid = false
|
typeMatch = false
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
seenKeys[rr.key] = struct{}{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// The file only contains one resource defined in its resources or targets block,
|
// Format matches. There's less than or equal to one resource defined in the file.
|
||||||
// and the resource is of the correct type.
|
// The resource is also of the correct type.
|
||||||
if valid {
|
if typeMatch && len(seenKeys) <= 1 {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue