feat: 743 constructor semver#1317
Conversation
5c96e2f to
06974ad
Compare
06974ad to
68502a1
Compare
6f979ca to
146cf24
Compare
6605a0f to
15bafd8
Compare
1514b90 to
d378932
Compare
|
Just wondering, instead of having concrete semver checks, shouldn't we rather try to have a thorough json schema for the constructor and validate the entire constructors against that json schema? |
something like this? // Component defines a named and versioned component containing dependencies such as sources, resources and
// references pointing to further component versions.
// +k8s:deepcopy-gen=true
type Component struct {
ComponentMeta `json:",inline"`
Provider Provider `json:"-"`
Resources []Resource `json:"-"`
Sources []Source `json:"-"`
References []Reference `json:"-"`
}
func (a *Component) Validate() error {
if _, err := semver.NewConstraint(a.Version); err != nil {
return errors.Join(ErrInvalidSemverVersion, fmt.Errorf("component %q has invalid semver version %q: %w", a.Name, a.Version, err))
}
return nil
} |
5a079c8 to
51b0470
Compare
if err := constructorv1.ValidateRawYAML(constructorData); err != nil {
return nil, fmt.Errorf("validating component constructor %q failed: %w", path, err)
}I tried to validate the constructor against the existing schema and it fails with basically every existing cli test @jakobmoellerdev since you built the schema - how to proceed here? should I update every existing cli test or revisit the schema since it's not really in use right now afaik |
2db203a to
52993c0
Compare
On-behalf-of: SAP <matthias.bruns@sap.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
On-behalf-of: SAP <matthias.bruns@sap.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
76d5472 to
b2a4819
Compare
jakobmoellerdev
left a comment
There was a problem hiding this comment.
Just a note. are you sure that this shouldnt just be a call on the data in the cli? otherwise everyone will loose to read a constructor that does not conform to the schema (i.e. when they want to build them together step by step from fragments)
haven't thought about it - wdyt? I am usually for more strict handling everywhere than fragmented behaviour. I can only check it in CLI for now, but since we have a spec, and we are parsing from it, I'd assume that we would do the check at this point for every model tbh |
On-behalf-of: SAP <matthias.bruns@sap.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
In general this is great but you have to remember that were currently restricting marshalling itself. I am happy to default to use this marshaller but be able to have an unsafe version as well. since this lib is so foundational we must assume folks want to get unfinished constructors into the lib |
On-behalf-of: SAP <matthias.bruns@sap.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
Added https://github.com/open-component-model/open-component-model/pull/1317/files#diff-35b4b1f537a1b2d5258b540d47da10402c97cf1dc45bcacf82009cff106a0700R51 and tests for it |
On-behalf-of: SAP <matthias.bruns@sap.com> Signed-off-by: Matthias Bruns <git@matthiasbruns.com>
fd34b01 to
5d9297d
Compare
fabianburth
left a comment
There was a problem hiding this comment.
The PR linked in your PR description does not contain any additional information.
added a bit info to the cli pr |
40ef3dd
into
open-component-model:main
<!-- markdownlint-disable MD041 --> #### What this PR does / why we need it Adds semver checks to `ocm add cv` analog to `ocm get cv` - This PR will only update cli and add tests when #1317 is merged to verify, that the constructor validation works as expected - This Pr also reduces the logging level in `get cv` when requesting an invalid version #1393 #### Which issue(s) this PR fixes Fixes: open-component-model/ocm-project#743 Fixes: open-component-model/ocm-project#752 --------- Signed-off-by: Matthias Bruns <git@matthiasbruns.com> Co-authored-by: ocmbot[bot] <125909804+ocmbot[bot]@users.noreply.github.com>
What this PR does / why we need it
Adds semver checks to
ocm add cvanalog toocm get cvWhich issue(s) this PR fixes
Contributes open-component-model/ocm-project#743
Check #1341 how it is integrated