Skip to content

Commit 17359ee

Browse files
authored
Merge pull request #480 from jpeeler/add-operator-group
add OperatorGroup
2 parents 5cbe455 + b49c9bc commit 17359ee

File tree

31 files changed

+2035
-75
lines changed

31 files changed

+2035
-75
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,9 @@ clean-openapi:
124124

125125
codegen-openapi: clean-openapi pkg/package-server/generated/openapi/zz_generated.openapi.go
126126

127+
# our version of hack/update-codegen.sh
127128
codegen: $(CODEGEN)
128-
$(CODEGEN) all $(PKG)/pkg/api/client $(PKG)/pkg/api/apis "operators:v1alpha1"
129+
$(CODEGEN) all $(PKG)/pkg/api/client $(PKG)/pkg/api/apis "operators:v1alpha1,v1alpha2"
129130
$(CODEGEN) all $(PKG)/pkg/package-server/client $(PKG)/pkg/package-server/apis "packagemanifest:v1alpha1"
130131

131132
verify-codegen: codegen
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
apiVersion: apiextensions.k8s.io/v1beta1
2+
kind: CustomResourceDefinition
3+
metadata:
4+
name: operatorgroups.operators.coreos.com
5+
spec:
6+
group: operators.coreos.com
7+
version: v1alpha2
8+
versions:
9+
- name: v1alpha2
10+
served: true
11+
storage: true
12+
names:
13+
plural: operatorgroups
14+
singular: operatorgroup
15+
kind: OperatorGroup
16+
listKind: OperatorGroupList
17+
scope: Namespaced
18+
subresources:
19+
# status enables the status subresource.
20+
status: {}
21+
validation:
22+
openAPIV3Schema:
23+
properties:
24+
spec:
25+
properties:
26+
selector:
27+
type: object
28+
serviceAccountName:
29+
type: string
30+
required:
31+
- selector
32+
type: object
33+
status:
34+
properties:
35+
lastUpdated:
36+
format: date-time
37+
type: string
38+
namespaces:
39+
items:
40+
type: object
41+
type: array
42+
required:
43+
- namespaces
44+
- lastUpdated
45+
type: object
46+
required:
47+
- metadata
48+
- spec
49+
version: v1alpha2

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ const (
196196
CSVReasonReplaced ConditionReason = "Replaced"
197197
CSVReasonNeedCertRotation ConditionReason = "NeedCertRotation"
198198
CSVReasonAPIServiceResourceIssue ConditionReason = "APIServiceResourceIssue"
199+
CSVReasonCopied ConditionReason = "Copied"
199200
)
200201

201202
// Conditions appear in the status as a record of state transitions on the ClusterServiceVersion
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// +k8s:deepcopy-gen=package
2+
// +groupName=operators.coreos.com
3+
package v1alpha2
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package v1alpha2
2+
3+
import (
4+
corev1 "k8s.io/api/core/v1"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
)
7+
8+
type OperatorGroupSpec struct {
9+
Selector metav1.LabelSelector `json:"selector,omitempty"`
10+
ServiceAccount corev1.ServiceAccount `json:"serviceAccount,omitempty"`
11+
}
12+
13+
type OperatorGroupStatus struct {
14+
Namespaces []*corev1.Namespace `json:"namespaces"`
15+
LastUpdated metav1.Time `json:"lastUpdated"`
16+
}
17+
18+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
19+
// +genclient
20+
type OperatorGroup struct {
21+
metav1.TypeMeta `json:",inline"`
22+
metav1.ObjectMeta `json:"metadata"`
23+
24+
Spec OperatorGroupSpec `json:"spec"`
25+
Status OperatorGroupStatus `json:"status,omitempty"`
26+
}
27+
28+
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
29+
type OperatorGroupList struct {
30+
metav1.TypeMeta `json:",inline"`
31+
metav1.ListMeta `json:"metadata"`
32+
33+
Items []OperatorGroup `json:"items"`
34+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package v1alpha2
2+
3+
import (
4+
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme"
5+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
6+
"k8s.io/apimachinery/pkg/runtime"
7+
"k8s.io/apimachinery/pkg/runtime/schema"
8+
k8sscheme "k8s.io/client-go/kubernetes/scheme"
9+
10+
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
11+
)
12+
13+
const (
14+
GroupName = "operators.coreos.com"
15+
GroupVersion = "v1alpha2"
16+
)
17+
18+
// SchemeGroupVersion is group version used to register these objects
19+
var SchemeGroupVersion = schema.GroupVersion{Group: operators.GroupName, Version: GroupVersion}
20+
21+
// Kind takes an unqualified kind and returns back a Group qualified GroupKind
22+
func Kind(kind string) schema.GroupKind {
23+
return SchemeGroupVersion.WithKind(kind).GroupKind()
24+
}
25+
26+
// Resource takes an unqualified resource and returns a Group qualified GroupResource
27+
func Resource(resource string) schema.GroupResource {
28+
return SchemeGroupVersion.WithResource(resource).GroupResource()
29+
}
30+
31+
var (
32+
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
33+
AddToScheme = SchemeBuilder.AddToScheme
34+
serScheme = runtime.NewScheme()
35+
)
36+
37+
func init() {
38+
k8sscheme.AddToScheme(serScheme)
39+
scheme.AddToScheme(serScheme)
40+
}
41+
42+
// Adds the list of known types to Scheme.
43+
func addKnownTypes(scheme *runtime.Scheme) error {
44+
scheme.AddKnownTypes(SchemeGroupVersion,
45+
&OperatorGroup{},
46+
&OperatorGroupList{},
47+
)
48+
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
49+
return nil
50+
}

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

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

pkg/api/client/clientset/versioned/clientset.go

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

pkg/api/client/clientset/versioned/fake/clientset_generated.go

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

pkg/api/client/clientset/versioned/fake/register.go

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

0 commit comments

Comments
 (0)