From d37a145029e78d3a2295a2661b4ee9298583542f Mon Sep 17 00:00:00 2001 From: Benjamin Alpert Date: Tue, 16 Jan 2024 12:45:43 +0100 Subject: [PATCH] Add print column for `Prefixes` in `NetworkInterface` (#960) Co-authored-by: Benjamin Alpert --- .../networkinterface/storage/tableconvertor.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/registry/networking/networkinterface/storage/tableconvertor.go b/internal/registry/networking/networkinterface/storage/tableconvertor.go index e9892a295..faf54a221 100644 --- a/internal/registry/networking/networkinterface/storage/tableconvertor.go +++ b/internal/registry/networking/networkinterface/storage/tableconvertor.go @@ -23,7 +23,8 @@ var ( {Name: "Name", Type: "string", Format: "name", Description: objectMetaSwaggerDoc["name"]}, {Name: "Network", Type: "string", Description: "The network this network interface is connected to"}, {Name: "Machine", Type: "string", Description: "The machine this network interface is used by"}, - {Name: "IPs", Type: "string", Description: "List of effective IPs of the network interface"}, + {Name: "IPs", Type: "string", Description: "The list of effective IPs of the network interface"}, + {Name: "Prefixes", Type: "string", Description: "The list of effective prefixes assigned to this network interface"}, {Name: "VirtualIP", Type: "string", Description: "The virtual IP assigned to this interface, if any"}, {Name: "State", Type: "string", Description: "The state of the network interface"}, {Name: "Age", Type: "string", Format: "date", Description: objectMetaSwaggerDoc["creationTimestamp"]}, @@ -68,6 +69,15 @@ func (c *convertor) ConvertToTable(ctx context.Context, obj runtime.Object, tabl } else { cells = append(cells, "") } + if effectivePrefixes := networkInterface.Status.Prefixes; len(effectivePrefixes) > 0 { + var ePrefixes []string + for _, prefix := range effectivePrefixes { + ePrefixes = append(ePrefixes, prefix.String()) + } + cells = append(cells, strings.Join(ePrefixes, ",")) + } else { + cells = append(cells, "") + } if vip := networkInterface.Status.VirtualIP; vip != nil { cells = append(cells, vip.String()) } else {