Skip to content

feat: Add a new CRD as a simplied OperandRequest #644

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,26 @@ layout: go.kubebuilder.io/v3
projectName: operand-deployment-lifecycle-manager
repo: github.com/IBM/operand-deployment-lifecycle-manager
resources:
- group: operator
- crdVersion: v1
group: operator
kind: OperandRequest
version: v1alpha1
- group: operator
- crdVersion: v1
group: operator
kind: OperandRegistry
version: v1alpha1
- group: operator
- crdVersion: v1
group: operator
kind: OperandConfig
version: v1alpha1
- group: operator
- crdVersion: v1
group: operator
kind: OperandBindInfo
version: v1alpha1
- crdVersion: v1
group: operator
kind: ComposableOperatorRequest
version: v1alpha1
version: 3-alpha
plugins:
manifests.sdk.operatorframework.io/v2: {}
Expand Down
90 changes: 90 additions & 0 deletions api/v1alpha1/composableoperatorrequest_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// Copyright 2021 IBM Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package v1alpha1

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

// OperatorRequestPhase is the phase of the ComposableOperatorRequest.
type OperatorRequestPhase string

const (
ComposableInstalling OperatorRequestPhase = "Installing"
ComposableUpdating OperatorRequestPhase = "Updating"
ComposableFailed OperatorRequestPhase = "Failed"
ComposableInit OperatorRequestPhase = "Initializing"
ComposableRunning OperatorRequestPhase = "Running"
ComposableNone OperatorRequestPhase = ""
)

// ComposableOperatorRequestSpec defines the desired state of ComposableOperatorRequest
type ComposableOperatorRequestSpec struct {
// +operator-sdk:csv:customresourcedefinitions:type=spec,displayName="Composable Components"
ComposableComponents []Component `json:"composableComponents"`
}

// Component is used to enable or disable operators.
type Component struct {
// OperatorName the name of the Operator.
OperatorName string `json:"name"`
// Enabled indicates if the operator is enabled
Enabled bool `json:"enabled"`
}

// ComposableOperatorRequestStatus defines the observed state of ComposableOperatorRequest
type ComposableOperatorRequestStatus struct {
// Phase is the cluster running phase.
// +operator-sdk:csv:customresourcedefinitions:type=status,displayName="Phase",xDescriptors="urn:alm:descriptor:io.kubernetes.phase"
// +optional
Phase OperatorRequestPhase `json:"phase,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// ComposableOperatorRequest is the Schema for the composableoperatorrequests API
type ComposableOperatorRequest struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ComposableOperatorRequestSpec `json:"spec,omitempty"`
Status ComposableOperatorRequestStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

//InitRequestStatus initializes OperandRequest status.
func (r *ComposableOperatorRequest) InitRequestStatus() bool {
isInitialized := true
if r.Status.Phase == "" {
isInitialized = false
r.Status.Phase = ComposableInit
}
return isInitialized
}

func init() {
SchemeBuilder.Register(&ComposableOperatorRequest{}, &ComposableOperatorRequestList{})
}
4 changes: 2 additions & 2 deletions api/v1alpha1/operandrequest_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ func (r *OperandRequest) UpdateClusterPhase() {
r.SetClusterPhase(clusterPhase)
}

// GetRegistryKey Set the default value for Request spec.
// GetRegistryKey sets the default value for Request spec.
func (r *OperandRequest) GetRegistryKey(req Request) types.NamespacedName {
regName := req.Registry
regNs := req.RegistryNamespace
Expand All @@ -464,7 +464,7 @@ func (r *OperandRequest) GetRegistryKey(req Request) types.NamespacedName {
return types.NamespacedName{Namespace: regNs, Name: regName}
}

//InitRequestStatus OperandConfig status.
//InitRequestStatus initializes OperandRequest status.
func (r *OperandRequest) InitRequestStatus() bool {
isInitialized := true
if r.Status.Phase == "" {
Expand Down
109 changes: 109 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=ibm-odlm
LABEL operators.operatorframework.io.bundle.channels.v1=v1,beta
LABEL operators.operatorframework.io.bundle.channels.v1=v3,beta
LABEL operators.operatorframework.io.bundle.channel.default.v1=v3
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.3.0
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ spec:
apiservicedefinitions: {}
customresourcedefinitions:
owned:
- description: ComposableOperatorRequest is the Schema for the composableoperatorrequests API
displayName: Composable Operator Request
kind: ComposableOperatorRequest
name: composableoperatorrequests.operator.ibm.com
specDescriptors:
- displayName: Composable Components
path: composableComponents
statusDescriptors:
- description: Phase is the cluster running phase.
displayName: Phase
path: phase
x-descriptors:
- urn:alm:descriptor:io.kubernetes.phase
version: v1alpha1
- description: OperandBindInfo is the Schema for the operandbindinfoes API.
displayName: OperandBindInfo
kind: OperandBindInfo
Expand Down
72 changes: 72 additions & 0 deletions bundle/manifests/operator.ibm.com_composableoperatorrequests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.0
creationTimestamp: null
labels:
app.kubernetes.io/instance: operand-deployment-lifecycle-manager
app.kubernetes.io/managed-by: operand-deployment-lifecycle-manager
app.kubernetes.io/name: operand-deployment-lifecycle-manager
name: composableoperatorrequests.operator.ibm.com
spec:
group: operator.ibm.com
names:
kind: ComposableOperatorRequest
listKind: ComposableOperatorRequestList
plural: composableoperatorrequests
singular: composableoperatorrequest
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: ComposableOperatorRequest is the Schema for the composableoperatorrequests API
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: ComposableOperatorRequestSpec defines the desired state of ComposableOperatorRequest
properties:
composableComponents:
items:
description: Component is used to enable or disable operators.
properties:
enabled:
description: Enabled indicates if the operator is enabled
type: boolean
name:
description: OperatorName the name of the Operator.
type: string
required:
- enabled
- name
type: object
type: array
required:
- composableComponents
type: object
status:
description: ComposableOperatorRequestStatus defines the observed state of ComposableOperatorRequest
properties:
phase:
description: Phase is the cluster running phase.
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading