github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/nstemplatetier_types.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     5  )
     6  
     7  // NSTemplateTierSpec defines the desired state of NSTemplateTier
     8  // +k8s:openapi-gen=true
     9  type NSTemplateTierSpec struct {
    10  	// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
    11  	// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
    12  
    13  	// The namespace templates
    14  	// +listType=atomic
    15  	Namespaces []NSTemplateTierNamespace `json:"namespaces"`
    16  
    17  	// the cluster resources template (for cluster-wide quotas, etc.)
    18  	// +optional
    19  	ClusterResources *NSTemplateTierClusterResources `json:"clusterResources,omitempty"`
    20  
    21  	// the templates to set the spaces roles, indexed by role
    22  	// +optional
    23  	// +mapType=atomic
    24  	SpaceRoles map[string]NSTemplateTierSpaceRole `json:"spaceRoles,omitempty"`
    25  
    26  	// SpaceRequestConfig stores all the configuration related to the Space Request feature
    27  	// +optional
    28  	SpaceRequestConfig *SpaceRequestConfig `json:"spaceRequestConfig,omitempty"`
    29  }
    30  
    31  // SpaceRequestConfig contains all the configuration related to the Space Request feature
    32  // +k8s:openapi-gen=true
    33  type SpaceRequestConfig struct {
    34  	// Provides the name of the Service Account whose token is to be copied
    35  	// +optional
    36  	ServiceAccountName string `json:"serviceAccountName,omitempty"`
    37  }
    38  
    39  // NSTemplateTierNamespace the namespace definition in an NSTemplateTier resource
    40  type NSTemplateTierNamespace struct {
    41  	// TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use
    42  	TemplateRef string `json:"templateRef"`
    43  }
    44  
    45  // NSTemplateTierClusterResources defines the cluster-scoped resources associated with a given user
    46  type NSTemplateTierClusterResources struct {
    47  	// TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use
    48  	TemplateRef string `json:"templateRef"`
    49  }
    50  
    51  // NSTemplateTierSpaceRole the space roles definition in an NSTemplateTier resource
    52  type NSTemplateTierSpaceRole struct {
    53  	// TemplateRef The name of the TierTemplate resource which exists in the host cluster and which contains the template to use
    54  	TemplateRef string `json:"templateRef"`
    55  }
    56  
    57  // NSTemplateTierStatus defines the observed state of NSTemplateTier
    58  // +k8s:openapi-gen=true
    59  type NSTemplateTierStatus struct {
    60  	// Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file
    61  	// Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html
    62  
    63  	// Conditions is an array of current NSTemplateTier conditions
    64  	// Supported condition types: ConditionReady
    65  	// +optional
    66  	// +patchMergeKey=type
    67  	// +patchStrategy=merge
    68  	// +listType=map
    69  	// +listMapKey=type
    70  	Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
    71  
    72  	// Updates is an array of all NSTemplateTier updates
    73  	// +optional
    74  	// +patchMergeKey=startTime
    75  	// +patchStrategy=merge
    76  	// +listType=map
    77  	// +listMapKey=startTime
    78  	Updates []NSTemplateTierHistory `json:"updates,omitempty" patchStrategy:"merge" patchMergeKey:"startTime"`
    79  }
    80  
    81  // NSTemplateTierHistory a track record of an update
    82  type NSTemplateTierHistory struct {
    83  	// StartTime is the time when the NSTemplateTier was updated
    84  	StartTime metav1.Time `json:"startTime"`
    85  	// Hash the hash matching on the templateRefs in the resource spec
    86  	Hash string `json:"hash"`
    87  	// CompletionTime is the time when the last MasterUserRecord was updated
    88  	// +optional
    89  	CompletionTime *metav1.Time `json:"completionTime,omitempty"`
    90  	// Failures is the number of MasterUserRecords which failed to be updated
    91  	Failures int `json:"failures"`
    92  	// FailedAccounts
    93  	// +optional
    94  	FailedAccounts []string `json:"failedAccounts,omitempty"`
    95  }
    96  
    97  //+kubebuilder:object:root=true
    98  //+kubebuilder:subresource:status
    99  
   100  // NSTemplateTier configures user environment via templates used for namespaces the user has access to
   101  // +k8s:openapi-gen=true
   102  // +kubebuilder:subresource:status
   103  // +kubebuilder:resource:scope=Namespaced
   104  // +kubebuilder:resource:shortName=tier
   105  // +kubebuilder:validation:XPreserveUnknownFields
   106  // +operator-sdk:gen-csv:customresourcedefinitions.displayName="Namespace Template Tier"
   107  type NSTemplateTier struct {
   108  	metav1.TypeMeta   `json:",inline"`
   109  	metav1.ObjectMeta `json:"metadata,omitempty"`
   110  
   111  	Spec   NSTemplateTierSpec   `json:"spec,omitempty"`
   112  	Status NSTemplateTierStatus `json:"status,omitempty"`
   113  }
   114  
   115  //+kubebuilder:object:root=true
   116  
   117  // NSTemplateTierList contains a list of NSTemplateTier
   118  type NSTemplateTierList struct {
   119  	metav1.TypeMeta `json:",inline"`
   120  	metav1.ListMeta `json:"metadata,omitempty"`
   121  	Items           []NSTemplateTier `json:"items"`
   122  }
   123  
   124  func init() {
   125  	SchemeBuilder.Register(&NSTemplateTier{}, &NSTemplateTierList{})
   126  }