-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove catalogmetadata types, introduce to resolver interface
Signed-off-by: Joe Lanford <joe.lanford@gmail.com>
- Loading branch information
1 parent
60d26ed
commit 7b0983c
Showing
30 changed files
with
1,847 additions
and
3,175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package bundleutil | ||
|
||
import ( | ||
"encoding/json" | ||
"fmt" | ||
|
||
bsemver "github.com/blang/semver/v4" | ||
|
||
"github.com/operator-framework/operator-registry/alpha/declcfg" | ||
"github.com/operator-framework/operator-registry/alpha/property" | ||
|
||
ocv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1" | ||
) | ||
|
||
func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) { | ||
for _, p := range b.Properties { | ||
if p.Type == property.TypePackage { | ||
var pkg property.Package | ||
if err := json.Unmarshal(p.Value, &pkg); err != nil { | ||
return nil, fmt.Errorf("error unmarshalling package property: %w", err) | ||
} | ||
vers, err := bsemver.Parse(pkg.Version) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &vers, nil | ||
} | ||
} | ||
return nil, fmt.Errorf("no package property found in bundle %q", b.Name) | ||
} | ||
|
||
// MetadataFor returns a BundleMetadata for the given bundle. If the provided bundle is nil, | ||
// this function panics. It is up to the caller to ensure that the bundle is non-nil. | ||
func MetadataFor(bundleName string, bundleVersion *bsemver.Version) *ocv1alpha1.BundleMetadata { | ||
return &ocv1alpha1.BundleMetadata{ | ||
Name: bundleName, | ||
Version: bundleVersion.String(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.