mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-06 07:57:35 +00:00
hide operator when describe pod with empty value tolerations
This commit is contained in:
@@ -3321,9 +3321,9 @@ func printTolerationsMultilineWithIndent(w PrefixWriter, initialIndent, title, i
|
||||
w.Write(LEVEL_0, "%s", initialIndent)
|
||||
w.Write(LEVEL_0, "%s", innerIndent)
|
||||
}
|
||||
w.Write(LEVEL_0, "%s=%s", toleration.Key, toleration.Value)
|
||||
if len(toleration.Operator) != 0 {
|
||||
w.Write(LEVEL_0, ":%s", toleration.Operator)
|
||||
w.Write(LEVEL_0, "%s", toleration.Key)
|
||||
if len(toleration.Value) != 0 {
|
||||
w.Write(LEVEL_0, "=%s", toleration.Value)
|
||||
}
|
||||
if len(toleration.Effect) != 0 {
|
||||
w.Write(LEVEL_0, ":%s", toleration.Effect)
|
||||
|
||||
@@ -102,8 +102,11 @@ func TestDescribePodTolerations(t *testing.T) {
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Tolerations: []api.Toleration{
|
||||
{Key: "key0", Operator: api.TolerationOpExists},
|
||||
{Key: "key1", Value: "value1"},
|
||||
{Key: "key2", Value: "value2", Effect: api.TaintEffectNoExecute, TolerationSeconds: &[]int64{300}[0]},
|
||||
{Key: "key2", Operator: api.TolerationOpEqual, Value: "value2", Effect: api.TaintEffectNoSchedule},
|
||||
{Key: "key3", Value: "value3", Effect: api.TaintEffectNoExecute, TolerationSeconds: &[]int64{300}[0]},
|
||||
{Key: "key4", Effect: api.TaintEffectNoExecute, TolerationSeconds: &[]int64{60}[0]},
|
||||
},
|
||||
},
|
||||
})
|
||||
@@ -113,8 +116,13 @@ func TestDescribePodTolerations(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
if !strings.Contains(out, "key1=value1") || !strings.Contains(out, "key2=value2:NoExecute for 300s") || !strings.Contains(out, "Tolerations:") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
if !strings.Contains(out, "key0\n") ||
|
||||
!strings.Contains(out, "key1=value1\n") ||
|
||||
!strings.Contains(out, "key2=value2:NoSchedule\n") ||
|
||||
!strings.Contains(out, "key3=value3:NoExecute for 300s\n") ||
|
||||
!strings.Contains(out, "key4:NoExecute for 60s\n") ||
|
||||
!strings.Contains(out, "Tolerations:") {
|
||||
t.Errorf("unexpected out:\n%s", out)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user