Skip to content

Commit ebd75c8

Browse files
committed
Address comments 1
1 parent b73b053 commit ebd75c8

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

config/v1/tests/apiservers.config.openshift.io/HTTP01ChallengeProxy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,4 @@ tests:
140140
mode: CustomDeployment
141141
customDeployment:
142142
internalPort: 65536
143-
expectedError: "spec.http01ChallengeProxy.customDeployment.internalPort: Invalid value: 65536: must be less than or equal to 65535"
143+
expectedError: "spec.http01ChallengeProxy.customDeployment.internalPort: Invalid value: 65536: must be less than or equal to 65535"

config/v1/types_apiserver.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ type APIServerSpec struct {
7373
// This enables cert-manager to perform HTTP01 ACME challenges for API endpoint certificates.
7474
// +openshift:enable:FeatureGate=HTTP01ChallengeProxy
7575
// +optional
76-
HTTP01ChallengeProxy *HTTP01ChallengeProxySpec `json:"http01ChallengeProxy,omitempty"`
76+
HTTP01ChallengeProxy HTTP01ChallengeProxySpec `json:"http01ChallengeProxy,omitzero"`
7777
}
7878

7979
// AuditProfileType defines the audit policy profile type.
@@ -240,26 +240,34 @@ const (
240240
EncryptionTypeKMS EncryptionType = "KMS"
241241
)
242242

243+
// HTTP01ChallengeProxyMode defines how the HTTP01 challenge proxy should be deployed.
244+
// +kubebuilder:validation:Enum=DefaultDeployment;CustomDeployment
245+
type HTTP01ChallengeProxyMode string
246+
247+
const (
248+
// HTTP01ChallengeProxyModeDefaultDeployment enables the proxy with default configuration.
249+
HTTP01ChallengeProxyModeDefaultDeployment HTTP01ChallengeProxyMode = "DefaultDeployment"
250+
// HTTP01ChallengeProxyModeCustomDeployment enables the proxy with user-specified configuration.
251+
HTTP01ChallengeProxyModeCustomDeployment HTTP01ChallengeProxyMode = "CustomDeployment"
252+
)
253+
243254
// +union
244255
// +kubebuilder:validation:XValidation:rule="self.mode == 'CustomDeployment' ? has(self.customDeployment) : !has(self.customDeployment)",message="customDeployment is required when mode is CustomDeployment and forbidden otherwise"
245256
type HTTP01ChallengeProxySpec struct {
246257
// mode controls whether the HTTP01 challenge proxy is active and how it should be deployed.
247258
// DefaultDeployment enables the proxy with default configuration.
248259
// CustomDeployment enables the proxy with user-specified configuration.
249-
// +kubebuilder:validation:Enum=DefaultDeployment;CustomDeployment
250-
// +kubebuilder:default=DefaultDeployment
251-
// +optional
260+
// +required
252261
// +unionDiscriminator
253-
Mode string `json:"mode,omitempty"`
262+
Mode HTTP01ChallengeProxyMode `json:"mode,omitempty"`
254263

255264
// customDeployment contains configuration options when mode is CustomDeployment.
256265
// This field is only valid when mode is CustomDeployment.
257266
// +optional
258267
// +unionMember
259-
CustomDeployment HTTP01ChallengeProxyCustomDeploymentSpec `json:"customDeployment,omitzero,omitempty"`
268+
CustomDeployment *HTTP01ChallengeProxyCustomDeploymentSpec `json:"customDeployment,omitzero,omitempty"`
260269
}
261270

262-
// +kubebuilder:validation:MinProperties=1
263271
type HTTP01ChallengeProxyCustomDeploymentSpec struct {
264272
// internalPort specifies the internal port used by the proxy service.
265273
// Valid values are 1024-65535.
@@ -268,7 +276,7 @@ type HTTP01ChallengeProxyCustomDeploymentSpec struct {
268276
// +kubebuilder:validation:Minimum=1024
269277
// +kubebuilder:validation:Maximum=65535
270278
// +optional
271-
InternalPort *int32 `json:"internalPort,omitempty"`
279+
InternalPort int32 `json:"internalPort,omitempty"`
272280
}
273281

274282
type APIServerStatus struct {

0 commit comments

Comments
 (0)