Skip to content

Commit 4b04955

Browse files
Merge pull request #892 from tkashem/user-defined-sa
Add support for user defined ServiceAccount for OperatorGroup.
2 parents 6b7c693 + 5c992e0 commit 4b04955

23 files changed

+1438
-193
lines changed

cmd/olm/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ func main() {
162162
olm.WithResyncPeriod(*wakeupInterval),
163163
olm.WithExternalClient(crClient),
164164
olm.WithOperatorClient(opClient),
165+
olm.WithRestConfig(config),
165166
)
166167
if err != nil {
167168
log.Fatalf("error configuring operator: %s", err.Error())

pkg/api/apis/operators/operatorgroup_types.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ type OperatorGroupSpec struct {
2929
// +optional
3030
TargetNamespaces []string
3131

32-
// ServiceAccount to bind OperatorGroup roles to.
33-
ServiceAccount corev1.ServiceAccount
32+
// ServiceAccountName is the admin specified service account which will be
33+
// used to deploy operator(s) in this operator group.
34+
ServiceAccountName string
3435

3536
// Static tells OLM not to update the OperatorGroup's providedAPIs annotation
3637
// +optional
@@ -42,6 +43,9 @@ type OperatorGroupStatus struct {
4243
// Namespaces is the set of target namespaces for the OperatorGroup.
4344
Namespaces []string
4445

46+
// ServiceAccountRef references the service account object specified.
47+
ServiceAccountRef *corev1.ObjectReference
48+
4549
// LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated.
4650
LastUpdated metav1.Time
4751
}

pkg/api/apis/operators/v1/operatorgroup_types.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ type OperatorGroupSpec struct {
2828
// +optional
2929
TargetNamespaces []string `json:"targetNamespaces,omitempty"`
3030

31-
// ServiceAccount to bind OperatorGroup roles to.
32-
ServiceAccount corev1.ServiceAccount `json:"serviceAccount,omitempty"`
31+
// ServiceAccountName is the admin specified service account which will be
32+
// used to deploy operator(s) in this operator group.
33+
ServiceAccountName string `json:"serviceAccountName,omitempty"`
3334

3435
// Static tells OLM not to update the OperatorGroup's providedAPIs annotation
3536
// +optional
@@ -41,6 +42,9 @@ type OperatorGroupStatus struct {
4142
// Namespaces is the set of target namespaces for the OperatorGroup.
4243
Namespaces []string `json:"namespaces,omitempty"`
4344

45+
// ServiceAccountRef references the service account object specified.
46+
ServiceAccountRef *corev1.ObjectReference `json:"serviceAccountRef,omitempty"`
47+
4448
// LastUpdated is a timestamp of the last time the OperatorGroup's status was Updated.
4549
LastUpdated metav1.Time `json:"lastUpdated"`
4650
}
@@ -72,3 +76,21 @@ func (o *OperatorGroup) BuildTargetNamespaces() string {
7276
sort.Strings(o.Status.Namespaces)
7377
return strings.Join(o.Status.Namespaces, ",")
7478
}
79+
80+
// IsServiceAccountSpecified returns true if the spec has a service account name specified.
81+
func (o *OperatorGroup) IsServiceAccountSpecified() bool {
82+
if o.Spec.ServiceAccountName == "" {
83+
return false
84+
}
85+
86+
return true
87+
}
88+
89+
// HasServiceAccountSynced returns true if the service account specified has been synced.
90+
func (o *OperatorGroup) HasServiceAccountSynced() bool {
91+
if o.IsServiceAccountSpecified() && o.Status.ServiceAccountRef != nil {
92+
return true
93+
}
94+
95+
return false
96+
}

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

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

pkg/api/apis/operators/v1/zz_generated.deepcopy.go

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/api/apis/operators/zz_generated.deepcopy.go

Lines changed: 5 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)