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