Skip to content

Commit 0fcc45e

Browse files
authored
fix: serilization of componentReferences (#97)
1 parent 8bf0443 commit 0fcc45e

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.5.0-dev
1+
v0.5.1

internal/ocm-cli/ocm.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ type Component struct {
9696
// Version is the version of the component.
9797
Version string `json:"version"`
9898
// ComponentReferences is a list of references to other components that this component depends on.
99-
ComponentReferences []ComponentReference `yaml:"componentReferences"`
99+
ComponentReferences []ComponentReference `json:"componentReferences"`
100100
// Resources is a list of resources associated with this component, including their names, versions, types, and access information.
101101
Resources []Resource `json:"resources"`
102102
}

internal/ocm-cli/ocm_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"testing"
66

77
"github.com/stretchr/testify/assert"
8+
"k8s.io/apimachinery/pkg/util/json"
89
"k8s.io/utils/ptr"
910

1011
ocmcli "github.com/openmcp-project/bootstrapper/internal/ocm-cli"
@@ -114,6 +115,19 @@ func TestGetComponentVersion(t *testing.T) {
114115
MediaType: ptr.To("application/octet-stream"),
115116
},
116117
})
118+
119+
cvMarshaled, err := json.Marshal(cv)
120+
assert.NoError(t, err)
121+
assert.NotNil(t, cvMarshaled)
122+
123+
var cvAsMap map[string]interface{}
124+
err = json.Unmarshal(cvMarshaled, &cvAsMap)
125+
assert.NoError(t, err)
126+
assert.NotNil(t, cvAsMap)
127+
assert.Contains(t, cvAsMap, "component")
128+
assert.Contains(t, cvAsMap["component"], "componentReferences")
129+
comp := cvAsMap["component"].(map[string]interface{})
130+
assert.Len(t, comp["componentReferences"], 2)
117131
},
118132
},
119133
{

0 commit comments

Comments
 (0)