Skip to content

Commit 663537d

Browse files
Merge pull request #1623 from ankitathomas/plural_resource_in_relatedObjects
Bug 1851213: Set Resource to plural in CSV RelatedObjects field
2 parents 82ab614 + adeb8ab commit 663537d

File tree

4 files changed

+21
-18
lines changed

4 files changed

+21
-18
lines changed

pkg/lib/operatorstatus/builder_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -336,15 +336,15 @@ func TestBuilder(t *testing.T) {
336336
{
337337
name: "WithRelatedObject/ReferenceNotPresentInStatus",
338338
action: func(b *Builder) {
339-
b.WithRelatedObject("group", "resource", "namespace", "name")
339+
b.WithRelatedObject("group", "resources", "namespace", "name")
340340
},
341341
expected: &configv1.ClusterOperatorStatus{
342342
Conditions: []configv1.ClusterOperatorStatusCondition{},
343343
Versions: []configv1.OperandVersion{},
344344
RelatedObjects: []configv1.ObjectReference{
345345
configv1.ObjectReference{
346346
Group: "group",
347-
Resource: "resource",
347+
Resource: "resources",
348348
Namespace: "namespace",
349349
Name: "name",
350350
},
@@ -357,15 +357,15 @@ func TestBuilder(t *testing.T) {
357357
{
358358
name: "WithRelatedObject/ReferencePresentInStatus",
359359
action: func(b *Builder) {
360-
b.WithRelatedObject("group", "resource", "namespace", "name")
360+
b.WithRelatedObject("group", "resources", "namespace", "name")
361361
},
362362
existing: &configv1.ClusterOperatorStatus{
363363
Conditions: []configv1.ClusterOperatorStatusCondition{},
364364
Versions: []configv1.OperandVersion{},
365365
RelatedObjects: []configv1.ObjectReference{
366366
configv1.ObjectReference{
367367
Group: "group",
368-
Resource: "resource",
368+
Resource: "resources",
369369
Namespace: "namespace",
370370
Name: "name",
371371
},
@@ -377,7 +377,7 @@ func TestBuilder(t *testing.T) {
377377
RelatedObjects: []configv1.ObjectReference{
378378
configv1.ObjectReference{
379379
Group: "group",
380-
Resource: "resource",
380+
Resource: "resources",
381381
Namespace: "namespace",
382382
Name: "name",
383383
},
@@ -390,15 +390,15 @@ func TestBuilder(t *testing.T) {
390390
{
391391
name: "WithoutRelatedObject/ReferenceBeingRemoved",
392392
action: func(b *Builder) {
393-
b.WithoutRelatedObject("group", "resource", "namespace", "name")
393+
b.WithoutRelatedObject("group", "resources", "namespace", "name")
394394
},
395395
existing: &configv1.ClusterOperatorStatus{
396396
Conditions: []configv1.ClusterOperatorStatusCondition{},
397397
Versions: []configv1.OperandVersion{},
398398
RelatedObjects: []configv1.ObjectReference{
399399
configv1.ObjectReference{
400400
Group: "group",
401-
Resource: "resource",
401+
Resource: "resources",
402402
Namespace: "namespace",
403403
Name: "name",
404404
},

pkg/lib/operatorstatus/csv_reporter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func newCSVStatusReporter(releaseVersion string) *csvStatusReporter {
2121
}
2222
}
2323

24-
// csvStatusReporter provides the logic for initialzing ClusterOperator and
24+
// csvStatusReporter provides the logic for initializing ClusterOperator and
2525
// ClusterOperatorStatus types.
2626
type csvStatusReporter struct {
2727
clock clock.Clock
@@ -76,7 +76,7 @@ func (r *csvStatusReporter) GetNewStatus(existing *configv1.ClusterOperatorStatu
7676
gvk := csv.GetObjectKind().GroupVersionKind()
7777

7878
builder.WithoutVersion(csv.GetName(), csv.Spec.Version.String()).
79-
WithoutRelatedObject(gvk.Group, gvk.Kind, csv.GetNamespace(), csv.GetName())
79+
WithoutRelatedObject(gvk.Group, clusterServiceVersionResource, csv.GetNamespace(), csv.GetName())
8080

8181
if context.WorkingToward == nil {
8282
builder.WithProgressing(configv1.ConditionFalse, fmt.Sprintf("Uninstalled version %s", csv.Spec.Version)).
@@ -94,7 +94,7 @@ func (r *csvStatusReporter) GetNewStatus(existing *configv1.ClusterOperatorStatu
9494

9595
gvk := csv.GetObjectKind().GroupVersionKind()
9696
builder.WithRelatedObject("", "namespaces", "", csv.GetNamespace()).
97-
WithRelatedObject(gvk.Group, gvk.Kind, csv.GetNamespace(), csv.GetName())
97+
WithRelatedObject(gvk.Group, clusterServiceVersionResource, csv.GetNamespace(), csv.GetName())
9898

9999
switch phase {
100100
case v1alpha1.CSVPhaseSucceeded:

pkg/lib/operatorstatus/csv_reporter_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ func TestGetNewStatus(t *testing.T) {
8383
},
8484
{
8585
Group: v1alpha1.GroupName,
86-
Resource: v1alpha1.ClusterServiceVersionKind,
86+
Resource: clusterServiceVersionResource,
8787
Namespace: "foo-namespace",
8888
Name: "foo",
8989
},
@@ -159,7 +159,7 @@ func TestGetNewStatus(t *testing.T) {
159159
},
160160
{
161161
Group: v1alpha1.GroupName,
162-
Resource: v1alpha1.ClusterServiceVersionKind,
162+
Resource: clusterServiceVersionResource,
163163
Namespace: "foo-namespace",
164164
Name: "foo",
165165
},

pkg/lib/operatorstatus/status.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,12 @@ import (
2525
)
2626

2727
const (
28-
clusterOperatorOLM = "operator-lifecycle-manager"
29-
clusterOperatorCatalogSource = "operator-lifecycle-manager-catalog"
30-
openshiftNamespace = "openshift-operator-lifecycle-manager"
28+
clusterOperatorOLM = "operator-lifecycle-manager"
29+
clusterOperatorCatalogSource = "operator-lifecycle-manager-catalog"
30+
openshiftNamespace = "openshift-operator-lifecycle-manager"
31+
clusterServiceVersionResource = "clusterserviceversions"
32+
subscriptionResource = "subscriptions"
33+
installPlanResource = "installplans"
3134
)
3235

3336
func MonitorClusterStatus(name string, syncCh <-chan error, stopCh <-chan struct{}, opClient operatorclient.ClientInterface, configClient configv1client.ConfigV1Interface, crClient versioned.Interface) {
@@ -280,7 +283,7 @@ func relatedObjects(name string, opClient operatorclient.ClientInterface, crClie
280283
}
281284
objectReferences = append(objectReferences, configv1.ObjectReference{
282285
Group: olmv1alpha1.GroupName,
283-
Resource: olmv1alpha1.ClusterServiceVersionKind,
286+
Resource: clusterServiceVersionResource,
284287
Namespace: csv.GetNamespace(),
285288
Name: csv.GetName(),
286289
})
@@ -299,15 +302,15 @@ func relatedObjects(name string, opClient operatorclient.ClientInterface, crClie
299302
for _, sub := range subList.Items {
300303
objectReferences = append(objectReferences, configv1.ObjectReference{
301304
Group: olmv1alpha1.GroupName,
302-
Resource: olmv1alpha1.SubscriptionKind,
305+
Resource: subscriptionResource,
303306
Namespace: sub.GetNamespace(),
304307
Name: sub.GetName(),
305308
})
306309
}
307310
for _, ip := range installPlanList.Items {
308311
objectReferences = append(objectReferences, configv1.ObjectReference{
309312
Group: olmv1alpha1.GroupName,
310-
Resource: olmv1alpha1.InstallPlanKind,
313+
Resource: installPlanResource,
311314
Namespace: ip.GetNamespace(),
312315
Name: ip.GetName(),
313316
})

0 commit comments

Comments
 (0)