Skip to content

Commit

Permalink
Merge pull request operator-framework#423 from njhale/subscription-cu…
Browse files Browse the repository at this point in the history
…rrent-csv

feat(subscription): add dedicated currentCSV field to subscription
  • Loading branch information
njhale authored Aug 17, 2018
2 parents ba2771d + c328605 commit ac948c8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
5 changes: 3 additions & 2 deletions pkg/api/apis/operators/v1alpha1/subscription_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ type Subscription struct {
}

type SubscriptionStatus struct {
CurrentCSV string `json:"installedCSV,omitempty"`
Install *InstallPlanReference `json:"installplan,omitempty"`
CurrentCSV string `json:"currentCSV,omitempty"`
InstalledCSV string `json:"installedCSV, omitempty"`
Install *InstallPlanReference `json:"installplan,omitempty"`

State SubscriptionState `json:"state,omitempty"`
Reason ConditionReason `json:"reason,omitempty"`
Expand Down
3 changes: 3 additions & 0 deletions pkg/controller/operators/catalog/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ func (o *Operator) syncSubscription(in *v1alpha1.Subscription) (*v1alpha1.Subscr
return out, nil
}

// Set the installed CSV
out.Status.InstalledCSV = out.Status.CurrentCSV

// Poll catalog for an update
repl, err := catalog.FindReplacementCSVForPackageNameUnderChannel(out.Spec.Package, out.Spec.Channel, out.Status.CurrentCSV)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions pkg/controller/operators/catalog/subscriptions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -813,9 +813,10 @@ func TestSyncSubscription(t *testing.T) {
Channel: "magical",
},
Status: v1alpha1.SubscriptionStatus{
CurrentCSV: "next",
Install: nil,
State: v1alpha1.SubscriptionStateUpgradeAvailable,
CurrentCSV: "next",
InstalledCSV: "toupgrade",
Install: nil,
State: v1alpha1.SubscriptionStateUpgradeAvailable,
},
},
},
Expand Down

0 comments on commit ac948c8

Please sign in to comment.