Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
188 changes: 188 additions & 0 deletions api/operator/v1alpha1/http01proxy_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
)

func init() {
SchemeBuilder.Register(&HTTP01Proxy{}, &HTTP01ProxyList{})
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
//+kubebuilder:object:root=true

// HTTP01ProxyList is a list of HTTP01Proxy objects.
type HTTP01ProxyList struct {
metav1.TypeMeta `json:",inline"`

// metadata is the standard list's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ListMeta `json:"metadata"`
Items []HTTP01Proxy `json:"items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +kubebuilder:subresource:status

// HTTP01Proxy describes configuration for a cluster-managed HTTP-01 challenge proxy.
// The name must be `default` to make it a singleton per namespace.
//
// When an HTTP01Proxy is created and enabled, the operator may deploy and
// manage components needed to route and respond to ACME HTTP-01 challenges
// for eligible namespaces.
//
// +kubebuilder:object:root=true
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:validation:XValidation:rule="self.metadata.name == 'default'",message="http01proxy is a singleton, .metadata.name must be 'default'"
// +operator-sdk:csv:customresourcedefinitions:displayName="HTTP01Proxy"
type HTTP01Proxy struct {
metav1.TypeMeta `json:",inline"`

// metadata is the standard object's metadata.
// More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
metav1.ObjectMeta `json:"metadata,omitempty"`

// spec is the specification of the desired behavior of the HTTP01Proxy.
// +kubebuilder:validation:Required
// +required
Spec HTTP01ProxySpec `json:"spec,omitempty"`

Comment on lines +47 to +51
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Make spec truly required (drop omitempty)

You’ve marked Spec as required, but json:",omitempty" can cause clients to omit it when zero-valued, leading to CRD validation failures. Remove omitempty.

Apply this diff:

-    // +kubebuilder:validation:Required
-    // +required
-    Spec HTTP01ProxySpec `json:"spec,omitempty"`
+    // +kubebuilder:validation:Required
+    // +required
+    Spec HTTP01ProxySpec `json:"spec"`
🤖 Prompt for AI Agents
In api/operator/v1alpha1/http01proxy_types.go around lines 47 to 51, the Spec
field is marked required but the struct tag uses `json:"spec,omitempty"`, which
allows omission; remove `omitempty` so the JSON tag is `json:"spec"` to ensure
the field is always serialized and CRD validation works as intended. Update the
struct tag accordingly and run `make generate`/rebuild CRDs if your project uses
codegen to propagate the change.

// status is the most recently observed status of the HTTP01Proxy.
Status HTTP01ProxyStatus `json:"status,omitempty"`
}

// HTTP01ProxySpec defines desired behavior for managing HTTP-01 challenge proxying.
type HTTP01ProxySpec struct {
// enabled turns the HTTP01 proxy manager on or off.
// +kubebuilder:default:=false
// +kubebuilder:validation:Optional
// +optional
Enabled bool `json:"enabled,omitempty"`

// allowedNamespaces restricts which namespaces may utilize the proxy.
// When unset, no namespaces are allowed. Set a label selector to opt-in.
// +kubebuilder:validation:Optional
// +optional
AllowedNamespaces *metav1.LabelSelector `json:"allowedNamespaces,omitempty"`

// cleanupTTLSeconds is the TTL in seconds to keep any ephemeral resources
// (like Routes) after a challenge is completed.
// +kubebuilder:default:=600
// +kubebuilder:validation:Minimum:=0
// +kubebuilder:validation:Optional
// +optional
CleanupTTLSeconds int32 `json:"cleanupTTLSeconds,omitempty"`

// controllerConfig configures labels or other defaults for resources
// created by the controller.
// +kubebuilder:validation:Optional
// +optional
ControllerConfig *ControllerConfig `json:"controllerConfig,omitempty"`
}

// HTTP01ProxyStatus is the most recently observed status of the HTTP01Proxy.
type HTTP01ProxyStatus struct {
// conditions holds information about the current state of the HTTP01 proxy controller.
ConditionalStatus `json:",inline,omitempty"`

// activeChallenges is a best-effort count of challenges currently being serviced.
// +kubebuilder:validation:Optional
// +optional
ActiveChallenges int32 `json:"activeChallenges,omitempty"`

// lastError contains a short description of the last reconciliation error, if any.
// +kubebuilder:validation:Optional
// +optional
LastError string `json:"lastError,omitempty"`
}

// DeepCopyInto copies all properties of this object into another object of the
// same type that is provided as a pointer.
func (in *HTTP01Proxy) DeepCopyInto(out *HTTP01Proxy) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
in.Status.DeepCopyInto(&out.Status)
}

// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new HTTP01Proxy.
func (in *HTTP01Proxy) DeepCopy() *HTTP01Proxy {
if in == nil {
return nil
}
out := new(HTTP01Proxy)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject copies the receiver, creating a new runtime.Object.
func (in *HTTP01Proxy) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}

// DeepCopyInto for HTTP01ProxySpec
func (in *HTTP01ProxySpec) DeepCopyInto(out *HTTP01ProxySpec) {
*out = *in
if in.AllowedNamespaces != nil {
out.AllowedNamespaces = new(metav1.LabelSelector)
in.AllowedNamespaces.DeepCopyInto(out.AllowedNamespaces)
}
if in.ControllerConfig != nil {
out.ControllerConfig = new(ControllerConfig)
*out.ControllerConfig = *in.ControllerConfig
if in.ControllerConfig.Labels != nil {
out.ControllerConfig.Labels = make(map[string]string, len(in.ControllerConfig.Labels))
for k, v := range in.ControllerConfig.Labels {
out.ControllerConfig.Labels[k] = v
}
}
}
}

// DeepCopyInto for HTTP01ProxyStatus
func (in *HTTP01ProxyStatus) DeepCopyInto(out *HTTP01ProxyStatus) {
*out = *in
if in.Conditions != nil {
out.Conditions = make([]metav1.Condition, len(in.Conditions))
for i := range in.Conditions {
in.Conditions[i].DeepCopyInto(&out.Conditions[i])
}
}
}

// DeepCopyInto copies all properties of this object into another object.
func (in *HTTP01ProxyList) DeepCopyInto(out *HTTP01ProxyList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
out.Items = make([]HTTP01Proxy, len(in.Items))
for i := range in.Items {
in.Items[i].DeepCopyInto(&out.Items[i])
}
}
}

// DeepCopy creates a new deep-copied HTTP01ProxyList.
func (in *HTTP01ProxyList) DeepCopy() *HTTP01ProxyList {
if in == nil {
return nil
}
out := new(HTTP01ProxyList)
in.DeepCopyInto(out)
return out
}

// DeepCopyObject creates a new runtime.Object deep copy.
func (in *HTTP01ProxyList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
22 changes: 21 additions & 1 deletion api/operator/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading