Skip to content

Commit

Permalink
feat: introduces features fluent interface
Browse files Browse the repository at this point in the history
Extracts the fluent interface for Features from PR opendatahub-io#605. This allows other components to configure cluster resources using this interface before the original PR gets merged.

No changes to the reconcile logic have been introduced.
  • Loading branch information
bartoszmajsak committed Oct 25, 2023
1 parent f8a23a5 commit 3e36071
Show file tree
Hide file tree
Showing 44 changed files with 12,117 additions and 319 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ endef
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
# TODO: enable below when we do webhook
# $(CONTROLLER_GEN) rbac:roleName=controller-manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=controller-manager-role crd paths="./..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=controller-manager-role crd:ignoreUnexportedFields=true paths="./..." output:crd:artifacts:config=config/crd/bases
$(call fetch-external-crds,github.com/openshift/api,route/v1)
$(call fetch-external-crds,github.com/openshift/api,user/v1)

Expand Down Expand Up @@ -308,6 +308,8 @@ toolbox: ## Create a toolbox instance with the proper Golang and Operator SDK ve
toolbox create opendatahub-toolbox --image localhost/opendatahub-toolbox:latest

# Run tests.
TEST_SRC=./controllers/... ./tests/integration/features/...

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
Expand All @@ -318,7 +320,7 @@ test: unit-test e2e-test

.PHONY: unit-test
unit-test: envtest
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./controllers/... -v -coverprofile cover.out
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test $(TEST_SRC) -v -coverprofile cover.out

.PHONY: e2e-test
e2e-test: ## Run e2e tests for the controller
Expand Down
47 changes: 46 additions & 1 deletion apis/dscinitialization/v1/dscinitialization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,51 @@ type DSCInitializationList struct {
Items []DSCInitialization `json:"items"`
}

// FeatureTracker is a cluster-scoped resource for tracking objects
// created through Features API for Data Science Platform.
// It's primarily used as owner reference for resources created across namespaces so that they can be
// garbage collected by Kubernetes when they're not needed anymore.
// +kubebuilder:object:root=true
// +kubebuilder:resource:scope=Cluster
type FeatureTracker struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec FeatureTrackerSpec `json:"spec,omitempty"`
Status FeatureTrackerStatus `json:"status,omitempty"`
}

func (s *FeatureTracker) ToOwnerReference() metav1.OwnerReference {
return metav1.OwnerReference{
APIVersion: s.APIVersion,
Kind: s.Kind,
Name: s.Name,
UID: s.UID,
}
}

// FeatureTrackerSpec defines the desired state of FeatureTracker.
type FeatureTrackerSpec struct {
}

// FeatureTrackerStatus defines the observed state of FeatureTracker.
type FeatureTrackerStatus struct {
}

// +kubebuilder:object:root=true

// FeatureTrackerList contains a list of FeatureTracker.
type FeatureTrackerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []FeatureTracker `json:"items"`
}

func init() {
SchemeBuilder.Register(&DSCInitialization{}, &DSCInitializationList{})
SchemeBuilder.Register(
&DSCInitialization{},
&DSCInitializationList{},
&FeatureTracker{},
&FeatureTrackerList{},
)
}
89 changes: 89 additions & 0 deletions apis/dscinitialization/v1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: featuretrackers.dscinitialization.opendatahub.io
spec:
group: dscinitialization.opendatahub.io
names:
kind: FeatureTracker
listKind: FeatureTrackerList
plural: featuretrackers
singular: featuretracker
scope: Cluster
versions:
- name: v1
schema:
openAPIV3Schema:
description: FeatureTracker is a cluster-scoped resource for tracking objects
created through Features API for Data Science Platform. It's primarily used
as owner reference for resources created across namespaces so that they
can be garbage collected by Kubernetes when they're not needed anymore.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: FeatureTrackerSpec defines the desired state of FeatureTracker.
type: object
status:
description: FeatureTrackerStatus defines the observed state of FeatureTracker.
type: object
type: object
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: null
storedVersions: null
88 changes: 12 additions & 76 deletions bundle/manifests/opendatahub-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ metadata:
categories: AI/Machine Learning, Big Data
certified: "False"
containerImage: quay.io/opendatahub/opendatahub-operator:v2.1.0
createdAt: "2023-8-23T00:00:00Z"
createdAt: "2023-10-25T18:15:30Z"
olm.skipRange: '>=1.0.0 <2.0.0'
operatorframework.io/initialization-resource: |-
{
Expand Down Expand Up @@ -117,7 +117,7 @@ metadata:
}
}
}
operators.operatorframework.io/builder: operator-sdk-v1.24.1
operators.operatorframework.io/builder: operator-sdk-v1.32.0
operators.operatorframework.io/internal-objects: '[dscinitialization.opendatahub.io]'
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/opendatahub-io/opendatahub-operator
Expand Down Expand Up @@ -158,6 +158,9 @@ spec:
displayName: Conditions
path: conditions
version: v1
- kind: FeatureTracker
name: featuretrackers.dscinitialization.opendatahub.io
version: v1
description: "The Open Data Hub is a machine-learning-as-a-service platform built
on Red Hat's Kubernetes-based OpenShift® Container Platform. Open Data Hub integrates
multiple AI/ML open source components into one operator that can easily be downloaded
Expand Down Expand Up @@ -901,54 +904,6 @@ spec:
- seldondeployments
verbs:
- '*'
- apiGroups:
- maistra.io
resources:
- servicemeshcontrolplanes
verbs:
- create
- get
- list
- patch
- update
- use
- watch
- apiGroups:
- maistra.io
resources:
- servicemeshmemberrolls
verbs:
- create
- get
- list
- patch
- update
- use
- watch
- apiGroups:
- maistra.io
resources:
- servicemeshmembers
verbs:
- create
- get
- list
- patch
- update
- use
- watch
- apiGroups:
- maistra.io
resources:
- servicemeshmembers/finalizers
verbs:
- create
- get
- list
- patch
- update
- use
- watch
- apiGroups:
- mcad.ibm.com
resources:
Expand Down Expand Up @@ -1001,32 +956,6 @@ spec:
- patch
- update
- watch
- apiGroups:
- networking.istio.io
resources:
- virtualservices
verbs:
- '*'
- apiGroups:
- networking.istio.io
resources:
- virtualservices/finalizers
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- networking.istio.io
resources:
- virtualservices/status
verbs:
- delete
- patch
- update
- apiGroups:
- networking.k8s.io
resources:
Expand Down Expand Up @@ -1194,6 +1123,13 @@ spec:
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- create
- get
- apiGroups:
- security.openshift.io
resources:
Expand Down
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ annotations:
operators.operatorframework.io.bundle.package.v1: opendatahub-operator
operators.operatorframework.io.bundle.channels.v1: fast
operators.operatorframework.io.bundle.channel.default.v1: fast
operators.operatorframework.io.metrics.builder: operator-sdk-v1.24.1
operators.operatorframework.io.metrics.builder: operator-sdk-v1.32.0
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
Loading

0 comments on commit 3e36071

Please sign in to comment.