Skip to content

Commit b73b053

Browse files
committed
Make internalPort optional to resolve API compatibility error
- Changed internalPort from required to optional (*int32 with omitempty) - This resolves the NoNewRequiredFields API compatibility violation - Updated test case to reflect optional field behavior - Users can now omit internalPort for custom deployments - Regenerated deepcopy functions and OpenAPI schemas
1 parent 75b13cb commit b73b053

File tree

5 files changed

+24
-16
lines changed

5 files changed

+24
-16
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,23 @@ tests:
104104
customDeployment:
105105
internalPort: 8888
106106
expectedError: "customDeployment is required when mode is CustomDeployment and forbidden otherwise"
107-
- name: Should reject CustomDeployment mode with customDeployment but missing internalPort
107+
- name: Should be able to create CustomDeployment mode with empty customDeployment (internalPort optional)
108108
initial: |
109109
apiVersion: config.openshift.io/v1
110110
kind: APIServer
111111
spec:
112112
http01ChallengeProxy:
113113
mode: CustomDeployment
114114
customDeployment: {}
115-
expectedError: "spec.http01ChallengeProxy.customDeployment.internalPort: Required value"
115+
expected: |
116+
apiVersion: config.openshift.io/v1
117+
kind: APIServer
118+
spec:
119+
audit:
120+
profile: Default
121+
http01ChallengeProxy:
122+
mode: CustomDeployment
123+
customDeployment: {}
116124
- name: Should reject CustomDeployment mode with port below minimum 1023
117125
initial: |
118126
apiVersion: config.openshift.io/v1

config/v1/types_apiserver.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,12 @@ type HTTP01ChallengeProxySpec struct {
263263
type HTTP01ChallengeProxyCustomDeploymentSpec struct {
264264
// internalPort specifies the internal port used by the proxy service.
265265
// Valid values are 1024-65535.
266-
// This port must be specified to avoid conflicts with other workloads on the host.
266+
// When not specified for CustomDeployment mode, users should ensure their chosen port
267+
// does not conflict with other workloads on the host.
267268
// +kubebuilder:validation:Minimum=1024
268269
// +kubebuilder:validation:Maximum=65535
269-
// +required
270-
InternalPort int32 `json:"internalPort"`
270+
// +optional
271+
InternalPort *int32 `json:"internalPort,omitempty"`
271272
}
272273

273274
type APIServerStatus struct {

config/v1/zz_generated.deepcopy.go

Lines changed: 7 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/generated_openapi/zz_generated.openapi.go

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi/openapi.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6893,15 +6893,11 @@
68936893
},
68946894
"com.github.openshift.api.config.v1.HTTP01ChallengeProxyCustomDeploymentSpec": {
68956895
"type": "object",
6896-
"required": [
6897-
"internalPort"
6898-
],
68996896
"properties": {
69006897
"internalPort": {
6901-
"description": "internalPort specifies the internal port used by the proxy service. Valid values are 1024-65535. This port must be specified to avoid conflicts with other workloads on the host.",
6898+
"description": "internalPort specifies the internal port used by the proxy service. Valid values are 1024-65535. When not specified for CustomDeployment mode, users should ensure their chosen port does not conflict with other workloads on the host.",
69026899
"type": "integer",
6903-
"format": "int32",
6904-
"default": 0
6900+
"format": "int32"
69056901
}
69066902
}
69076903
},

0 commit comments

Comments
 (0)