From 66aaf16bfe8c2b0e9d645380b4d6628f1cb523af Mon Sep 17 00:00:00 2001 From: Balazs Nadasdi Date: Fri, 10 Dec 2021 10:19:35 +0100 Subject: [PATCH] feat: populate meta-data for microvms Added keys: * instance_id * local_hostname * platform * cluster_name fixes #42 --- internal/services/microvm/convert.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/services/microvm/convert.go b/internal/services/microvm/convert.go index 579c7e1..1ed0b0d 100644 --- a/internal/services/microvm/convert.go +++ b/internal/services/microvm/convert.go @@ -4,6 +4,10 @@ package microvm import ( + "encoding/base64" + "fmt" + "strings" + flintlocktypes "github.com/weaveworks/flintlock/api/types" "github.com/weaveworks/cluster-api-provider-microvm/api/v1alpha1" @@ -82,5 +86,17 @@ func convertToFlintlockAPI(machineScope *scope.MachineScope) *flintlocktypes.Mic apiVM.Interfaces = append(apiVM.Interfaces, apiIface) } + userMeta := strings.Join( + []string{ + fmt.Sprintf("instance_id: %s/%s", machineScope.Namespace(), machineScope.Name()), + fmt.Sprintf("local_hostname: %s", machineScope.Name()), + "platform: liquid_metal", + fmt.Sprintf("cluster_name: %s", machineScope.ClusterName()), + }, + "\n", + ) + + apiVM.Metadata["meta-data"] = base64.StdEncoding.EncodeToString([]byte(userMeta)) + return apiVM }