Skip to content

Commit

Permalink
check if version contained '+',
Browse files Browse the repository at this point in the history
which has been replaced by META_SEPARATOR to create OCI compliant tag
  • Loading branch information
hilmarf committed Jan 13, 2025
1 parent 2dc0134 commit 4d7d05f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions api/ocm/extensions/repositories/genericocireg/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,6 @@ func (c *componentAccessImpl) HasVersion(vers string) (bool, error) {
}

func (c *componentAccessImpl) LookupVersion(version string) (*repocpi.ComponentVersionAccessInfo, error) {
// LookupVersion '0.0.1-20250108132333.build-af79499' would fail with:
// unable to unref last: unable to cleanup component version [%v] while unref last: closing component version [%v]: check failed: component version [%v] is invalid
// This is because the version comes from an artifact tag, which doesn't allow '+' characters, which we replace with '.build-' during the push
version = toVersion(version) // ensure the cv doesn't contain '.build-'
tag, err := toTag(version)
if err != nil {
return nil, err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@ func (c *ComponentVersionContainer) SetReadOnly() {

func (c *ComponentVersionContainer) Check() error {
if c.version != c.GetDescriptor().Version {
// check if version contained '+' which has been replaced by META_SEPARATOR to create OCI compliant tag
if replaced, _ := toTag(c.GetDescriptor().Version); replaced != c.GetDescriptor().Version && replaced == c.version {
Logger(c.GetContext()).Warn(fmt.Sprintf(
"checked version %q contains %q, this is discouraged and you should prefer the original component version %q", c.version, META_SEPARATOR, c.GetDescriptor().Version))
return nil
} else {
return errors.ErrInvalid("component version", c.GetDescriptor().Version)
}
return errors.ErrInvalid("component version", c.GetDescriptor().Version)

Check failure on line 113 in api/ocm/extensions/repositories/genericocireg/componentversion.go

View workflow job for this annotation

GitHub Actions / Lint Golang

unreachable: unreachable code (govet)
}
if c.comp.name != c.GetDescriptor().Name {
Expand Down

0 comments on commit 4d7d05f

Please sign in to comment.