github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/spacerequest_types.go (about) 1 package v1alpha1 2 3 import ( 4 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 5 ) 6 7 const ( 8 // SpaceRequestLabelKey is a label on the subSpace, and will hold the name of the SpaceRequest that created the subSpace resource. 9 SpaceRequestLabelKey = LabelKeyPrefix + "spacerequest" 10 // SpaceRequestNamespaceLabelKey is a label on the subSpace, and will hold the namespace of the SpaceRequest that created the subSpace resource. 11 SpaceRequestNamespaceLabelKey = LabelKeyPrefix + "spacerequest-namespace" 12 // SpaceRequestProvisionedNamespaceLabelKey is a label on the secret that was created to provide access to a specific namespace provisioned by the SpaceRequest. 13 SpaceRequestProvisionedNamespaceLabelKey = LabelKeyPrefix + "spacerequest-provisioned-namespace" 14 15 // AdminServiceAccountName is the service account holding the token that grants admin permissions for the namespace provisioned by the SpaceRequest. 16 AdminServiceAccountName = "namespace-manager" 17 ) 18 19 // SpaceRequestSpec defines the desired state of Space 20 // +k8s:openapi-gen=true 21 type SpaceRequestSpec struct { 22 // TierName is a required property introduced to retain the name of the tier 23 // for which this Space is provisioned. 24 TierName string `json:"tierName"` 25 26 // TargetClusterRoles one or more label keys that define a set of clusters 27 // where the Space can be provisioned. 28 // The target cluster has to match ALL the roles defined in this field in order for the space to be provisioned there. 29 // +optional 30 // +listType=atomic 31 TargetClusterRoles []string `json:"targetClusterRoles,omitempty"` 32 33 // DisableInheritance indicates whether or not SpaceBindings from the parent-spaces are 34 // automatically inherited to all sub-spaces in the tree. 35 // 36 // Set to True to disable SpaceBinding inheritance from the parent-spaces. 37 // Default is False. 38 // +optional 39 DisableInheritance bool `json:"disableInheritance,omitempty"` 40 } 41 42 // SpaceRequestStatus defines the observed state of Space 43 // +k8s:openapi-gen=true 44 type SpaceRequestStatus struct { 45 46 // TargetClusterURL The API URL of the cluster where Space is currently provisioned 47 // Can be empty if provisioning did not start or failed 48 // The URL is just for informative purposes for developers and controllers that are placed in member clusters. 49 // +optional 50 TargetClusterURL string `json:"targetClusterURL,omitempty"` 51 52 // NamespaceAccess is the list with the provisioned namespace and secret to access it 53 // +listType=atomic 54 // +optional 55 NamespaceAccess []NamespaceAccess `json:"namespaceAccess,omitempty"` 56 57 // Conditions is an array of SpaceRequest conditions 58 // Supported condition types: 59 // Provisioning, SpaceNotReady and Ready 60 // +optional 61 // +patchMergeKey=type 62 // +patchStrategy=merge 63 // +listType=map 64 // +listMapKey=type 65 Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` 66 } 67 68 // NamespaceAccess defines the name of the namespace and the secret reference to access it 69 type NamespaceAccess struct { 70 // Name is the corresponding name of the provisioned namespace 71 Name string `json:"name"` 72 // SecretRef is the name of the secret with a SA token that has admin-like 73 // (or whatever we set in the tier template) permissions in the namespace 74 SecretRef string `json:"secretRef"` 75 } 76 77 // +kubebuilder:object:root=true 78 // +kubebuilder:subresource:status 79 80 // SpaceRequest is the Schema for the space request API 81 // +k8s:openapi-gen=true 82 // +kubebuilder:resource:scope=Namespaced 83 // +kubebuilder:printcolumn:name="Tier",type="string",JSONPath=`.spec.tierName` 84 // +kubebuilder:printcolumn:name="TargetClusterURL",type="string",JSONPath=`.status.targetClusterURL` 85 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status` 86 // +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].reason` 87 // +kubebuilder:validation:XPreserveUnknownFields 88 // +operator-sdk:gen-csv:customresourcedefinitions.displayName="SpaceRequest" 89 type SpaceRequest struct { 90 metav1.TypeMeta `json:",inline"` 91 metav1.ObjectMeta `json:"metadata,omitempty"` 92 93 Spec SpaceRequestSpec `json:"spec,omitempty"` 94 Status SpaceRequestStatus `json:"status,omitempty"` 95 } 96 97 //+kubebuilder:object:root=true 98 99 // SpaceRequestList contains a list of SpaceRequests 100 type SpaceRequestList struct { 101 metav1.TypeMeta `json:",inline"` 102 metav1.ListMeta `json:"metadata,omitempty"` 103 Items []SpaceRequest `json:"items"` 104 } 105 106 func init() { 107 SchemeBuilder.Register(&SpaceRequest{}, &SpaceRequestList{}) 108 }