Skip to content

Commit

Permalink
Merge pull request #2204 from raaizik/sp-414
Browse files Browse the repository at this point in the history
Transforms StorageProfile array into a set of CRs
  • Loading branch information
openshift-ci[bot] authored Oct 17, 2023
2 parents d290a42 + f542c11 commit d45e44c
Show file tree
Hide file tree
Showing 21 changed files with 629 additions and 159 deletions.
16 changes: 0 additions & 16 deletions api/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,22 +109,6 @@ type StorageClusterSpec struct {
// DefaultStorageProfile is the default storage profile to use for
// the storageclassrequest as StorageProfile is optional.
DefaultStorageProfile string `json:"defaultStorageProfile,omitempty"`

StorageProfiles []StorageProfile `json:"storageProfiles,omitempty"`
}

// StorageProfile is the storage profile to use for the storageclassrequest.
type StorageProfile struct {
// +kubebuilder:validation:Required
// Name of the storage profile.
Name string `json:"name"`
// +kubebuilder:validation:Required
// DeviceClass is the deviceclass name.
DeviceClass string `json:"deviceClass"`
// configurations to use for cephfilesystem.
SharedFilesystemConfiguration SharedFilesystemConfigurationSpec `json:"sharedFilesystemConfiguration,omitempty"`
// configurations to use for profile specific blockpool.
BlockPoolConfiguration BlockPoolConfigurationSpec `json:"blockPoolConfiguration,omitempty"`
}

