score-spec / score-go

Reference library for parsing and loading Score files
Apache License 2.0
26 stars 6 forks source link

fix(framework): fixed param/meta comparison for duplicate resource def with the same id #34

Closed astromechza closed 7 months ago

astromechza commented 7 months ago

While upgrading a Score implementation at Humanitec I found a bug when processing a spec like the following (which was used in an existing unit test):

...
resources:
  thing-a:
    type: cat
    id: garfield
    params:
      color: orange
  thing-b:
    type: cat
    id: garfield
    params:
      color: orange 

This is an esoteric example which makes more sense when looking at multiple score workloads that define the same resource in the same project. The current main branch check was failing because deep-equal returned false because the metadata dictionaries were technically not the same outer type at the time of comparison.

The fix is just coercing it to the comparable type map[string]interface{}.

Specs like this (params or metadata defined only once) will still work fine without errors.

  thing-a:
    type: cat
    id: garfield
    params:
      color: orange
  thing-b:
    type: cat
    id: garfield