mirror of https://github.com/k3s-io/k3s
describe allowedTopologies
parent
795b213455
commit
eefd337ba0
|
@ -3474,6 +3474,9 @@ func describeStorageClass(sc *storage.StorageClass, events *api.EventList) (stri
|
|||
if sc.VolumeBindingMode != nil {
|
||||
w.Write(LEVEL_0, "VolumeBindingMode:\t%s\n", *sc.VolumeBindingMode)
|
||||
}
|
||||
if sc.AllowedTopologies != nil {
|
||||
printAllowedTopologies(w, sc.AllowedTopologies)
|
||||
}
|
||||
if events != nil {
|
||||
DescribeEvents(events, w)
|
||||
}
|
||||
|
@ -3482,6 +3485,38 @@ func describeStorageClass(sc *storage.StorageClass, events *api.EventList) (stri
|
|||
})
|
||||
}
|
||||
|
||||
func printAllowedTopologies(w PrefixWriter, topologies []api.TopologySelectorTerm) {
|
||||
w.Write(LEVEL_0, "AllowedTopologies:\t")
|
||||
if len(topologies) == 0 {
|
||||
w.WriteLine("<none>")
|
||||
return
|
||||
}
|
||||
w.WriteLine("")
|
||||
for i, term := range topologies {
|
||||
printTopologySelectorTermsMultilineWithIndent(w, LEVEL_1, fmt.Sprintf("Term %d", i), "\t", term.MatchLabelExpressions)
|
||||
}
|
||||
}
|
||||
|
||||
func printTopologySelectorTermsMultilineWithIndent(w PrefixWriter, indentLevel int, title, innerIndent string, reqs []api.TopologySelectorLabelRequirement) {
|
||||
w.Write(indentLevel, "%s:%s", title, innerIndent)
|
||||
|
||||
if len(reqs) == 0 {
|
||||
w.WriteLine("<none>")
|
||||
return
|
||||
}
|
||||
|
||||
for i, req := range reqs {
|
||||
if i != 0 {
|
||||
w.Write(indentLevel, "%s", innerIndent)
|
||||
}
|
||||
exprStr := fmt.Sprintf("%s %s", req.Key, "in")
|
||||
if len(req.Values) > 0 {
|
||||
exprStr = fmt.Sprintf("%s [%s]", exprStr, strings.Join(req.Values, ", "))
|
||||
}
|
||||
w.Write(LEVEL_0, "%s\n", exprStr)
|
||||
}
|
||||
}
|
||||
|
||||
type PodDisruptionBudgetDescriber struct {
|
||||
clientset.Interface
|
||||
}
|
||||
|
|
|
@ -1433,6 +1433,32 @@ func TestDescribeStorageClass(t *testing.T) {
|
|||
},
|
||||
ReclaimPolicy: &reclaimPolicy,
|
||||
VolumeBindingMode: &bindingMode,
|
||||
AllowedTopologies: []api.TopologySelectorTerm{
|
||||
{
|
||||
MatchLabelExpressions: []api.TopologySelectorLabelRequirement{
|
||||
{
|
||||
Key: "failure-domain.beta.kubernetes.io/zone",
|
||||
Values: []string{"zone1"},
|
||||
},
|
||||
{
|
||||
Key: "kubernetes.io/hostname",
|
||||
Values: []string{"node1"},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
MatchLabelExpressions: []api.TopologySelectorLabelRequirement{
|
||||
{
|
||||
Key: "failure-domain.beta.kubernetes.io/zone",
|
||||
Values: []string{"zone2"},
|
||||
},
|
||||
{
|
||||
Key: "kubernetes.io/hostname",
|
||||
Values: []string{"node2"},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
s := StorageClassDescriber{f}
|
||||
out, err := s.Describe("", "foo", printers.DescriberSettings{ShowEvents: true})
|
||||
|
@ -1446,7 +1472,13 @@ func TestDescribeStorageClass(t *testing.T) {
|
|||
!strings.Contains(out, "value1") ||
|
||||
!strings.Contains(out, "value2") ||
|
||||
!strings.Contains(out, "Retain") ||
|
||||
!strings.Contains(out, "bindingmode") {
|
||||
!strings.Contains(out, "bindingmode") ||
|
||||
!strings.Contains(out, "failure-domain.beta.kubernetes.io/zone") ||
|
||||
!strings.Contains(out, "zone1") ||
|
||||
!strings.Contains(out, "kubernetes.io/hostname") ||
|
||||
!strings.Contains(out, "node1") ||
|
||||
!strings.Contains(out, "zone2") ||
|
||||
!strings.Contains(out, "node2") {
|
||||
t.Errorf("unexpected out: %s", out)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue