kubesphere.io/api@v0.0.0-20231107125330-c9a03957060c/storage/v1alpha1/capability_types.go (about) 1 /* 2 Copyright 2019 The KubeSphere authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha1 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 type ExpandMode string 24 25 const ( 26 ExpandModeUnknown ExpandMode = "UNKNOWN" 27 ExpandModeOffline ExpandMode = "OFFLINE" 28 ExpandModeOnline ExpandMode = "ONLINE" 29 ) 30 31 // VolumeFeature describe volume features 32 type VolumeFeature struct { 33 Create bool `json:"create"` 34 Attach bool `json:"attach"` 35 List bool `json:"list"` 36 Clone bool `json:"clone"` 37 Stats bool `json:"stats"` 38 Expand ExpandMode `json:"expandMode"` 39 } 40 41 // SnapshotFeature describe snapshot features 42 type SnapshotFeature struct { 43 Create bool `json:"create"` 44 List bool `json:"list"` 45 } 46 47 // CapabilityFeatures describe storage features 48 type CapabilityFeatures struct { 49 Topology bool `json:"topology"` 50 Volume VolumeFeature `json:"volume"` 51 Snapshot SnapshotFeature `json:"snapshot"` 52 } 53 54 // PluginInfo describes plugin info 55 type PluginInfo struct { 56 Name string `json:"name"` 57 Version string `json:"version"` 58 } 59 60 // +genclient 61 // +kubebuilder:object:root=true 62 // +genclient:noStatus 63 // +genclient:nonNamespaced 64 // +kubebuilder:printcolumn:name="Provisioner",type="string",JSONPath=".spec.provisioner" 65 // +kubebuilder:printcolumn:name="Volume",type="boolean",JSONPath=".spec.features.volume.create" 66 // +kubebuilder:printcolumn:name="Expand",type="string",JSONPath=".spec.features.volume.expandMode" 67 // +kubebuilder:printcolumn:name="Clone",type="boolean",JSONPath=".spec.features.volume.clone" 68 // +kubebuilder:printcolumn:name="Snapshot",type="boolean",JSONPath=".spec.features.snapshot.create" 69 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" 70 // +kubebuilder:resource:scope="Cluster" 71 72 // StorageClassCapability is the Schema for the storage class capability API 73 // +k8s:openapi-gen=true 74 type StorageClassCapability struct { 75 metav1.TypeMeta `json:",inline"` 76 metav1.ObjectMeta `json:"metadata,omitempty"` 77 78 Spec StorageClassCapabilitySpec `json:"spec"` 79 } 80 81 // StorageClassCapabilitySpec defines the desired state of StorageClassCapability 82 type StorageClassCapabilitySpec struct { 83 Provisioner string `json:"provisioner"` 84 Features CapabilityFeatures `json:"features"` 85 } 86 87 // +kubebuilder:object:root=true 88 // +genclient:nonNamespaced 89 90 // StorageClassCapabilityList contains a list of StorageClassCapability 91 type StorageClassCapabilityList struct { 92 metav1.TypeMeta `json:",inline"` 93 metav1.ListMeta `json:"metadata"` 94 Items []StorageClassCapability `json:"items"` 95 } 96 97 // +genclient 98 // +kubebuilder:object:root=true 99 // +genclient:noStatus 100 // +genclient:nonNamespaced 101 // +kubebuilder:printcolumn:name="Provisioner",type="string",JSONPath=".spec.pluginInfo.name" 102 // +kubebuilder:printcolumn:name="Expand",type="string",JSONPath=".spec.features.volume.expandMode" 103 // +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" 104 // +kubebuilder:resource:scope="Cluster" 105 106 // ProvisionerCapability is the schema for the provisionercapability API 107 // +k8s:openapi-gen=true 108 type ProvisionerCapability struct { 109 metav1.TypeMeta `json:",inline"` 110 metav1.ObjectMeta `json:"metadata,omitempty"` 111 112 Spec ProvisionerCapabilitySpec `json:"spec"` 113 } 114 115 // ProvisionerCapabilitySpec defines the desired state of ProvisionerCapability 116 type ProvisionerCapabilitySpec struct { 117 PluginInfo PluginInfo `json:"pluginInfo"` 118 Features CapabilityFeatures `json:"features"` 119 } 120 121 // +kubebuilder:object:root=true 122 type ProvisionerCapabilityList struct { 123 metav1.TypeMeta `json:",inline"` 124 metav1.ListMeta `json:"metadata"` 125 Items []ProvisionerCapability `json:"items"` 126 } 127 128 func init() { 129 SchemeBuilder.Register( 130 &StorageClassCapability{}, 131 &StorageClassCapabilityList{}, 132 &ProvisionerCapability{}, 133 &ProvisionerCapabilityList{}) 134 }