Skip to content

Commit 3413d70

Browse files
Laure-diremyleone
andauthored
fix(apple-silicon): improve vizualization compatible server types (#3834)
Co-authored-by: Rémy Léone <[email protected]>
1 parent d822cb4 commit 3413d70

File tree

5 files changed

+113
-0
lines changed

5 files changed

+113
-0
lines changed

internal/namespaces/applesilicon/v1alpha1/custom.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func GetCommands() *core.Commands {
1717
human.RegisterMarshalerFunc(applesilicon.ServerTypeCPU{}, cpuMarshalerFunc)
1818
human.RegisterMarshalerFunc(applesilicon.ServerTypeDisk{}, diskMarshalerFunc)
1919
human.RegisterMarshalerFunc(applesilicon.ServerTypeMemory{}, memoryMarshalerFunc)
20+
human.RegisterMarshalerFunc(applesilicon.OS{}, OSMarshalerFunc)
2021

2122
human.RegisterMarshalerFunc(applesilicon.ServerStatus(""), human.EnumMarshalFunc(serverStatusMarshalSpecs))
2223
human.RegisterMarshalerFunc(applesilicon.ServerTypeStock(""), human.EnumMarshalFunc(serverTypeStockMarshalSpecs))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package applesilicon
2+
3+
import (
4+
"github.com/scaleway/scaleway-cli/v2/internal/human"
5+
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
6+
)
7+
8+
func OSMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) {
9+
type tmp applesilicon.OS
10+
os := tmp(i.(applesilicon.OS))
11+
opt.Sections = []*human.MarshalSection{
12+
{
13+
FieldName: "CompatibleServerTypes",
14+
Title: "CompatibleServerTypes",
15+
},
16+
}
17+
str, err := human.Marshal(os, opt)
18+
if err != nil {
19+
return "", err
20+
}
21+
return str, nil
22+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package applesilicon_test
2+
3+
import (
4+
"testing"
5+
6+
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
8+
)
9+
10+
func Test_OSDisplay(t *testing.T) {
11+
t.Run("Simple", core.Test(&core.TestConfig{
12+
Commands: applesilicon.GetCommands(),
13+
Cmd: "scw apple-silicon os get e08d1e5d-b4b9-402a-9f9a-97732d17e374",
14+
Check: core.TestCheckCombine(
15+
core.TestCheckGolden(),
16+
core.TestCheckExitCode(0),
17+
),
18+
DisableParallel: false,
19+
}))
20+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: '{"id":"e08d1e5d-b4b9-402a-9f9a-97732d17e374", "name":"macos-sonoma-14",
6+
"label":"macOS Sonoma 14", "image_url":"https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
7+
"family":"Sonoma", "is_beta":false, "xcode_version":"15", "version":"14.4",
8+
"compatible_server_types":["M1-M", "M2-M", "M2-L"]}'
9+
form: {}
10+
headers:
11+
User-Agent:
12+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.22.2; darwin; amd64) cli-e2e-test
13+
url: https://api.scaleway.com/apple-silicon/v1alpha1/zones/fr-par-1/os/e08d1e5d-b4b9-402a-9f9a-97732d17e374
14+
method: GET
15+
response:
16+
body: '{"id":"e08d1e5d-b4b9-402a-9f9a-97732d17e374", "name":"macos-sonoma-14",
17+
"label":"macOS Sonoma 14", "image_url":"https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
18+
"family":"Sonoma", "is_beta":false, "xcode_version":"15", "version":"14.4",
19+
"compatible_server_types":["M1-M", "M2-M", "M2-L"]}'
20+
headers:
21+
Content-Length:
22+
- "319"
23+
Content-Security-Policy:
24+
- default-src 'none'; frame-ancestors 'none'
25+
Content-Type:
26+
- application/json
27+
Date:
28+
- Tue, 11 Jun 2024 08:37:10 GMT
29+
Server:
30+
- Scaleway API Gateway (fr-par-1;edge02)
31+
Strict-Transport-Security:
32+
- max-age=63072000
33+
X-Content-Type-Options:
34+
- nosniff
35+
X-Frame-Options:
36+
- DENY
37+
X-Request-Id:
38+
- 08a51853-e9da-4643-aaf8-13d240591fb3
39+
status: 200 OK
40+
code: 200
41+
duration: ""
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
3+
ID e08d1e5d-b4b9-402a-9f9a-97732d17e374
4+
Name macos-sonoma-14
5+
Label macOS Sonoma 14
6+
ImageURL https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png
7+
Family Sonoma
8+
IsBeta false
9+
Version 14.4
10+
XcodeVersion 15
11+
12+
CompatibleServerTypes:
13+
[M1-M M2-M M2-L]
14+
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
15+
{
16+
"id": "e08d1e5d-b4b9-402a-9f9a-97732d17e374",
17+
"name": "macos-sonoma-14",
18+
"label": "macOS Sonoma 14",
19+
"image_url": "https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
20+
"family": "Sonoma",
21+
"is_beta": false,
22+
"version": "14.4",
23+
"xcode_version": "15",
24+
"compatible_server_types": [
25+
"M1-M",
26+
"M2-M",
27+
"M2-L"
28+
]
29+
}

0 commit comments

Comments
 (0)