-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16327 from deads2k/api-07-fieldselector
Automatic merge from submit-queue (batch tested with PRs 16384, 16327, 16199, 16286, 16378) fix remaining field selectors Really hoping that #16305 works out. This updates all the rest for that pattern and allows us to remove a ton of boilerplate while maintaining decent unit test coverage. Still need a "you forgot to add a test" test, but that was already missing.
- Loading branch information
Showing
40 changed files
with
488 additions
and
397 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
@@ -1,13 +1,17 @@ | ||
package authorization | ||
|
||
import "k8s.io/apimachinery/pkg/fields" | ||
import ( | ||
"fmt" | ||
|
||
// PolicyBindingToSelectableFields returns a label set that represents the object | ||
// changes to the returned keys require registering conversions for existing versions using Scheme.AddFieldLabelConversionFunc | ||
func PolicyBindingToSelectableFields(policyBinding *PolicyBinding) fields.Set { | ||
return fields.Set{ | ||
"metadata.name": policyBinding.Name, | ||
"metadata.namespace": policyBinding.Namespace, | ||
"policyRef.namespace": policyBinding.PolicyRef.Namespace, | ||
"k8s.io/apimachinery/pkg/fields" | ||
runtime "k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func PolicyBindingFieldSelector(obj runtime.Object, fieldSet fields.Set) error { | ||
policyBinding, ok := obj.(*PolicyBinding) | ||
if !ok { | ||
return fmt.Errorf("%T not a PolicyBinding", obj) | ||
} | ||
fieldSet["policyRef.namespace"] = policyBinding.PolicyRef.Namespace | ||
return nil | ||
} |
This file contains 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 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 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 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 |
---|---|---|
@@ -1,14 +1,19 @@ | ||
package build | ||
|
||
import "k8s.io/apimachinery/pkg/fields" | ||
|
||
// BuildToSelectableFields returns a label set that represents the object | ||
// changes to the returned keys require registering conversions for existing versions using Scheme.AddFieldLabelConversionFunc | ||
func BuildToSelectableFields(build *Build) fields.Set { | ||
return fields.Set{ | ||
"metadata.name": build.Name, | ||
"metadata.namespace": build.Namespace, | ||
"status": string(build.Status.Phase), | ||
"podName": GetBuildPodName(build), | ||
import ( | ||
"fmt" | ||
|
||
"k8s.io/apimachinery/pkg/fields" | ||
runtime "k8s.io/apimachinery/pkg/runtime" | ||
) | ||
|
||
func BuildFieldSelector(obj runtime.Object, fieldSet fields.Set) error { | ||
build, ok := obj.(*Build) | ||
if !ok { | ||
return fmt.Errorf("%T not a Build", obj) | ||
} | ||
fieldSet["status"] = string(build.Status.Phase) | ||
fieldSet["podName"] = GetBuildPodName(build) | ||
|
||
return nil | ||
} |
This file contains 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 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 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 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 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
Oops, something went wrong.