Skip to content

Commit a5daf5f

Browse files
authored
fix(instance): complete image list fields (#3236)
1 parent 6f6aa7a commit a5daf5f

File tree

2 files changed

+11
-33
lines changed

2 files changed

+11
-33
lines changed

internal/namespaces/instance/v1/custom_image.go

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func imagesMarshalerFunc(i interface{}, _ *human.MarshalOpt) (string, error) {
7878
ServerName: image.ServerName,
7979
ServerID: image.ServerID,
8080
Arch: image.Arch,
81-
OrganizationID: image.OrganizationID,
82-
ProjectID: image.ProjectID,
81+
OrganizationID: image.Organization,
82+
ProjectID: image.Project,
8383
CreationDate: image.CreationDate,
8484
ModificationDate: image.ModificationDate,
8585
})
@@ -153,23 +153,11 @@ func imageCreateBuilder(c *core.Command) *core.Command {
153153

154154
// customImage is based on instance.Image, with additional information about the server
155155
type imageListItem struct {
156-
ID string `json:"id"`
157-
Name string `json:"name"`
158-
Arch instance.Arch `json:"arch"`
159-
CreationDate *time.Time `json:"creation_date"`
160-
ModificationDate *time.Time `json:"modification_date"`
161-
DefaultBootscript *instance.Bootscript `json:"default_bootscript"`
162-
ExtraVolumes map[string]*instance.Volume `json:"extra_volumes"`
163-
OrganizationID string `json:"organization"`
164-
ProjectID string `json:"project"`
165-
Public bool `json:"public"`
166-
RootVolume *instance.VolumeSummary `json:"root_volume"`
167-
State instance.ImageState `json:"state"`
156+
*instance.Image
168157

169158
// Replace Image.FromServer
170-
ServerID string `json:"server_id"`
171-
ServerName string `json:"server_name"`
172-
Zone scw.Zone `json:"zone"`
159+
ServerID string `json:"server_id"`
160+
ServerName string `json:"server_name"`
173161
}
174162

175163
// imageListBuilder list the images for a given organization/project.
@@ -210,19 +198,7 @@ func imageListBuilder(c *core.Command) *core.Command {
210198
customImages := []*imageListItem(nil)
211199
for _, image := range images {
212200
newCustomImage := &imageListItem{
213-
ID: image.ID,
214-
Name: image.Name,
215-
Arch: image.Arch,
216-
CreationDate: image.CreationDate,
217-
ModificationDate: image.ModificationDate,
218-
DefaultBootscript: image.DefaultBootscript,
219-
ExtraVolumes: image.ExtraVolumes,
220-
OrganizationID: image.Organization,
221-
ProjectID: image.Project,
222-
Public: image.Public,
223-
RootVolume: image.RootVolume,
224-
State: image.State,
225-
Zone: image.Zone,
201+
Image: image,
226202
}
227203
customImages = append(customImages, newCustomImage)
228204

internal/namespaces/instance/v1/testdata/test-image-list-simple.golden

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ ID NAME STATE PUBLIC
1212
"modification_date": "1970-01-01T00:00:00.0Z",
1313
"default_bootscript": null,
1414
"extra_volumes": {},
15+
"from_server": "",
1516
"organization": "951df375-e094-4d26-97c1-ba548eeb9c42",
16-
"project": "951df375-e094-4d26-97c1-ba548eeb9c42",
1717
"public": false,
1818
"root_volume": {
1919
"id": "4af8f168-68b8-4958-957c-f1ea72bd5022",
@@ -22,8 +22,10 @@ ID NAME STATE PUBLIC
2222
"volume_type": "l_ssd"
2323
},
2424
"state": "available",
25+
"project": "951df375-e094-4d26-97c1-ba548eeb9c42",
26+
"tags": [],
27+
"zone": "fr-par-1",
2528
"server_id": "",
26-
"server_name": "",
27-
"zone": "fr-par-1"
29+
"server_name": ""
2830
}
2931
]

0 commit comments

Comments
 (0)