github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/nstemplateset_types.go (about) 1 package v1alpha1 2 3 import ( 4 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 5 ) 6 7 const ( 8 OwnerLabelKey = LabelKeyPrefix + "owner" 9 SpaceLabelKey = LabelKeyPrefix + "space" 10 TypeLabelKey = LabelKeyPrefix + "type" 11 TemplateRefLabelKey = LabelKeyPrefix + "templateref" 12 TierLabelKey = LabelKeyPrefix + "tier" 13 ProviderLabelKey = LabelKeyPrefix + "provider" 14 ProviderLabelValue = "codeready-toolchain" 15 16 LastAppliedSpaceRolesAnnotationKey = LabelKeyPrefix + "last-applied-space-roles" 17 ) 18 19 // These are valid status condition reasons of a NSTemplateSet 20 const ( 21 NSTemplateSetProvisionedReason = provisionedReason 22 NSTemplateSetProvisioningReason = provisioningReason 23 NSTemplateSetUnableToProvisionReason = "UnableToProvision" 24 NSTemplateSetUnableToProvisionNamespaceReason = "UnableToProvisionNamespace" 25 NSTemplateSetUnableToProvisionClusterResourcesReason = "UnableToProvisionClusteResources" 26 NSTemplateSetUnableToProvisionSpaceRolesReason = "UnableToProvisionSpaceRoles" 27 NSTemplateSetTerminatingReason = terminatingReason 28 NSTemplateSetTerminatingFailedReason = terminatingFailedReason 29 NSTemplateSetUpdatingReason = updatingReason 30 NSTemplateSetUpdateFailedReason = "UpdateFailed" 31 ) 32 33 // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. 34 35 // NSTemplateSetSpec defines the desired state of NSTemplateSet 36 // +k8s:openapi-gen=true 37 type NSTemplateSetSpec struct { 38 // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file 39 // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html 40 41 // The name of the tier represented by this template set 42 TierName string `json:"tierName"` 43 44 // The namespace templates 45 // +listType=atomic 46 Namespaces []NSTemplateSetNamespace `json:"namespaces"` 47 48 // the cluster resources template (for cluster-wide quotas, etc.) 49 // +optional 50 ClusterResources *NSTemplateSetClusterResources `json:"clusterResources,omitempty"` 51 52 // the role template and the users to whom the templates should be applied to 53 // +optional 54 // +listType=atomic 55 SpaceRoles []NSTemplateSetSpaceRole `json:"spaceRoles,omitempty"` 56 } 57 58 // NSTemplateSetNamespace the namespace definition in an NSTemplateSet resource 59 // +k8s:openapi-gen=true 60 type NSTemplateSetNamespace struct { 61 62 // TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use 63 TemplateRef string `json:"templateRef"` 64 } 65 66 // NSTemplateSetClusterResources defines the cluster-scoped resources associated with a given user 67 // +k8s:openapi-gen=true 68 type NSTemplateSetClusterResources struct { 69 70 // TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use 71 TemplateRef string `json:"templateRef"` 72 } 73 74 // NSTemplateSetSpaceRole the role template and the users to whom the templates should be applied to 75 // +k8s:openapi-gen=true 76 type NSTemplateSetSpaceRole struct { 77 78 // TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use 79 TemplateRef string `json:"templateRef"` 80 81 // Usernames the usernames to which the template applies 82 // +listType=atomic 83 Usernames []string `json:"usernames"` 84 } 85 86 // NSTemplateSetStatus defines the observed state of NSTemplateSet 87 // +k8s:openapi-gen=true 88 type NSTemplateSetStatus struct { 89 // ProvisionedNamespaces is a list of Namespaces that were provisioned by the NSTemplateSet. 90 // +optional 91 // +listType=atomic 92 ProvisionedNamespaces []SpaceNamespace `json:"provisionedNamespaces,omitempty"` 93 94 // Conditions is an array of current NSTemplateSet conditions 95 // Supported condition types: ConditionReady 96 // +optional 97 // +patchMergeKey=type 98 // +patchStrategy=merge 99 // +listType=map 100 // +listMapKey=type 101 Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` 102 } 103 104 //+kubebuilder:object:root=true 105 //+kubebuilder:subresource:status 106 107 // NSTemplateSet defines user environment via templates that are used for namespace provisioning 108 // +k8s:openapi-gen=true 109 // +kubebuilder:subresource:status 110 // +kubebuilder:resource:scope=Namespaced 111 // +kubebuilder:printcolumn:name="Tier",type="string",JSONPath=`.spec.tierName` 112 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status` 113 // +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].reason` 114 // +kubebuilder:validation:XPreserveUnknownFields 115 // +operator-sdk:gen-csv:customresourcedefinitions.displayName="Namespace Template Set" 116 type NSTemplateSet struct { 117 metav1.TypeMeta `json:",inline"` 118 metav1.ObjectMeta `json:"metadata,omitempty"` 119 120 Spec NSTemplateSetSpec `json:"spec,omitempty"` 121 Status NSTemplateSetStatus `json:"status,omitempty"` 122 } 123 124 //+kubebuilder:object:root=true 125 126 // NSTemplateSetList contains a list of NSTemplateSet 127 type NSTemplateSetList struct { 128 metav1.TypeMeta `json:",inline"` 129 metav1.ListMeta `json:"metadata,omitempty"` 130 Items []NSTemplateSet `json:"items"` 131 } 132 133 func init() { 134 SchemeBuilder.Register(&NSTemplateSet{}, &NSTemplateSetList{}) 135 }