Skip to content

Attributes overriding fails when overriding for non primitive attributes (arrays or objects) #263

@davidfestal

Description

@davidfestal

Describe the bug

When trying to override non-primitive (arrays or objects) elements of an attributes field, this fails with the following error:
merging an object in json but data type is not struct, instead is: map

To Reproduce
Steps to reproduce the behavior:

  1. Create a new folder pkg/utils/overriding/test-fixtures/patches/command-with-attributes in the repository
  2. Cteate the following 3 files inside this new repository:
  • original.yaml:
commands:
  - attributes:
      objectAttributeToReplaceFully:
        attributeField: 9.9
    apply:
      component: "mycomponent"
    id: command-with-attributes-changed
  • patch.yaml:
commands:
  - attributes:
      objectAttributeToReplaceFully:
        newAttributeField: newAttributeFieldValue
    apply: {}
    
    id: command-with-attributes-changed
  • result.yaml:
commands:
  - attributes:
      objectAttributeToReplaceFully:
        newAttributeField: newAttributeFieldValue
    apply:
      component: "mycomponent"
    id: command-with-attributes-changed
  1. In the file pkg/utils/overriding/overriding_test.go, replace the following line (311):
t.Error("Received error but did not expect one")

by

t.Error("Received error but did not expect one" + actual)
  1. Run the overriding test at the root of the project:
go test ./pkg/utils/overriding
  1. See the error in the Go test result:
--- FAIL: TestOverridingPatches (0.00s)
    --- FAIL: TestOverridingPatches/command-with-attributes (0.00s)
        overriding_test.go:311: Received error but did not expect onemerging an object in json but data type is not struct, instead is: map
FAIL
FAIL    github.com/devfile/api/pkg/utils/overriding     0.008s
FAIL

Expected behavior

The result of the attribute override should be the one described in the result.yaml file above.

Metadata

Metadata

Assignees

Labels

kind/bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions