mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 19:23:40 +00:00
kubectl/describe: use function calls to build field selector
Instead of using string concatenation. Signed-off-by: Jingyuan Liang <jingyuanliang@google.com>
This commit is contained in:
parent
60c4c2b252
commit
a2dc34cb17
@ -3631,10 +3631,11 @@ func (d *NodeDescriber) Describe(namespace, name string, describerSettings Descr
|
||||
return "", err
|
||||
}
|
||||
|
||||
fieldSelector, err := fields.ParseSelector("spec.nodeName=" + name + ",status.phase!=" + string(corev1.PodSucceeded) + ",status.phase!=" + string(corev1.PodFailed))
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
fieldSelector := fields.AndSelectors(
|
||||
fields.OneTermEqualSelector("spec.nodeName", name),
|
||||
fields.OneTermNotEqualSelector("status.phase", string(corev1.PodSucceeded)),
|
||||
fields.OneTermNotEqualSelector("status.phase", string(corev1.PodFailed)),
|
||||
)
|
||||
// in a policy aware setting, users may have access to a node, but not all pods
|
||||
// in that case, we note that the user does not have access to the pods
|
||||
canViewPods := true
|
||||
|
Loading…
Reference in New Issue
Block a user