OpenCHAMI / cloud-init

Micro-service for serving cloud-init payloads
https://openchami.dev/docs/software/cloud-init-standard-node-personalization-for-the-cloud/
MIT License
2 stars 0 forks source link

[BUG] Metadata returns an empty list instead of being empty #29

Open alexlovelltroy opened 1 day ago

alexlovelltroy commented 1 day ago

After adding a group to the cloud-init server that only contains user-data information (and not meta-data) information, the group ends up represented in the meta-data anyway as a key and empty list.

$curl -s $CLOUD_INIT_URL/x1000c1s7b1n0/meta-data
groups:
  ssh: []

In the above example ssh should not be listed if it is empty.

groups should also not be listed if it is empty.

davidallendj commented 14 hours ago

Would this simply require exporting the groups field and adding field tag to this line? https://github.com/OpenCHAMI/cloud-init/blob/main/internal/memstore/ciMemStore.go#L24

So something like:

type MemStore struct {
    list   map[string]citypes.CI
    Groups map[string]citypes.GroupData `json:"groups,omitempty"`
}