-
Notifications
You must be signed in to change notification settings - Fork 56
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 <[email protected]>
- Loading branch information
1 parent
957fc1b
commit b59ac9e
Showing
30 changed files
with
1,843 additions
and
3,184 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,38 @@ | ||
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 name and version. | ||
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.