generated from kubernetes/kubernetes-template-project
-
Notifications
You must be signed in to change notification settings - Fork 540
ListenerSet adjust PortNumber kubebuilder validations #3750
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dprotaso
wants to merge
11
commits into
kubernetes-sigs:main
Choose a base branch
from
dprotaso:listenerset-port-number
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
ffb8c00
set proper min/max value for listenerentry.port
dprotaso 47793aa
adjust kubebuilder annotations for PortNumber to accomodate ListenerS…
dprotaso 4d659d8
add constraints to listenerset port number in status
dprotaso 49991a7
make generate
dprotaso 6228c0b
override min/max markers when generating crds to avoid kubebuilder bug
dprotaso 6cedab5
add missing object reference validation
dprotaso f523299
address linter warnings
dprotaso 2797f27
make generate
dprotaso 223c2ac
revert gep changes - they are done in another PR
dprotaso 70e8cb5
fix default
dprotaso bbdc171
add boilerplate
dprotaso File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
config/crd/experimental/gateway.networking.x-k8s.io_xlistenersets.yaml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
Copyright 2025 The Kubernetes Authors. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
package main | ||
|
||
import ( | ||
apiext "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" | ||
"sigs.k8s.io/controller-tools/pkg/markers" | ||
) | ||
|
||
type Minimum float64 | ||
|
||
func (m Minimum) Value() float64 { | ||
return float64(m) | ||
} | ||
|
||
//nolint:unparam | ||
func (m Minimum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { | ||
val := m.Value() | ||
schema.Minimum = &val | ||
return nil | ||
} | ||
|
||
type Maximum float64 | ||
|
||
func (m Maximum) Value() float64 { | ||
return float64(m) | ||
} | ||
|
||
//nolint:unparam | ||
func (m Maximum) ApplyToSchema(schema *apiext.JSONSchemaProps) error { | ||
val := m.Value() | ||
schema.Maximum = &val | ||
return nil | ||
} | ||
|
||
// kubebuilder Min Max markers are broken with type aliases | ||
func registerMarkerOverrides(into *markers.Registry) { | ||
minMarker, _ := markers.MakeDefinition( | ||
"kubebuilder:validation:Minimum", | ||
markers.DescribesField, | ||
Minimum(0), | ||
) | ||
|
||
maxMarker, _ := markers.MakeDefinition( | ||
"kubebuilder:validation:Maximum", | ||
markers.DescribesField, | ||
Maximum(0), | ||
) | ||
|
||
into.Register(minMarker) //nolint:errcheck | ||
into.Register(maxMarker) //nolint:errcheck | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.