type SharedFilesystemConfigurationSpec struct {
Expand Down
94 changes: 94 additions & 0 deletions api/v1/storageprofile_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
/*
Copyright 2020 Red Hat OpenShift Container Storage.
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 v1

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

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// StorageProfileSpec defines the desired state of StorageProfile
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.deviceClass) || has(self.deviceClass)", message="deviceClass is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.sharedFilesystemConfiguration) || has(self.sharedFilesystemConfiguration)", message="sharedFilesystemConfiguration is required once set"
// +kubebuilder:validation:XValidation:rule="!has(oldSelf.blockPoolConfiguration) || has(self.blockPoolConfiguration)", message="blockPoolConfiguration is required once set"
type StorageProfileSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="DeviceClass is immutable"
// +kubebuilder:validation:MaxLength=512
// DeviceClass is the deviceclass name.
DeviceClass string `json:"deviceClass"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="SharedFilesystemConfiguration is immutable"
// configurations to use for cephfilesystem.
SharedFilesystemConfiguration SharedFilesystemConfigurationSpec `json:"sharedFilesystemConfiguration,omitempty"`

// +kubebuilder:validation:Optional
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="BlockPoolConfiguration is immutable"
// configurations to use for profile specific blockpool.
BlockPoolConfiguration BlockPoolConfigurationSpec `json:"blockPoolConfiguration,omitempty"`
}

// StorageProfileStatus defines the observed state of StorageProfile
type StorageProfileStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Phase describes the Phase of StorageProfile
// This is used by OLM UI to provide status information
// to the user
Phase StorageProfilePhase `json:"phase,omitempty"`
}

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

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

Spec StorageProfileSpec `json:"spec,omitempty"`
Status StorageProfileStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

// StorageProfilePhase stores a StorageProfile reconciliation phase
type StorageProfilePhase string

const (
StorageProfilePhaseFailed StorageProfilePhase = "Failed"
StorageProfilePhaseReady StorageProfilePhase = "Ready"
StorageProfilePhaseRejected StorageProfilePhase = "Rejected"
)

func init() {
SchemeBuilder.Register(&StorageProfile{}, &StorageProfileList{})
}
85 changes: 76 additions & 9 deletions api/v1/zz_generated.deepcopy.go

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

32 changes: 0 additions & 32 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6173,38 +6173,6 @@ spec:
- name
type: object
type: array
storageProfiles:
items:
description: StorageProfile is the storage profile to use for the
storageclassrequest.
properties:
blockPoolConfiguration:
description: configurations to use for profile specific blockpool.
properties:
parameters:
additionalProperties:
type: string
type: object
type: object
deviceClass:
description: DeviceClass is the deviceclass name.
type: string
name:
description: Name of the storage profile.
type: string
sharedFilesystemConfiguration:
description: configurations to use for cephfilesystem.
properties:
parameters:
additionalProperties:
type: string
type: object
type: object
required:
- deviceClass
- name
type: object
type: array
version:
description: Version specifies the version of StorageCluster
type: string
Expand Down
87 changes: 87 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageprofiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.9.2
creationTimestamp: null
name: storageprofiles.ocs.openshift.io
spec:
group: ocs.openshift.io
names:
kind: StorageProfile
listKind: StorageProfileList
plural: storageprofiles
singular: storageprofile
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
description: StorageProfile is the Schema for the storageprofiles 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: StorageProfileSpec defines the desired state of StorageProfile
properties:
blockPoolConfiguration:
description: configurations to use for profile specific blockpool.
properties:
parameters:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-validations:
- message: BlockPoolConfiguration is immutable
rule: self == oldSelf
deviceClass:
description: DeviceClass is the deviceclass name.
maxLength: 512
type: string
x-kubernetes-validations:
- message: DeviceClass is immutable
rule: self == oldSelf
sharedFilesystemConfiguration:
description: configurations to use for cephfilesystem.
properties:
parameters:
additionalProperties:
type: string
type: object
type: object
x-kubernetes-validations:
- message: SharedFilesystemConfiguration is immutable
rule: self == oldSelf
type: object
x-kubernetes-validations:
- message: deviceClass is required once set
rule: '!has(oldSelf.deviceClass) || has(self.deviceClass)'
- message: sharedFilesystemConfiguration is required once set
rule: '!has(oldSelf.sharedFilesystemConfiguration) || has(self.sharedFilesystemConfiguration)'
- message: blockPoolConfiguration is required once set
rule: '!has(oldSelf.blockPoolConfiguration) || has(self.blockPoolConfiguration)'
status:
description: StorageProfileStatus defines the observed state of StorageProfile
properties:
phase:
description: Phase describes the Phase of StorageProfile This is used
by OLM UI to provide status information to the user
type: string
type: object
type: object
served: true
storage: true
subresources:
status: {}
3 changes: 3 additions & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ resources:
- bases/ocs.openshift.io_storageclusters.yaml
- bases/ocs.openshift.io_storageconsumers.yaml
- bases/ocs.openshift.io_storageclassrequests.yaml
- bases/ocs.openshift.io_storageprofiles.yaml
# +kubebuilder:scaffold:crdkustomizeresource

# patchesStrategicMerge:
Expand All @@ -15,6 +16,7 @@ resources:
#- patches/webhook_in_storageclusters.yaml
#- patches/webhook_in_storageconsumers.yaml
#- patches/webhook_in_storageclassrequestss.yaml
#- patches/webhook_in_storageprofiles.yaml
# +kubebuilder:scaffold:crdkustomizewebhookpatch

# [CERTMANAGER] To enable webhook, uncomment all the sections with [CERTMANAGER] prefix.
Expand All @@ -23,6 +25,7 @@ resources:
#- patches/cainjection_in_storageclusters.yaml
#- patches/cainjection_in_storageconsumers.yaml
#- patches/cainjection_in_storageclassrequests.yaml
#- patches/cainjection_in_storageprofiles.yaml
# +kubebuilder:scaffold:crdkustomizecainjectionpatch

# the following config is for teaching kustomize how to do kustomization for CRDs.
Expand Down
8 changes: 8 additions & 0 deletions config/crd/patches/cainjection_in_storageprofiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# The following patch adds a directive for certmanager to inject CA into the CRD
# CRD conversion requires k8s 1.13 or later.
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: storageprofiles.ocs.openshift.io
Loading

0 comments on commit d45e44c

Please sign in to comment.