github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/api/v1alpha1/useraccount_types.go (about) 1 package v1alpha1 2 3 import ( 4 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 5 ) 6 7 // These are valid status condition reasons of a UserAccount 8 const ( 9 // Status condition reasons 10 UserAccountUnableToCreateUserReason = "UnableToCreateUser" 11 UserAccountUnableToCreateIdentityReason = "UnableToCreateIdentity" 12 UserAccountUnableToCreateMappingReason = "UnableToCreateMapping" 13 UserAccountProvisioningReason = provisioningReason 14 UserAccountProvisionedReason = provisionedReason 15 UserAccountDisabledReason = disabledReason 16 UserAccountDisablingReason = "Disabling" 17 UserAccountTerminatingReason = terminatingReason 18 UserAccountUpdatingReason = updatingReason 19 20 // AnnotationKeyPrefix is the prefix used for annotation key values 21 AnnotationKeyPrefix = LabelKeyPrefix 22 23 // UserIDUserAnnotationKey is used to set an annotation value in the User resource on the member cluster, that 24 // contains the user's User ID as set in the user's JWT token. 25 UserIDUserAnnotationKey = AnnotationKeyPrefix + "sso-user-id" 26 27 // AccountIDUserAnnotationKey is used to set an annotation value in the User resource on the member cluster, that 28 // contains the user's Account ID as set in the user's JWT token. 29 AccountIDUserAnnotationKey = AnnotationKeyPrefix + "sso-account-id" 30 31 // EmailUserAnnotationKey is used to set an annotation value in the User resource on the member cluster, that 32 // contains the user's Email as set in the user's JWT token. 33 EmailUserAnnotationKey = AnnotationKeyPrefix + "user-email" 34 ) 35 36 // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. 37 38 // UserAccountSpec defines the desired state of UserAccount 39 // +k8s:openapi-gen=true 40 type UserAccountSpec struct { 41 // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file 42 // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html 43 44 // If set to true then the corresponding user should not be able to login 45 // "false" is assumed by default 46 // +optional 47 Disabled bool `json:"disabled,omitempty"` 48 49 // PropagatedClaims contains a selection of claim values from the SSO Identity Provider which are intended to 50 // be "propagated" down the resource dependency chain 51 // +optional 52 PropagatedClaims PropagatedClaims `json:"propagatedClaims,omitempty"` 53 } 54 55 // UserAccountStatus defines the observed state of UserAccount 56 // +k8s:openapi-gen=true 57 type UserAccountStatus struct { 58 // Important: Run "operator-sdk generate k8s" to regenerate code after modifying this file 59 // Add custom validation using kubebuilder tags: https://book.kubebuilder.io/beyond_basics/generating_crd.html 60 61 // Conditions is an array of current User Account conditions 62 // Supported condition types: ConditionReady 63 // +optional 64 // +patchMergeKey=type 65 // +patchStrategy=merge 66 // +listType=map 67 // +listMapKey=type 68 Conditions []Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` 69 } 70 71 //+kubebuilder:object:root=true 72 //+kubebuilder:subresource:status 73 74 // UserAccount keeps all information about user provisioned in the cluster 75 // +k8s:openapi-gen=true 76 // +kubebuilder:subresource:status 77 // +kubebuilder:resource:scope=Namespaced 78 // +kubebuilder:printcolumn:name="User ID",type="string",JSONPath=`.spec.userID`,priority=1 79 // +kubebuilder:printcolumn:name="Created_at",type="string",JSONPath=`.metadata.creationTimestamp` 80 // +kubebuilder:printcolumn:name="Tier",type="string",JSONPath=`.metadata.labels.toolchain\.dev\.openshift\.com/tier` 81 // +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].status` 82 // +kubebuilder:printcolumn:name="Reason",type="string",JSONPath=`.status.conditions[?(@.type=="Ready")].reason` 83 // +kubebuilder:printcolumn:name="Disabled",type="boolean",JSONPath=`.spec.disabled`,priority=1 84 // +kubebuilder:validation:XPreserveUnknownFields 85 // +operator-sdk:gen-csv:customresourcedefinitions.displayName="User Account" 86 type UserAccount struct { 87 metav1.TypeMeta `json:",inline"` 88 metav1.ObjectMeta `json:"metadata,omitempty"` 89 90 Spec UserAccountSpec `json:"spec,omitempty"` 91 Status UserAccountStatus `json:"status,omitempty"` 92 } 93 94 //+kubebuilder:object:root=true 95 96 // UserAccountList contains a list of UserAccount 97 type UserAccountList struct { 98 metav1.TypeMeta `json:",inline"` 99 metav1.ListMeta `json:"metadata,omitempty"` 100 Items []UserAccount `json:"items"` 101 } 102 103 func init() { 104 SchemeBuilder.Register(&UserAccount{}, &UserAccountList{}) 105 }