@@ -178,6 +178,93 @@ func cdxFindComponent(b *cydx.BOM, c *configParams) *cydx.Component {
178
178
return nil
179
179
}
180
180
181
+ func cdxUniqTools (a * cydx.ToolsChoice , b * cydx.ToolsChoice ) * cydx.ToolsChoice {
182
+ choices := cydx.ToolsChoice {}
183
+
184
+ if a == nil && b == nil {
185
+ return & choices
186
+ }
187
+
188
+ if a == nil && b != nil {
189
+ return b
190
+ }
191
+
192
+ if a != nil && b == nil {
193
+ return a
194
+ }
195
+
196
+ if a .Tools != nil && b .Tools != nil {
197
+ choices .Tools = new ([]cydx.Tool )
198
+ uniqTools := make (map [string ]string )
199
+
200
+ for _ , tool := range * a .Tools {
201
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
202
+
203
+ if _ , ok := uniqTools [key ]; ! ok {
204
+ * choices .Tools = append (* choices .Tools , tool )
205
+ uniqTools [key ] = key
206
+ }
207
+ }
208
+
209
+ for _ , tool := range * b .Tools {
210
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
211
+
212
+ if _ , ok := uniqTools [key ]; ! ok {
213
+ * choices .Tools = append (* choices .Tools , tool )
214
+ uniqTools [key ] = key
215
+ }
216
+ }
217
+ }
218
+
219
+ if a .Components != nil && b .Components != nil {
220
+ choices .Components = new ([]cydx.Component )
221
+ uniqTools := make (map [string ]string )
222
+
223
+ for _ , tool := range * a .Components {
224
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
225
+
226
+ if _ , ok := uniqTools [key ]; ! ok {
227
+ * choices .Components = append (* choices .Components , tool )
228
+ uniqTools [key ] = key
229
+ }
230
+ }
231
+
232
+ for _ , tool := range * b .Components {
233
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
234
+
235
+ if _ , ok := uniqTools [key ]; ! ok {
236
+ * choices .Components = append (* choices .Components , tool )
237
+ uniqTools [key ] = key
238
+ }
239
+ }
240
+ }
241
+
242
+ if a .Services != nil && b .Services != nil {
243
+ choices .Services = new ([]cydx.Service )
244
+ uniqTools := make (map [string ]string )
245
+
246
+ for _ , tool := range * a .Services {
247
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
248
+
249
+ if _ , ok := uniqTools [key ]; ! ok {
250
+ * choices .Services = append (* choices .Services , tool )
251
+ uniqTools [key ] = key
252
+ }
253
+ }
254
+
255
+ for _ , tool := range * b .Services {
256
+ key := fmt .Sprintf ("%s-%s" , strings .ToLower (tool .Name ), strings .ToLower (tool .Version ))
257
+
258
+ if _ , ok := uniqTools [key ]; ! ok {
259
+ * choices .Services = append (* choices .Services , tool )
260
+ uniqTools [key ] = key
261
+ }
262
+ }
263
+ }
264
+
265
+ return & choices
266
+ }
267
+
181
268
func cdxConstructTools (b * cydx.BOM , c * configParams ) * cydx.ToolsChoice {
182
269
choice := cydx.ToolsChoice {}
183
270
@@ -226,7 +313,7 @@ func cdxConstructHashes(_ *cydx.BOM, c *configParams) *[]cydx.Hash {
226
313
return & hashes
227
314
}
228
315
229
- func cdxConstructLicenses (b * cydx.BOM , c * configParams ) cydx.Licenses {
316
+ func cdxConstructLicenses (_ * cydx.BOM , c * configParams ) cydx.Licenses {
230
317
licenses := cydx.Licenses {}
231
318
232
319
for _ , license := range c .licenses {
0 commit comments