mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-15 06:01:50 +00:00
Merge pull request #57050 from juanvallejo/jvallejo/check-empty-label-resource-builder
Automatic merge from submit-queue (batch tested with PRs 56676, 57050, 54881, 56822, 57113). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. check for empty label before assigning Prevents an empty label from being assigned to the resource builder when calling its `LabelSelectorParam` parameter. Currently, we assign the address of the provided selector string, even if the string is empty - this has the potential of returning erroneous failures since we check to see [if a selector was provided here](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/resource/builder.go#L470), for example, by doing a nil check. Storing the pointer to [an empty string value](https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/resource/builder.go#L344) would break this check as the pointer is no longer nil **Release note**: ```release-note NONE ``` cc @deads2k @smarterclayton
This commit is contained in:
@@ -341,6 +341,10 @@ func (b *Builder) LabelSelectorParam(s string) *Builder {
|
|||||||
// LabelSelector accepts a selector directly and will filter the resulting list by that object.
|
// LabelSelector accepts a selector directly and will filter the resulting list by that object.
|
||||||
// Use LabelSelectorParam instead for user input.
|
// Use LabelSelectorParam instead for user input.
|
||||||
func (b *Builder) LabelSelector(selector string) *Builder {
|
func (b *Builder) LabelSelector(selector string) *Builder {
|
||||||
|
if len(selector) == 0 {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
b.labelSelector = &selector
|
b.labelSelector = &selector
|
||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user