1 package v1 2 3 import ( 4 "fmt" 5 6 corev1 "k8s.io/api/core/v1" 7 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 8 "k8s.io/apimachinery/pkg/runtime" 9 ) 10 11 // +genclient 12 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 13 14 // Template contains the inputs needed to produce a Config. 15 // 16 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 17 // +openshift:compatibility-gen:level=1 18 type Template struct { 19 metav1.TypeMeta `json:",inline"` 20 21 // metadata is the standard object's metadata. 22 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 23 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 24 25 // message is an optional instructional message that will 26 // be displayed when this template is instantiated. 27 // This field should inform the user how to utilize the newly created resources. 28 // Parameter substitution will be performed on the message before being 29 // displayed so that generated credentials and other parameters can be 30 // included in the output. 31 Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"` 32 33 // objects is an array of resources to include in this template. 34 // If a namespace value is hardcoded in the object, it will be removed 35 // during template instantiation, however if the namespace value 36 // is, or contains, a ${PARAMETER_REFERENCE}, the resolved 37 // value after parameter substitution will be respected and the object 38 // will be created in that namespace. 39 // +kubebuilder:pruning:PreserveUnknownFields 40 Objects []runtime.RawExtension `json:"objects" protobuf:"bytes,3,rep,name=objects"` 41 42 // parameters is an optional array of Parameters used during the 43 // Template to Config transformation. 44 Parameters []Parameter `json:"parameters,omitempty" protobuf:"bytes,4,rep,name=parameters"` 45 46 // labels is a optional set of labels that are applied to every 47 // object during the Template to Config transformation. 48 ObjectLabels map[string]string `json:"labels,omitempty" protobuf:"bytes,5,rep,name=labels"` 49 } 50 51 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 52 53 // TemplateList is a list of Template objects. 54 // 55 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 56 // +openshift:compatibility-gen:level=1 57 type TemplateList struct { 58 metav1.TypeMeta `json:",inline"` 59 60 // metadata is the standard list's metadata. 61 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 62 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 63 64 // Items is a list of templates 65 Items []Template `json:"items" protobuf:"bytes,2,rep,name=items"` 66 } 67 68 // Parameter defines a name/value variable that is to be processed during 69 // the Template to Config transformation. 70 type Parameter struct { 71 // Name must be set and it can be referenced in Template 72 // Items using ${PARAMETER_NAME}. Required. 73 Name string `json:"name" protobuf:"bytes,1,opt,name=name"` 74 75 // Optional: The name that will show in UI instead of parameter 'Name' 76 DisplayName string `json:"displayName,omitempty" protobuf:"bytes,2,opt,name=displayName"` 77 78 // Description of a parameter. Optional. 79 Description string `json:"description,omitempty" protobuf:"bytes,3,opt,name=description"` 80 81 // Value holds the Parameter data. If specified, the generator will be 82 // ignored. The value replaces all occurrences of the Parameter ${Name} 83 // expression during the Template to Config transformation. Optional. 84 Value string `json:"value,omitempty" protobuf:"bytes,4,opt,name=value"` 85 86 // generate specifies the generator to be used to generate random string 87 // from an input value specified by From field. The result string is 88 // stored into Value field. If empty, no generator is being used, leaving 89 // the result Value untouched. Optional. 90 // 91 // The only supported generator is "expression", which accepts a "from" 92 // value in the form of a simple regular expression containing the 93 // range expression "[a-zA-Z0-9]", and the length expression "a{length}". 94 // 95 // Examples: 96 // 97 // from | value 98 // ----------------------------- 99 // "test[0-9]{1}x" | "test7x" 100 // "[0-1]{8}" | "01001100" 101 // "0x[A-F0-9]{4}" | "0xB3AF" 102 // "[a-zA-Z0-9]{8}" | "hW4yQU5i" 103 // 104 Generate string `json:"generate,omitempty" protobuf:"bytes,5,opt,name=generate"` 105 106 // From is an input value for the generator. Optional. 107 From string `json:"from,omitempty" protobuf:"bytes,6,opt,name=from"` 108 109 // Optional: Indicates the parameter must have a value. Defaults to false. 110 Required bool `json:"required,omitempty" protobuf:"varint,7,opt,name=required"` 111 } 112 113 // +genclient 114 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 115 116 // TemplateInstance requests and records the instantiation of a Template. 117 // TemplateInstance is part of an experimental API. 118 // 119 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 120 // +openshift:compatibility-gen:level=1 121 type TemplateInstance struct { 122 metav1.TypeMeta `json:",inline"` 123 124 // metadata is the standard object's metadata. 125 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 126 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 127 128 // spec describes the desired state of this TemplateInstance. 129 Spec TemplateInstanceSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 130 131 // status describes the current state of this TemplateInstance. 132 // +optional 133 Status TemplateInstanceStatus `json:"status" protobuf:"bytes,3,opt,name=status"` 134 } 135 136 // TemplateInstanceSpec describes the desired state of a TemplateInstance. 137 type TemplateInstanceSpec struct { 138 // template is a full copy of the template for instantiation. 139 Template Template `json:"template" protobuf:"bytes,1,opt,name=template"` 140 141 // secret is a reference to a Secret object containing the necessary 142 // template parameters. 143 Secret *corev1.LocalObjectReference `json:"secret,omitempty" protobuf:"bytes,2,opt,name=secret"` 144 145 // requester holds the identity of the agent requesting the template 146 // instantiation. 147 // +optional 148 Requester *TemplateInstanceRequester `json:"requester" protobuf:"bytes,3,opt,name=requester"` 149 } 150 151 // TemplateInstanceRequester holds the identity of an agent requesting a 152 // template instantiation. 153 type TemplateInstanceRequester struct { 154 // username uniquely identifies this user among all active users. 155 Username string `json:"username,omitempty" protobuf:"bytes,1,opt,name=username"` 156 157 // uid is a unique value that identifies this user across time; if this user is 158 // deleted and another user by the same name is added, they will have 159 // different UIDs. 160 UID string `json:"uid,omitempty" protobuf:"bytes,2,opt,name=uid"` 161 162 // groups represent the groups this user is a part of. 163 Groups []string `json:"groups,omitempty" protobuf:"bytes,3,rep,name=groups"` 164 165 // extra holds additional information provided by the authenticator. 166 Extra map[string]ExtraValue `json:"extra,omitempty" protobuf:"bytes,4,rep,name=extra"` 167 } 168 169 // ExtraValue masks the value so protobuf can generate 170 // +protobuf.nullable=true 171 // +protobuf.options.(gogoproto.goproto_stringer)=false 172 type ExtraValue []string 173 174 func (t ExtraValue) String() string { 175 return fmt.Sprintf("%v", []string(t)) 176 } 177 178 // TemplateInstanceStatus describes the current state of a TemplateInstance. 179 type TemplateInstanceStatus struct { 180 // conditions represent the latest available observations of a 181 // TemplateInstance's current state. 182 Conditions []TemplateInstanceCondition `json:"conditions,omitempty" protobuf:"bytes,1,rep,name=conditions"` 183 184 // Objects references the objects created by the TemplateInstance. 185 Objects []TemplateInstanceObject `json:"objects,omitempty" protobuf:"bytes,2,rep,name=objects"` 186 } 187 188 // TemplateInstanceCondition contains condition information for a 189 // TemplateInstance. 190 type TemplateInstanceCondition struct { 191 // Type of the condition, currently Ready or InstantiateFailure. 192 Type TemplateInstanceConditionType `json:"type" protobuf:"bytes,1,opt,name=type,casttype=TemplateInstanceConditionType"` 193 // Status of the condition, one of True, False or Unknown. 194 Status corev1.ConditionStatus `json:"status" protobuf:"bytes,2,opt,name=status"` 195 // LastTransitionTime is the last time a condition status transitioned from 196 // one state to another. 197 LastTransitionTime metav1.Time `json:"lastTransitionTime" protobuf:"bytes,3,opt,name=lastTransitionTime"` 198 // Reason is a brief machine readable explanation for the condition's last 199 // transition. 200 Reason string `json:"reason" protobuf:"bytes,4,opt,name=reason"` 201 // Message is a human readable description of the details of the last 202 // transition, complementing reason. 203 Message string `json:"message" protobuf:"bytes,5,opt,name=message"` 204 } 205 206 // TemplateInstanceConditionType is the type of condition pertaining to a 207 // TemplateInstance. 208 type TemplateInstanceConditionType string 209 210 const ( 211 // TemplateInstanceReady indicates the readiness of the template 212 // instantiation. 213 TemplateInstanceReady TemplateInstanceConditionType = "Ready" 214 // TemplateInstanceInstantiateFailure indicates the failure of the template 215 // instantiation 216 TemplateInstanceInstantiateFailure TemplateInstanceConditionType = "InstantiateFailure" 217 ) 218 219 // TemplateInstanceObject references an object created by a TemplateInstance. 220 type TemplateInstanceObject struct { 221 // ref is a reference to the created object. When used under .spec, only 222 // name and namespace are used; these can contain references to parameters 223 // which will be substituted following the usual rules. 224 Ref corev1.ObjectReference `json:"ref,omitempty" protobuf:"bytes,1,opt,name=ref"` 225 } 226 227 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 228 229 // TemplateInstanceList is a list of TemplateInstance objects. 230 // 231 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 232 // +openshift:compatibility-gen:level=1 233 type TemplateInstanceList struct { 234 metav1.TypeMeta `json:",inline"` 235 236 // metadata is the standard list's metadata. 237 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 238 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 239 240 // items is a list of Templateinstances 241 Items []TemplateInstance `json:"items" protobuf:"bytes,2,rep,name=items"` 242 } 243 244 // +genclient 245 // +genclient:nonNamespaced 246 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 247 248 // BrokerTemplateInstance holds the service broker-related state associated with 249 // a TemplateInstance. BrokerTemplateInstance is part of an experimental API. 250 // 251 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 252 // +openshift:compatibility-gen:level=1 253 type BrokerTemplateInstance struct { 254 metav1.TypeMeta `json:",inline"` 255 256 // metadata is the standard object's metadata. 257 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 258 metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 259 260 // spec describes the state of this BrokerTemplateInstance. 261 Spec BrokerTemplateInstanceSpec `json:"spec" protobuf:"bytes,2,opt,name=spec"` 262 } 263 264 // BrokerTemplateInstanceSpec describes the state of a BrokerTemplateInstance. 265 type BrokerTemplateInstanceSpec struct { 266 // templateinstance is a reference to a TemplateInstance object residing 267 // in a namespace. 268 TemplateInstance corev1.ObjectReference `json:"templateInstance" protobuf:"bytes,1,opt,name=templateInstance"` 269 270 // secret is a reference to a Secret object residing in a namespace, 271 // containing the necessary template parameters. 272 Secret corev1.ObjectReference `json:"secret" protobuf:"bytes,2,opt,name=secret"` 273 274 // bindingids is a list of 'binding_id's provided during successive bind 275 // calls to the template service broker. 276 BindingIDs []string `json:"bindingIDs,omitempty" protobuf:"bytes,3,rep,name=bindingIDs"` 277 } 278 279 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object 280 281 // BrokerTemplateInstanceList is a list of BrokerTemplateInstance objects. 282 // 283 // Compatibility level 1: Stable within a major release for a minimum of 12 months or 3 minor releases (whichever is longer). 284 // +openshift:compatibility-gen:level=1 285 type BrokerTemplateInstanceList struct { 286 metav1.TypeMeta `json:",inline"` 287 288 // metadata is the standard list's metadata. 289 // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata 290 metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` 291 292 // items is a list of BrokerTemplateInstances 293 Items []BrokerTemplateInstance `json:"items" protobuf:"bytes,2,rep,name=items"` 294 } 295