Skip to content

Commit 325075f

Browse files
Laure-dijremy42
andauthored
feat(baremetal): display cloud-init supported (#5202)
Co-authored-by: Jonathan R. <[email protected]>
1 parent da7f67c commit 325075f

File tree

3 files changed

+3551
-3030
lines changed

3 files changed

+3551
-3030
lines changed

internal/namespaces/baremetal/v1/custom_offer.go

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package baremetal
22

33
import (
44
"context"
5+
"slices"
56
"strings"
67

78
"github.com/fatih/color"
@@ -62,8 +63,9 @@ func listOfferMarshalerFunc(i any, opt *human.MarshalOpt) (string, error) {
6263

6364
type customOffer struct {
6465
*baremetal.Offer
65-
KgCo2Equivalent *float32 `json:"kg_co2_equivalent"`
66-
M3WaterUsage *float32 `json:"m3_water_usage"`
66+
KgCo2Equivalent *float32 `json:"kg_co2_equivalent"`
67+
M3WaterUsage *float32 `json:"m3_water_usage"`
68+
CloudInitSupported bool `json:"cloud_init_supported"`
6769
}
6870

6971
func serverOfferListBuilder(c *core.Command) *core.Command {
@@ -75,9 +77,9 @@ func serverOfferListBuilder(c *core.Command) *core.Command {
7577
{Label: "Disks", FieldName: "Disks"},
7678
{Label: "CPUs", FieldName: "CPUs"},
7779
{Label: "Memories", FieldName: "Memories"},
78-
{Label: "Options", FieldName: "Options"},
7980
{Label: "Bandwidth", FieldName: "Bandwidth"},
8081
{Label: "PrivateBandwidth", FieldName: "PrivateBandwidth"},
82+
{Label: "CloudInit supported", FieldName: "CloudInitSupported"},
8183
},
8284
}
8385

@@ -126,21 +128,24 @@ func serverOfferListBuilder(c *core.Command) *core.Command {
126128

127129
var customOfferRes []customOffer
128130
for _, offer := range offers.Offers {
131+
cloudInitSupported := slices.Contains(offer.Tags, "cloud-init")
129132
impact, ok := impactMap[offer.Name]
130133
if !ok {
131134
customOfferRes = append(customOfferRes, customOffer{
132-
Offer: offer,
133-
KgCo2Equivalent: nil,
134-
M3WaterUsage: nil,
135+
Offer: offer,
136+
KgCo2Equivalent: nil,
137+
M3WaterUsage: nil,
138+
CloudInitSupported: cloudInitSupported,
135139
})
136140

137141
continue
138142
}
139143

140144
customOfferRes = append(customOfferRes, customOffer{
141-
Offer: offer,
142-
KgCo2Equivalent: impact.EnvironmentalImpactEstimation.KgCo2Equivalent,
143-
M3WaterUsage: impact.EnvironmentalImpactEstimation.M3WaterUsage,
145+
Offer: offer,
146+
KgCo2Equivalent: impact.EnvironmentalImpactEstimation.KgCo2Equivalent,
147+
M3WaterUsage: impact.EnvironmentalImpactEstimation.M3WaterUsage,
148+
CloudInitSupported: cloudInitSupported,
144149
})
145150
}
146151

0 commit comments

Comments
 (0)