Skip to content

Commit 64d8d37

Browse files
committed
fix(secret): use a synthetic kind instead of an api field to determine
bundle secrets from pull secrets
1 parent cd0f8e8 commit 64d8d37

File tree

6 files changed

+17
-28
lines changed

6 files changed

+17
-28
lines changed

pkg/api/apis/operators/installplan_types.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -354,10 +354,6 @@ type StepResource struct {
354354
Kind string
355355
Name string
356356
Manifest string
357-
// BundleSecret is a one-off flag for handling secrets from a user bundle versus from the catalog source.
358-
// This field is handled internally by OLM and should not be exposed by the API.
359-
// Longer term StepResources will be refactored.
360-
BundleSecret bool
361357
}
362358

363359
func (r StepResource) String() string {

pkg/api/apis/operators/v1alpha1/installplan_types.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,6 @@ type StepResource struct {
322322
Kind string `json:"kind"`
323323
Name string `json:"name"`
324324
Manifest string `json:"manifest,omitempty"`
325-
BundleSecret bool `json:"bundleSecret"`
326325
}
327326

328327
func (r StepResource) String() string {

pkg/api/apis/operators/v1alpha1/zz_generated.conversion.go

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

pkg/controller/operators/catalog/operator.go

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,22 +1523,20 @@ func (o *Operator) ExecutePlan(plan *v1alpha1.InstallPlan) error {
15231523

15241524
plan.Status.Plan[i].Status = status
15251525

1526-
case secretKind:
1527-
if step.Resource.BundleSecret {
1528-
var s corev1.Secret
1529-
err := json.Unmarshal([]byte(step.Resource.Manifest), &s)
1530-
if err != nil {
1531-
return errorwrap.Wrapf(err, "error parsing step manifest: %s", step.Resource.Name)
1532-
}
1533-
status, err := ensurer.EnsureBundleSecret(plan.Namespace, &s)
1534-
if err != nil {
1535-
return err
1536-
}
1537-
1538-
plan.Status.Plan[i].Status = status
1539-
continue
1526+
case resolver.BundleSecretKind:
1527+
var s corev1.Secret
1528+
err := json.Unmarshal([]byte(step.Resource.Manifest), &s)
1529+
if err != nil {
1530+
return errorwrap.Wrapf(err, "error parsing step manifest: %s", step.Resource.Name)
1531+
}
1532+
status, err := ensurer.EnsureBundleSecret(plan.Namespace, &s)
1533+
if err != nil {
1534+
return err
15401535
}
15411536

1537+
plan.Status.Plan[i].Status = status
1538+
1539+
case secretKind:
15421540
status, err := ensurer.EnsureSecret(o.namespace, plan.GetNamespace(), step.Resource.Name)
15431541
if err != nil {
15441542
return err

pkg/controller/operators/catalog/operator_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,10 +434,9 @@ func TestExecutePlan(t *testing.T) {
434434
CatalogSourceNamespace: namespace,
435435
Group: "",
436436
Version: "v1",
437-
Kind: "Secret",
437+
Kind: "BundleSecret",
438438
Name: "s",
439439
Manifest: toManifest(t, secret("s", namespace)),
440-
BundleSecret: true,
441440
},
442441
Status: v1alpha1.StepStatusUnknown,
443442
},
@@ -459,7 +458,6 @@ func TestExecutePlan(t *testing.T) {
459458
Kind: "Secret",
460459
Name: "s",
461460
Manifest: toManifest(t, secret("s", namespace)),
462-
BundleSecret: false,
463461
},
464462
Status: v1alpha1.StepStatusUnknown,
465463
},

pkg/controller/registry/resolver/steps.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222

2323
const (
2424
secretKind = "Secret"
25+
BundleSecretKind = "BundleSecret"
2526
)
2627

2728
var (
@@ -75,11 +76,10 @@ func NewStepResourceFromObject(obj runtime.Object, catalogSourceName, catalogSou
7576
CatalogSourceNamespace: catalogSourceNamespace,
7677
}
7778

78-
// Treat secret objects with a special case
79-
// OLM copies secrets as well as supports creating new ones from the bundle
80-
// This boolean determines whether its a user-created secret
79+
// BundleSecret is a synthetic kind that OLM uses to distinguish between secrets included in the bundle and
80+
// pull secrets included in the installplan
8181
if obj.GetObjectKind().GroupVersionKind().Kind == secretKind {
82-
resource.BundleSecret = true
82+
resource.Kind = BundleSecretKind
8383
}
8484

8585
return resource, nil

0 commit comments

Comments
 (0)