/
website_types.go
172 lines (137 loc) · 5.39 KB
/
website_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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
package v1beta1
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
// WebSiteSpec defines the desired state of WebSite
type WebSiteSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
// BuildImage is a container image name that will be used to build the website
// +kubebuiler:validation:Required
BuildImage string `json:"buildImage"`
// BuildScript is a script to build the website
// +kubebuiler:validation:Required
BuildScript DataSource `json:"buildScript"`
// BuildSecrets is the list of secrets you can use in a build script
// +optional
BuildSecrets []SecretKey `json:"buildSecrets,omitempty"`
// ImagePullSecrets is a list of references to secrets in the same namespace to use for pulling the images (buildImage, nginx and repo-checker).
// +optional
ImagePullSecrets []corev1.LocalObjectReference `json:"imagePullSecrets,omitempty"`
// RepoURL is the URL of the repository that has contents of the website
// +kubebuiler:validation:Required
RepoURL string `json:"repoURL"`
// Branch is the branch name of the repository
// +kubebuilder:default=main
// +optional
Branch string `json:"branch"`
// DeployKeySecretName is the name of the secret resource that contains the deploy key to access the private repository
// +optional
DeployKeySecretName *string `json:"deployKeySecretName,omitempty"`
// ExtraResources are resources that will be applied after the build step
// +optional
ExtraResources []DataSource `json:"extraResources,omitempty"`
// Replicas is the number of nginx instances
// +kubebuilder:default=1
// +optional
Replicas int32 `json:"replicas,omitempty"`
// PodTemplate is a `Pod` template for nginx container.
// +optional
PodTemplate *PodTemplate `json:"podTemplate,omitempty"`
// VolumeTemplates are `Volume` templates for nginx container.
// +optional
VolumeTemplates []corev1.Volume `json:"volumeTemplates,omitempty"`
// ServiceTemplate is a `Service` template for nginx.
// +optional
ServiceTemplate *ServiceTemplate `json:"serviceTemplate,omitempty"`
// AfterBuildScript is a script to execute in Job once after build
// +optional
AfterBuildScript *DataSource `json:"afterBuildScript"`
// PublicURL is the URL of the website
// +optional
PublicURL string `json:"publicURL,omitempty"`
}
// SecretKey represents the name and key of a secret resource.
type SecretKey struct {
// Name is the name of the secret resource
Name string `json:"name"`
// Key is the key of the secret resource
Key string `json:"key"`
}
// DataSource represents the source of data.
// Only one of its members may be specified.
type DataSource struct {
// ConfigMapName is the name of the ConfigMap
// +optional
ConfigMap *ConfigMapSource `json:"configMap,omitempty"`
// RawData is raw data
// +optional
RawData *string `json:"rawData,omitempty"`
}
// PodTemplate defines the desired spec and annotations of Pod
type PodTemplate struct {
// Standard object's metadata. Only `annotations` and `labels` are valid.
// +optional
ObjectMeta `json:"metadata,omitempty"`
}
// ServiceTemplate defines the desired spec and annotations of Service
type ServiceTemplate struct {
// Standard object's metadata. Only `annotations` and `labels` are valid.
// +optional
ObjectMeta `json:"metadata,omitempty"`
}
// ObjectMeta is metadata of objects.
// This is partially copied from metav1.ObjectMeta.
type ObjectMeta struct {
// Labels is a map of string keys and values.
// +optional
Labels map[string]string `json:"labels,omitempty"`
// Annotations is a map of string keys and values.
// +optional
Annotations map[string]string `json:"annotations,omitempty"`
}
type ConfigMapSource struct {
// Name is the name of a configmap resource
// +kubebuiler:validation:Required
Name string `json:"name"`
// Namespace is the namespace of a configmap resource
// if omitted, it will be the same namespace as the WebSite resource
// +optional
Namespace string `json:"namespace"`
// Key is the name of a key
// +kubebuiler:validation:Required
Key string `json:"key"`
}
// WebSiteStatus defines the observed state of WebSite
type WebSiteStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
// Revision is a revision currently available to the public
Revision string `json:"revision"`
// Ready is the current status
Ready corev1.ConditionStatus `json:"ready"`
}
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.ready"
//+kubebuilder:printcolumn:name="REVISION",type="string",JSONPath=".status.revision"
// WebSite is the Schema for the websites API
type WebSite struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec WebSiteSpec `json:"spec,omitempty"`
Status WebSiteStatus `json:"status,omitempty"`
}
//+kubebuilder:object:root=true
// WebSiteList contains a list of WebSite
type WebSiteList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []WebSite `json:"items"`
}
func init() {
SchemeBuilder.Register(&WebSite{}, &WebSiteList{})
}