From 57cfec52a26230bdf9f78e63a6af0a1f25a8f203 Mon Sep 17 00:00:00 2001 From: Tom Siewert Date: Mon, 14 Nov 2022 16:00:02 +0100 Subject: [PATCH] server/list: Add missing PlacementGroup to JSON (#416) Signed-off-by: Tom Siewert --- internal/cmd/server/list.go | 4 ++++ internal/cmd/util/util.go | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/internal/cmd/server/list.go b/internal/cmd/server/list.go index c1f36bb7..3d91e4cd 100644 --- a/internal/cmd/server/list.go +++ b/internal/cmd/server/list.go @@ -157,6 +157,10 @@ var ListCmd = base.ListCmd{ Labels: server.Labels, PrimaryDiskSize: server.PrimaryDiskSize, } + if server.PlacementGroup != nil { + serverPlacementGroup := util.PlacementGroupToSchema(*server.PlacementGroup) + serverSchema.PlacementGroup = &serverPlacementGroup + } if server.Image != nil { serverImage := util.ImageToSchema(*server.Image) serverSchema.Image = &serverImage diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go index ee0b6ce6..c9e45874 100644 --- a/internal/cmd/util/util.go +++ b/internal/cmd/util/util.go @@ -249,6 +249,17 @@ func LoadBalancerTypeToSchema(loadBalancerType hcloud.LoadBalancerType) schema.L return loadBalancerTypeSchema } +func PlacementGroupToSchema(placementGroup hcloud.PlacementGroup) schema.PlacementGroup { + return schema.PlacementGroup{ + ID: placementGroup.ID, + Name: placementGroup.Name, + Labels: placementGroup.Labels, + Created: placementGroup.Created, + Type: string(placementGroup.Type), + Servers: placementGroup.Servers, + } +} + // ValidateRequiredFlags ensures that flags has values for all flags with // the passed names. //