|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 5 | + runtime "k8s.io/apimachinery/pkg/runtime" |
| 6 | +) |
| 7 | + |
| 8 | +func init() { |
| 9 | + SchemeBuilder.Register(&HTTP01Proxy{}, &HTTP01ProxyList{}) |
| 10 | +} |
| 11 | + |
| 12 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 13 | +//+kubebuilder:object:root=true |
| 14 | + |
| 15 | +// HTTP01ProxyList is a list of HTTP01Proxy objects. |
| 16 | +type HTTP01ProxyList struct { |
| 17 | + metav1.TypeMeta `json:",inline"` |
| 18 | + |
| 19 | + // metadata is the standard list's metadata. |
| 20 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 21 | + metav1.ListMeta `json:"metadata"` |
| 22 | + Items []HTTP01Proxy `json:"items"` |
| 23 | +} |
| 24 | + |
| 25 | +// +genclient |
| 26 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 27 | +// +kubebuilder:subresource:status |
| 28 | + |
| 29 | +// HTTP01Proxy describes configuration for a cluster-managed HTTP-01 challenge proxy. |
| 30 | +// The name must be `default` to make it a singleton per namespace. |
| 31 | +// |
| 32 | +// When an HTTP01Proxy is created and enabled, the operator may deploy and |
| 33 | +// manage components needed to route and respond to ACME HTTP-01 challenges |
| 34 | +// for eligible namespaces. |
| 35 | +// |
| 36 | +// +kubebuilder:object:root=true |
| 37 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" |
| 38 | +// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default'",message="http01proxy is a singleton, .metadata.name must be 'default'" |
| 39 | +// +operator-sdk:csv:customresourcedefinitions:displayName="HTTP01Proxy" |
| 40 | +type HTTP01Proxy struct { |
| 41 | + metav1.TypeMeta `json:",inline"` |
| 42 | + |
| 43 | + // metadata is the standard object's metadata. |
| 44 | + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata |
| 45 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 46 | + |
| 47 | + // spec is the specification of the desired behavior of the HTTP01Proxy. |
| 48 | + // +kubebuilder:validation:Required |
| 49 | + // +required |
| 50 | + Spec HTTP01ProxySpec `json:"spec,omitempty"` |
| 51 | + |
| 52 | + // status is the most recently observed status of the HTTP01Proxy. |
| 53 | + Status HTTP01ProxyStatus `json:"status,omitempty"` |
| 54 | +} |
| 55 | + |
| 56 | +// HTTP01ProxySpec defines desired behavior for managing HTTP-01 challenge proxying. |
| 57 | +type HTTP01ProxySpec struct { |
| 58 | + // enabled turns the HTTP01 proxy manager on or off. |
| 59 | + // +kubebuilder:default:=false |
| 60 | + // +kubebuilder:validation:Optional |
| 61 | + // +optional |
| 62 | + Enabled bool `json:"enabled,omitempty"` |
| 63 | + |
| 64 | + // allowedNamespaces restricts which namespaces may utilize the proxy. |
| 65 | + // When unset, no namespaces are allowed. Set a label selector to opt-in. |
| 66 | + // +kubebuilder:validation:Optional |
| 67 | + // +optional |
| 68 | + AllowedNamespaces *metav1.LabelSelector `json:"allowedNamespaces,omitempty"` |
| 69 | + |
| 70 | + // cleanupTTLSeconds is the TTL in seconds to keep any ephemeral resources |
| 71 | + // (like Routes) after a challenge is completed. |
| 72 | + // +kubebuilder:default:=600 |
| 73 | + // +kubebuilder:validation:Minimum:=0 |
| 74 | + // +kubebuilder:validation:Optional |
| 75 | + // +optional |
| 76 | + CleanupTTLSeconds int32 `json:"cleanupTTLSeconds,omitempty"` |
| 77 | + |
| 78 | + // controllerConfig configures labels or other defaults for resources |
| 79 | + // created by the controller. |
| 80 | + // +kubebuilder:validation:Optional |
| 81 | + // +optional |
| 82 | + ControllerConfig *ControllerConfig `json:"controllerConfig,omitempty"` |
| 83 | +} |
| 84 | + |
| 85 | +// HTTP01ProxyStatus is the most recently observed status of the HTTP01Proxy. |
| 86 | +type HTTP01ProxyStatus struct { |
| 87 | + // conditions holds information about the current state of the HTTP01 proxy controller. |
| 88 | + ConditionalStatus `json:",inline,omitempty"` |
| 89 | + |
| 90 | + // activeChallenges is a best-effort count of challenges currently being serviced. |
| 91 | + // +kubebuilder:validation:Optional |
| 92 | + // +optional |
| 93 | + ActiveChallenges int32 `json:"activeChallenges,omitempty"` |
| 94 | + |
| 95 | + // lastError contains a short description of the last reconciliation error, if any. |
| 96 | + // +kubebuilder:validation:Optional |
| 97 | + // +optional |
| 98 | + LastError string `json:"lastError,omitempty"` |
| 99 | +} |
| 100 | + |
| 101 | +// DeepCopyInto copies all properties of this object into another object of the |
| 102 | +// same type that is provided as a pointer. |
| 103 | +func (in *HTTP01Proxy) DeepCopyInto(out *HTTP01Proxy) { |
| 104 | + *out = *in |
| 105 | + out.TypeMeta = in.TypeMeta |
| 106 | + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) |
| 107 | + in.Spec.DeepCopyInto(&out.Spec) |
| 108 | + in.Status.DeepCopyInto(&out.Status) |
| 109 | +} |
| 110 | + |
| 111 | +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTP01Proxy. |
| 112 | +func (in *HTTP01Proxy) DeepCopy() *HTTP01Proxy { |
| 113 | + if in == nil { |
| 114 | + return nil |
| 115 | + } |
| 116 | + out := new(HTTP01Proxy) |
| 117 | + in.DeepCopyInto(out) |
| 118 | + return out |
| 119 | +} |
| 120 | + |
| 121 | +// DeepCopyObject copies the receiver, creating a new runtime.Object. |
| 122 | +func (in *HTTP01Proxy) DeepCopyObject() runtime.Object { |
| 123 | + if c := in.DeepCopy(); c != nil { |
| 124 | + return c |
| 125 | + } |
| 126 | + return nil |
| 127 | +} |
| 128 | + |
| 129 | +// DeepCopyInto for HTTP01ProxySpec |
| 130 | +func (in *HTTP01ProxySpec) DeepCopyInto(out *HTTP01ProxySpec) { |
| 131 | + *out = *in |
| 132 | + if in.AllowedNamespaces != nil { |
| 133 | + out.AllowedNamespaces = new(metav1.LabelSelector) |
| 134 | + in.AllowedNamespaces.DeepCopyInto(out.AllowedNamespaces) |
| 135 | + } |
| 136 | + if in.ControllerConfig != nil { |
| 137 | + out.ControllerConfig = new(ControllerConfig) |
| 138 | + *out.ControllerConfig = *in.ControllerConfig |
| 139 | + if in.ControllerConfig.Labels != nil { |
| 140 | + out.ControllerConfig.Labels = make(map[string]string, len(in.ControllerConfig.Labels)) |
| 141 | + for k, v := range in.ControllerConfig.Labels { |
| 142 | + out.ControllerConfig.Labels[k] = v |
| 143 | + } |
| 144 | + } |
| 145 | + } |
| 146 | +} |
| 147 | + |
| 148 | +// DeepCopyInto for HTTP01ProxyStatus |
| 149 | +func (in *HTTP01ProxyStatus) DeepCopyInto(out *HTTP01ProxyStatus) { |
| 150 | + *out = *in |
| 151 | + if in.Conditions != nil { |
| 152 | + out.Conditions = make([]metav1.Condition, len(in.Conditions)) |
| 153 | + for i := range in.Conditions { |
| 154 | + in.Conditions[i].DeepCopyInto(&out.Conditions[i]) |
| 155 | + } |
| 156 | + } |
| 157 | +} |
| 158 | + |
| 159 | +// DeepCopyInto copies all properties of this object into another object. |
| 160 | +func (in *HTTP01ProxyList) DeepCopyInto(out *HTTP01ProxyList) { |
| 161 | + *out = *in |
| 162 | + out.TypeMeta = in.TypeMeta |
| 163 | + in.ListMeta.DeepCopyInto(&out.ListMeta) |
| 164 | + if in.Items != nil { |
| 165 | + out.Items = make([]HTTP01Proxy, len(in.Items)) |
| 166 | + for i := range in.Items { |
| 167 | + in.Items[i].DeepCopyInto(&out.Items[i]) |
| 168 | + } |
| 169 | + } |
| 170 | +} |
| 171 | + |
| 172 | +// DeepCopy creates a new deep-copied HTTP01ProxyList. |
| 173 | +func (in *HTTP01ProxyList) DeepCopy() *HTTP01ProxyList { |
| 174 | + if in == nil { |
| 175 | + return nil |
| 176 | + } |
| 177 | + out := new(HTTP01ProxyList) |
| 178 | + in.DeepCopyInto(out) |
| 179 | + return out |
| 180 | +} |
| 181 | + |
| 182 | +// DeepCopyObject creates a new runtime.Object deep copy. |
| 183 | +func (in *HTTP01ProxyList) DeepCopyObject() runtime.Object { |
| 184 | + if c := in.DeepCopy(); c != nil { |
| 185 | + return c |
| 186 | + } |
| 187 | + return nil |
| 188 | +} |
0 commit comments