mirror of https://github.com/databricks/cli.git
fix bug
This commit is contained in:
parent
557223e165
commit
be92aa639c
|
@ -482,13 +482,13 @@ func (r Root) verifySafeMerge(other Root) error {
|
|||
for k, p := range paths {
|
||||
if _, ok := otherPaths[k]; ok {
|
||||
// Type and location of the existing resource in the map.
|
||||
ot := strings.TrimSuffix(paths[k][0].Key(), "s")
|
||||
ov, _ := dyn.GetByPath(r.value.Get("resources"), paths[k])
|
||||
ot := strings.TrimSuffix(p[0].Key(), "s")
|
||||
ov, _ := dyn.GetByPath(r.value.Get("resources"), p)
|
||||
ol := ov.Location()
|
||||
|
||||
// Type and location of the newly encountered resource with a duplicate name.
|
||||
nt := strings.TrimSuffix(p[0].Key(), "s")
|
||||
nv, _ := dyn.GetByPath(r.value.Get("resources"), p)
|
||||
nt := strings.TrimSuffix(otherPaths[k][0].Key(), "s")
|
||||
nv, _ := dyn.GetByPath(other.value.Get("resources"), otherPaths[k])
|
||||
nl := nv.Location()
|
||||
|
||||
// Error, encountered a duplicate resource identifier.
|
||||
|
@ -501,9 +501,9 @@ func (r Root) verifySafeMerge(other Root) error {
|
|||
// This function gathers the resource identifiers, which exist in the bundle configuration
|
||||
// in the form: resources.<resource_type>.<resource_identifiers>.
|
||||
//
|
||||
// It returns an error if it encounters a duplicate resource identifiers.
|
||||
// It returns an error if it encounters duplicate resource identifiers.
|
||||
//
|
||||
// Otherwise it returns a map of resource identifiers to their paths in the configuration tree
|
||||
// Otherwise it returns a map of resource identifiers to their paths in the configuration tree,
|
||||
// relative to the resources key.
|
||||
func (r Root) gatherResourceIdentifiers() (map[string]dyn.Path, error) {
|
||||
paths := make(map[string]dyn.Path)
|
||||
|
@ -520,8 +520,6 @@ func (r Root) gatherResourceIdentifiers() (map[string]dyn.Path, error) {
|
|||
return v, dyn.ErrSkip
|
||||
}
|
||||
|
||||
// TODO: Add validation that the resource is a map.
|
||||
|
||||
// If the resource identifier already exists in the map, return an error.
|
||||
k := p[1].Key()
|
||||
if _, ok := paths[k]; ok {
|
||||
|
|
|
@ -48,7 +48,7 @@ func TestDuplicateIdOnMergeReturnsErrorForJobAndPipeline(t *testing.T) {
|
|||
require.NoError(t, diags.Error())
|
||||
|
||||
err := root.Merge(other)
|
||||
assert.ErrorContains(t, err, "multiple resources named foo (job at ./testdata/duplicate_resource_name_in_subconfiguration/databricks.yml:10:7, job at ./testdata/duplicate_resource_name_in_subconfiguration/databricks.yml:10:7)")
|
||||
assert.ErrorContains(t, err, "multiple resources named foo (job at ./testdata/duplicate_resource_name_in_subconfiguration/databricks.yml:10:7, pipeline at ./testdata/duplicate_resource_name_in_subconfiguration/resources.yml:4:7)")
|
||||
}
|
||||
|
||||
func TestDuplicateIdOnMergeReturnsErrorForJobAndJob(t *testing.T) {
|
||||
|
@ -59,7 +59,7 @@ func TestDuplicateIdOnMergeReturnsErrorForJobAndJob(t *testing.T) {
|
|||
require.NoError(t, diags.Error())
|
||||
|
||||
err := root.Merge(other)
|
||||
assert.ErrorContains(t, err, "multiple resources named foo (job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/databricks.yml:10:7, job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/databricks.yml:10:7)")
|
||||
assert.ErrorContains(t, err, "multiple resources named foo (job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/databricks.yml:10:7, job at ./testdata/duplicate_resource_name_in_subconfiguration_job_and_job/resources.yml:4:7)")
|
||||
}
|
||||
|
||||
func TestInitializeVariables(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue