Skip to content

Commit 7566298

Browse files
alistair-mcleanAlistair McLean
andauthored
fix: unset component tags for spec version less than 1.6 (#253)
Co-authored-by: Alistair McLean <alistair.mclean@netrise.io>
1 parent bc030ba commit 7566298

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ func componentConverter(specVersion SpecVersion) func(*Component) {
159159
c.OmniborID = nil
160160
c.Manufacturer = nil
161161
c.Authors = nil
162+
c.Tags = nil
162163
}
163164

164165
if !specVersion.supportsComponentType(c.Type) {

convert_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,3 +245,26 @@ func Test_convertAuthors(t *testing.T) {
245245
assert.Nil(t, (*bom.Components)[0].Authors)
246246
})
247247
}
248+
249+
func Test_convertTags(t *testing.T) {
250+
t.Run("spec 1.5 and lower", func(t *testing.T) {
251+
bom := NewBOM()
252+
bom.Metadata = &Metadata{
253+
Component: &Component{
254+
Name: "test",
255+
Tags: &[]string{"tag1", "tag2"},
256+
},
257+
}
258+
bom.Components = &[]Component{
259+
{
260+
Name: "foo",
261+
Tags: &[]string{"tag3", "tag4"},
262+
},
263+
}
264+
265+
bom.convert(SpecVersion1_5)
266+
267+
assert.Nil(t, bom.Metadata.Component.Tags)
268+
assert.Nil(t, (*bom.Components)[0].Tags)
269+
})
270+
}

0 commit comments

Comments
 (0)