Skip to content

Commit

Permalink
feat: populate meta-data for microvms
Browse files Browse the repository at this point in the history
Added keys:

* instance_id
* local_hostname
* platform
* cluster_name

fixes #42
  • Loading branch information
yitsushi committed Dec 10, 2021
1 parent cf83e67 commit 66aaf16
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions internal/services/microvm/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

0 comments on commit 66aaf16

Please sign in to comment.