Skip to content

Commit

Permalink
Merge pull request #480 from jpeeler/add-operator-group
Browse files Browse the repository at this point in the history
add OperatorGroup
  • Loading branch information
ecordell authored Nov 7, 2018
2 parents 5cbe455 + b49c9bc commit 17359ee
Show file tree
Hide file tree
Showing 31 changed files with 2,035 additions and 75 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ clean-openapi:

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

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

verify-codegen: codegen
Expand Down
49 changes: 49 additions & 0 deletions deploy/chart/templates/0000_30_14-operatorgroup.crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: operatorgroups.operators.coreos.com
spec:
group: operators.coreos.com
version: v1alpha2
versions:
- name: v1alpha2
served: true
storage: true
names:
plural: operatorgroups
singular: operatorgroup
kind: OperatorGroup
listKind: OperatorGroupList
scope: Namespaced
subresources:
# status enables the status subresource.
status: {}
validation:
openAPIV3Schema:
properties:
spec:
properties:
selector:
type: object
serviceAccountName:
type: string
required:
- selector
type: object
status:
properties:
lastUpdated:
format: date-time
type: string
namespaces:
items:
type: object
type: array
required:
- namespaces
- lastUpdated
type: object
required:
- metadata
- spec
version: v1alpha2
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ const (
CSVReasonReplaced ConditionReason = "Replaced"
CSVReasonNeedCertRotation ConditionReason = "NeedCertRotation"
CSVReasonAPIServiceResourceIssue ConditionReason = "APIServiceResourceIssue"
CSVReasonCopied ConditionReason = "Copied"
)

// Conditions appear in the status as a record of state transitions on the ClusterServiceVersion
Expand Down
3 changes: 3 additions & 0 deletions pkg/api/apis/operators/v1alpha2/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// +k8s:deepcopy-gen=package
// +groupName=operators.coreos.com
package v1alpha2
34 changes: 34 additions & 0 deletions pkg/api/apis/operators/v1alpha2/operatorgroup_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package v1alpha2

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

type OperatorGroupSpec struct {
Selector metav1.LabelSelector `json:"selector,omitempty"`
ServiceAccount corev1.ServiceAccount `json:"serviceAccount,omitempty"`
}

type OperatorGroupStatus struct {
Namespaces []*corev1.Namespace `json:"namespaces"`
LastUpdated metav1.Time `json:"lastUpdated"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +genclient
type OperatorGroup struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata"`

Spec OperatorGroupSpec `json:"spec"`
Status OperatorGroupStatus `json:"status,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
type OperatorGroupList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata"`

Items []OperatorGroup `json:"items"`
}
50 changes: 50 additions & 0 deletions pkg/api/apis/operators/v1alpha2/register.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package v1alpha2

import (
"k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset/scheme"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
k8sscheme "k8s.io/client-go/kubernetes/scheme"

"github.com/operator-framework/operator-lifecycle-manager/pkg/api/apis/operators"
)

const (
GroupName = "operators.coreos.com"
GroupVersion = "v1alpha2"
)

// SchemeGroupVersion is group version used to register these objects
var SchemeGroupVersion = schema.GroupVersion{Group: operators.GroupName, Version: GroupVersion}

// Kind takes an unqualified kind and returns back a Group qualified GroupKind
func Kind(kind string) schema.GroupKind {
return SchemeGroupVersion.WithKind(kind).GroupKind()
}

// Resource takes an unqualified resource and returns a Group qualified GroupResource
func Resource(resource string) schema.GroupResource {
return SchemeGroupVersion.WithResource(resource).GroupResource()
}

var (
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
AddToScheme = SchemeBuilder.AddToScheme
serScheme = runtime.NewScheme()
)

func init() {
k8sscheme.AddToScheme(serScheme)
scheme.AddToScheme(serScheme)
}

// Adds the list of known types to Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(SchemeGroupVersion,
&OperatorGroup{},
&OperatorGroupList{},
)
metav1.AddToGroupVersion(scheme, SchemeGroupVersion)
return nil
}
134 changes: 134 additions & 0 deletions pkg/api/apis/operators/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions pkg/api/client/clientset/versioned/clientset.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pkg/api/client/clientset/versioned/fake/register.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 17359ee

Please sign in to comment.