Skip to content

Commit

Permalink
controllers: add StorageClassClaim api and controller
Browse files Browse the repository at this point in the history
Signed-off-by: Jose A. Rivera <[email protected]>
  • Loading branch information
jarrpa committed Aug 22, 2022
1 parent 3c61ead commit 7092b00
Show file tree
Hide file tree
Showing 15 changed files with 975 additions and 3 deletions.
9 changes: 9 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ resources:
kind: OcsClient
path: github.com/red-hat-storage/ocs-client-operator/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: openshift.io
group: odf
kind: StorageClassClaim
path: github.com/red-hat-storage/ocs-client-operator/api/v1alpha1
version: v1alpha1
version: "3"
81 changes: 81 additions & 0 deletions api/v1alpha1/storageclassclaim_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2020 Red Hat, Inc.
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"
)

// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// StorageClassClaimSpec defines the desired state of StorageClassClaim
type StorageClassClaimSpec struct {
//+kubebuilder:validation:Enum=blockpool;sharedfilesystem
Type string `json:"type"`
EncryptionMethod string `json:"encryptionMethod,omitempty"`
}

type storageClassClaimState string

const (
// StorageClassClaimInitializing represents Initializing state of StorageClassClaim
StorageClassClaimInitializing storageClassClaimState = "Initializing"
// StorageClassClaimValidating represents Validating state of StorageClassClaim
StorageClassClaimValidating storageClassClaimState = "Validating"
// StorageClassClaimFailed represents Failed state of StorageClassClaim
StorageClassClaimFailed storageClassClaimState = "Failed"
// StorageClassClaimCreating represents Configuring state of StorageClassClaim
StorageClassClaimCreating storageClassClaimState = "Creating"
// StorageClassClaimConfiguring represents Configuring state of StorageClassClaim
StorageClassClaimConfiguring storageClassClaimState = "Configuring"
// StorageClassClaimReady represents Ready state of StorageClassClaim
StorageClassClaimReady storageClassClaimState = "Ready"
// StorageClassClaimDeleting represents Deleting state of StorageClassClaim
StorageClassClaimDeleting storageClassClaimState = "Deleting"
)

// StorageClassClaimStatus defines the observed state of StorageClassClaim
type StorageClassClaimStatus struct {
Phase storageClassClaimState `json:"phase,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:printcolumn:name="StorageType",type="string",JSONPath=".spec.type"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

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

Spec StorageClassClaimSpec `json:"spec,omitempty"`
Status StorageClassClaimStatus `json:"status,omitempty"`
}

// +kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&StorageClassClaim{}, &StorageClassClaimList{})
}
89 changes: 89 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.

53 changes: 53 additions & 0 deletions bundle/manifests/ocs-client-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ metadata:
"name": "ocsclient-sample"
},
"spec": null
},
{
"apiVersion": "odf.openshift.io/v1alpha1",
"kind": "StorageClassClaim",
"metadata": {
"name": "storageclassclaim-sample"
},
"spec": null
}
]
capabilities: Basic Install
Expand All @@ -29,6 +37,11 @@ spec:
kind: OcsClient
name: ocsclients.odf.openshift.io
version: v1alpha1
- description: StorageClassClaim is the Schema for the storageclassclaims API
displayName: Storage Class Claim
kind: StorageClassClaim
name: storageclassclaims.odf.openshift.io
version: v1alpha1
description: foo
displayName: OpenShift Data Foundation Client Operator
icon:
Expand All @@ -38,6 +51,14 @@ spec:
spec:
clusterPermissions:
- rules:
- apiGroups:
- ""
resources:
- persistentvolumes
verbs:
- get
- list
- watch
- apiGroups:
- odf.openshift.io
resources:
Expand All @@ -64,6 +85,38 @@ spec:
- get
- patch
- update
- apiGroups:
- odf.openshift.io
resources:
- storageclassclaims
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- odf.openshift.io
resources:
- storageclassclaims/status
verbs:
- get
- patch
- update
- apiGroups:
- storage.k8s.io
resources:
- storageclasses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- authentication.k8s.io
resources:
Expand Down
70 changes: 70 additions & 0 deletions bundle/manifests/odf.openshift.io_storageclassclaims.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.4.1
creationTimestamp: null
name: storageclassclaims.odf.openshift.io
spec:
group: odf.openshift.io
names:
kind: StorageClassClaim
listKind: StorageClassClaimList
plural: storageclassclaims
singular: storageclassclaim
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .spec.type
name: StorageType
type: string
- jsonPath: .status.phase
name: Phase
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: StorageClassClaim is the Schema for the storageclassclaims 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: StorageClassClaimSpec defines the desired state of StorageClassClaim
properties:
encryptionMethod:
type: string
type:
enum:
- blockpool
- sharedfilesystem
type: string
required:
- type
type: object
status:
description: StorageClassClaimStatus defines the observed state of StorageClassClaim
properties:
phase:
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
Loading

0 comments on commit 7092b00

Please sign in to comment.