Skip to content

Commit dc80a94

Browse files
committed
minor API improvements
Signed-off-by: Joe Lanford <[email protected]>
1 parent d09f325 commit dc80a94

File tree

10 files changed

+74
-81
lines changed

10 files changed

+74
-81
lines changed

api/v1alpha1/clusterextension_types.go

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ import (
2323
)
2424

2525
var (
26-
ClusterExtensionGVK = SchemeBuilder.GroupVersion.WithKind("ClusterExtension")
27-
ClusterExtensionKind = ClusterExtensionGVK.Kind
26+
ClusterExtensionKind = "ClusterExtension"
2827
)
2928

3029
type UpgradeConstraintPolicy string
@@ -386,15 +385,15 @@ type PreflightConfig struct {
386385
// The CRD Upgrade Safety pre-flight check safeguards from unintended
387386
// consequences of upgrading a CRD, such as data loss.
388387
//
389-
// This field is required if the spec.preflight field is specified.
388+
// This field is required if the spec.install.preflight field is specified.
390389
CRDUpgradeSafety *CRDUpgradeSafetyPreflightConfig `json:"crdUpgradeSafety"`
391390
}
392391

393392
// CRDUpgradeSafetyPreflightConfig is the configuration for CRD upgrade safety preflight check.
394393
type CRDUpgradeSafetyPreflightConfig struct {
395394
// policy is used to configure the state of the CRD Upgrade Safety pre-flight check.
396395
//
397-
// This field is required when the spec.preflight.crdUpgradeSafety field is
396+
// This field is required when the spec.install.preflight.crdUpgradeSafety field is
398397
// specified.
399398
//
400399
// Allowed values are ["Enabled", "Disabled"]. The default value is "Enabled".
@@ -485,15 +484,17 @@ type ClusterExtensionStatus struct {
485484
// - Reason: a string representation of the reason for the current state of the condition. Typically useful for building automation around particular Type+Reason combinations.
486485
// - Message: a human readable message that further elaborates on the state of the condition
487486
//
488-
// The current set of condition types are:
489-
// - "Installed", represents whether or not the package referenced in the spec.packageName field has been installed
487+
// The global set of condition types are:
488+
// - "Installed", represents whether or not the a bundle has been installed for this ClusterExtension
490489
// - "Resolved", represents whether or not a bundle was found that satisfies the selection criteria outlined in the spec
491-
// - "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types.
492-
// - "PackageDeprecated", represents whether or not the package specified in the spec.packageName field has been deprecated
493-
// - "ChannelDeprecated", represents whether or not the channel specified in spec.channel has been deprecated
494-
// - "BundleDeprecated", represents whether or not the bundle installed is deprecated
495490
// - "Unpacked", represents whether or not the bundle contents have been successfully unpacked
496491
//
492+
// When the ClusterExtension is sourced from a catalog, the following conditions are also possible:
493+
// - "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types
494+
// - "PackageDeprecated", represents whether or not the package specified in the spec.source.catalog.packageName field has been deprecated
495+
// - "ChannelDeprecated", represents whether or not any channel specified in spec.source.catalog.channels has been deprecated
496+
// - "BundleDeprecated", represents whether or not the installed bundle is deprecated
497+
//
497498
// The current set of reasons are:
498499
// - "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful
499500
// - "Failed", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when an error has occurred while unpacking the contents of a bundle, during resolution or installation.
@@ -511,22 +512,17 @@ type ClusterExtensionInstallStatus struct {
511512
//
512513
// A "bundle" is a versioned set of content that represents the resources that
513514
// need to be applied to a cluster to install a package.
514-
//
515-
// This field is only updated once a bundle has been successfully installed and
516-
// once set will only be updated when a new version of the bundle has
517-
// successfully replaced the currently installed version.
518-
//
519-
//+optional
520-
Bundle *BundleMetadata `json:"bundle,omitempty"`
515+
Bundle BundleMetadata `json:"bundle"`
521516
}
522517

523518
type ClusterExtensionResolutionStatus struct {
524519
// bundle is a representation of the bundle that was identified during
525520
// resolution to meet all installation/upgrade constraints and is slated to be
526521
// installed or upgraded to.
527522
//
528-
//+optional
529-
Bundle *BundleMetadata `json:"bundle,omitempty"`
523+
// A "bundle" is a versioned set of content that represents the resources that
524+
// need to be applied to a cluster to install a package.
525+
Bundle BundleMetadata `json:"bundle"`
530526
}
531527

532528
//+kubebuilder:object:root=true

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 4 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/base/crd/bases/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ spec:
100100
The CRD Upgrade Safety pre-flight check safeguards from unintended
101101
consequences of upgrading a CRD, such as data loss.
102102
103-
This field is required if the spec.preflight field is specified.
103+
This field is required if the spec.install.preflight field is specified.
104104
properties:
105105
policy:
106106
default: Enabled
107107
description: |-
108108
policy is used to configure the state of the CRD Upgrade Safety pre-flight check.
109109
110-
This field is required when the spec.preflight.crdUpgradeSafety field is
110+
This field is required when the spec.install.preflight.crdUpgradeSafety field is
111111
specified.
112112
113113
Allowed values are ["Enabled", "Disabled"]. The default value is "Enabled".
@@ -474,15 +474,17 @@ spec:
474474
- Reason: a string representation of the reason for the current state of the condition. Typically useful for building automation around particular Type+Reason combinations.
475475
- Message: a human readable message that further elaborates on the state of the condition
476476
477-
The current set of condition types are:
478-
- "Installed", represents whether or not the package referenced in the spec.packageName field has been installed
477+
The global set of condition types are:
478+
- "Installed", represents whether or not the a bundle has been installed for this ClusterExtension
479479
- "Resolved", represents whether or not a bundle was found that satisfies the selection criteria outlined in the spec
480-
- "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types.
481-
- "PackageDeprecated", represents whether or not the package specified in the spec.packageName field has been deprecated
482-
- "ChannelDeprecated", represents whether or not the channel specified in spec.channel has been deprecated
483-
- "BundleDeprecated", represents whether or not the bundle installed is deprecated
484480
- "Unpacked", represents whether or not the bundle contents have been successfully unpacked
485481
482+
When the ClusterExtension is sourced from a catalog, the following conditions are also possible:
483+
- "Deprecated", represents an aggregation of the PackageDeprecated, ChannelDeprecated, and BundleDeprecated condition types
484+
- "PackageDeprecated", represents whether or not the package specified in the spec.source.catalog.packageName field has been deprecated
485+
- "ChannelDeprecated", represents whether or not any channel specified in spec.source.catalog.channels has been deprecated
486+
- "BundleDeprecated", represents whether or not the installed bundle is deprecated
487+
486488
The current set of reasons are:
487489
- "Success", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when unpacking a bundle's content, resolution and installation/upgrading is successful
488490
- "Failed", this reason is set on the "Unpacked", "Resolved" and "Installed" conditions when an error has occurred while unpacking the contents of a bundle, during resolution or installation.
@@ -552,10 +554,6 @@ spec:
552554
553555
A "bundle" is a versioned set of content that represents the resources that
554556
need to be applied to a cluster to install a package.
555-
556-
This field is only updated once a bundle has been successfully installed and
557-
once set will only be updated when a new version of the bundle has
558-
successfully replaced the currently installed version.
559557
properties:
560558
name:
561559
description: |-
@@ -571,6 +569,8 @@ spec:
571569
- name
572570
- version
573571
type: object
572+
required:
573+
- bundle
574574
type: object
575575
resolution:
576576
properties:
@@ -579,6 +579,9 @@ spec:
579579
bundle is a representation of the bundle that was identified during
580580
resolution to meet all installation/upgrade constraints and is slated to be
581581
installed or upgraded to.
582+
583+
A "bundle" is a versioned set of content that represents the resources that
584+
need to be applied to a cluster to install a package.
582585
properties:
583586
name:
584587
description: |-
@@ -594,6 +597,8 @@ spec:
594597
- name
595598
- version
596599
type: object
600+
required:
601+
- bundle
597602
type: object
598603
type: object
599604
type: object

internal/bundleutil/bundle.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ func GetVersion(b declcfg.Bundle) (*bsemver.Version, error) {
3030
}
3131

3232
// MetadataFor returns a BundleMetadata for the given bundle name and version.
33-
func MetadataFor(bundleName string, bundleVersion bsemver.Version) *ocv1alpha1.BundleMetadata {
34-
return &ocv1alpha1.BundleMetadata{
33+
func MetadataFor(bundleName string, bundleVersion bsemver.Version) ocv1alpha1.BundleMetadata {
34+
return ocv1alpha1.BundleMetadata{
3535
Name: bundleName,
3636
Version: bundleVersion.String(),
3737
}

internal/catalogmetadata/filter/successors.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/operator-framework/operator-controller/internal/features"
1313
)
1414

15-
func SuccessorsOf(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
15+
func SuccessorsOf(installedBundle ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
1616
var successors successorsPredicateFunc = legacySuccessor
1717
if features.OperatorControllerFeatureGate.Enabled(features.ForceSemverUpgradeConstraints) {
1818
successors = semverSuccessor
@@ -42,9 +42,9 @@ func SuccessorsOf(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcf
4242

4343
// successorsPredicateFunc returns a predicate to find successors
4444
// for a bundle. Predicate must not include the current version.
45-
type successorsPredicateFunc func(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error)
45+
type successorsPredicateFunc func(installedBundle ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error)
4646

47-
func legacySuccessor(installedBundle *ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
47+
func legacySuccessor(installedBundle ocv1alpha1.BundleMetadata, channels ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
4848
installedBundleVersion, err := bsemver.Parse(installedBundle.Version)
4949
if err != nil {
5050
return nil, fmt.Errorf("error parsing installed bundle version: %w", err)
@@ -88,7 +88,7 @@ func legacySuccessor(installedBundle *ocv1alpha1.BundleMetadata, channels ...dec
8888
// in a channel entry that is necessary to determine if a bundle is a successor.
8989
// A semver range check is the only necessary element. If filtering by channel
9090
// membership is necessary, an additional filter for that purpose should be applied.
91-
func semverSuccessor(installedBundle *ocv1alpha1.BundleMetadata, _ ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
91+
func semverSuccessor(installedBundle ocv1alpha1.BundleMetadata, _ ...declcfg.Channel) (Predicate[declcfg.Bundle], error) {
9292
currentVersion, err := mmsemver.NewVersion(installedBundle.Version)
9393
if err != nil {
9494
return nil, err

internal/catalogmetadata/filter/successors_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsEnabled(t *testing.
129129

130130
for _, tt := range []struct {
131131
name string
132-
installedBundle *ocv1alpha1.BundleMetadata
132+
installedBundle ocv1alpha1.BundleMetadata
133133
expectedResult []declcfg.Bundle
134134
}{
135135
{
@@ -162,7 +162,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsEnabled(t *testing.
162162
},
163163
{
164164
name: "installed bundle not found",
165-
installedBundle: &ocv1alpha1.BundleMetadata{
165+
installedBundle: ocv1alpha1.BundleMetadata{
166166
Name: "test-package.v9.0.0",
167167
Version: "9.0.0",
168168
},
@@ -281,7 +281,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsDisabled(t *testing
281281

282282
for _, tt := range []struct {
283283
name string
284-
installedBundle *ocv1alpha1.BundleMetadata
284+
installedBundle ocv1alpha1.BundleMetadata
285285
expectedResult []declcfg.Bundle
286286
}{
287287
{
@@ -319,7 +319,7 @@ func TestSuccessorsPredicateWithForceSemverUpgradeConstraintsDisabled(t *testing
319319
},
320320
{
321321
name: "installed bundle not found",
322-
installedBundle: &ocv1alpha1.BundleMetadata{
322+
installedBundle: ocv1alpha1.BundleMetadata{
323323
Name: "test-package.v9.0.0",
324324
Version: "9.0.0",
325325
},
@@ -368,7 +368,7 @@ func TestLegacySuccessor(t *testing.T) {
368368
},
369369
},
370370
}
371-
installedBundle := &ocv1alpha1.BundleMetadata{
371+
installedBundle := ocv1alpha1.BundleMetadata{
372372
Name: "package1.v0.0.1",
373373
Version: "0.0.1",
374374
}

0 commit comments

Comments
 (0)