describer: use new ServiceCIDR API

Change-Id: Iff11c70f20bab3e55e4e569fb110ef25dd6dd97e
This commit is contained in:
Antonio Ojea 2023-10-29 17:55:03 +00:00
parent 5123a93b34
commit 513fdb5422
2 changed files with 35 additions and 11 deletions

View File

@ -2870,13 +2870,7 @@ func (c *ServiceCIDRDescriber) describeServiceCIDRV1alpha1(svc *networkingv1alph
printLabelsMultiline(w, "Labels", svc.Labels) printLabelsMultiline(w, "Labels", svc.Labels)
printAnnotationsMultiline(w, "Annotations", svc.Annotations) printAnnotationsMultiline(w, "Annotations", svc.Annotations)
if svc.Spec.IPv4 != "" { w.Write(LEVEL_0, "CIDRs:\t%v\n", strings.Join(svc.Spec.CIDRs, ", "))
w.Write(LEVEL_0, "IPv4:\t%s\n", svc.Spec.IPv4)
}
if svc.Spec.IPv6 != "" {
w.Write(LEVEL_0, "IPv6:\t%s\n", svc.Spec.IPv6)
}
if len(svc.Status.Conditions) > 0 { if len(svc.Status.Conditions) > 0 {
w.Write(LEVEL_0, "Status:\n") w.Write(LEVEL_0, "Status:\n")

View File

@ -5944,16 +5944,46 @@ func TestDescribeServiceCIDR(t *testing.T) {
Name: "foo.123", Name: "foo.123",
}, },
Spec: networkingv1alpha1.ServiceCIDRSpec{ Spec: networkingv1alpha1.ServiceCIDRSpec{
IPv4: "10.1.0.0/16", CIDRs: []string{"10.1.0.0/16", "fd00:1:1::/64"},
IPv6: "fd00:1:1::/64",
}, },
}), }),
output: `Name: foo.123 output: `Name: foo.123
Labels: <none> Labels: <none>
Annotations: <none> Annotations: <none>
IPv4: 10.1.0.0/16 CIDRs: 10.1.0.0/16, fd00:1:1::/64
IPv6: fd00:1:1::/64 Events: <none>` + "\n",
},
"ServiceCIDR v1alpha1 IPv4": {
input: fake.NewSimpleClientset(&networkingv1alpha1.ServiceCIDR{
ObjectMeta: metav1.ObjectMeta{
Name: "foo.123",
},
Spec: networkingv1alpha1.ServiceCIDRSpec{
CIDRs: []string{"10.1.0.0/16"},
},
}),
output: `Name: foo.123
Labels: <none>
Annotations: <none>
CIDRs: 10.1.0.0/16
Events: <none>` + "\n",
},
"ServiceCIDR v1alpha1 IPv6": {
input: fake.NewSimpleClientset(&networkingv1alpha1.ServiceCIDR{
ObjectMeta: metav1.ObjectMeta{
Name: "foo.123",
},
Spec: networkingv1alpha1.ServiceCIDRSpec{
CIDRs: []string{"fd00:1:1::/64"},
},
}),
output: `Name: foo.123
Labels: <none>
Annotations: <none>
CIDRs: fd00:1:1::/64
Events: <none>` + "\n", Events: <none>` + "\n",
}, },
} }