open-component-model / ocm

Open Component Model (Software Bill of Delivery Toolset)
https://ocm.software
Apache License 2.0
32 stars 23 forks source link

Rework adding elements to a component version #844

Closed mandelsoft closed 1 month ago

mandelsoft commented 1 month ago

What this PR does / why we need it:

The previous mechanism for adding elements (resources, sources and references) to a component version provided a hybrid mechanism, only:

This behaviour does not allow to add elements with the same base identity but a different version, if the version is not explicitly added to the extra identity. So, far this explicit handling of the version is not required, because it is implicitly done when evaluating the element list.

This PR add new options to the Set methods for the three element kinds on the component version access to specify the exact desired behaviour:

The default behaviour is unchanged. It is sufficient for the most common use cases, as long as no duplicate entries with different versions should be added.

The CLI commands have been adjusted to use the Append mode by default. This is exactly what is desired if new component versions are composed. If an existing version should be modified, it is possible to use the option -R to switch to the default mode.

Which issue(s) this PR fixes:

Fixes #842