Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(apple-silicon): improve vizualization compatible server types #3834

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/namespaces/applesilicon/v1alpha1/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func GetCommands() *core.Commands {
human.RegisterMarshalerFunc(applesilicon.ServerTypeCPU{}, cpuMarshalerFunc)
human.RegisterMarshalerFunc(applesilicon.ServerTypeDisk{}, diskMarshalerFunc)
human.RegisterMarshalerFunc(applesilicon.ServerTypeMemory{}, memoryMarshalerFunc)
human.RegisterMarshalerFunc(applesilicon.OS{}, OSMarshalerFunc)

human.RegisterMarshalerFunc(applesilicon.ServerStatus(""), human.EnumMarshalFunc(serverStatusMarshalSpecs))
human.RegisterMarshalerFunc(applesilicon.ServerTypeStock(""), human.EnumMarshalFunc(serverTypeStockMarshalSpecs))
Expand Down
22 changes: 22 additions & 0 deletions internal/namespaces/applesilicon/v1alpha1/custom_os.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package applesilicon
Laure-di marked this conversation as resolved.
Show resolved Hide resolved

import (
"github.com/scaleway/scaleway-cli/v2/internal/human"
applesilicon "github.com/scaleway/scaleway-sdk-go/api/applesilicon/v1alpha1"
)

func OSMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error) {
type tmp applesilicon.OS
os := tmp(i.(applesilicon.OS))
opt.Sections = []*human.MarshalSection{
{
FieldName: "CompatibleServerTypes",
Title: "CompatibleServerTypes",
},
}
str, err := human.Marshal(os, opt)
if err != nil {
return "", err
}
return str, nil
}
20 changes: 20 additions & 0 deletions internal/namespaces/applesilicon/v1alpha1/custom_os_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package applesilicon_test

import (
"testing"

"github.com/scaleway/scaleway-cli/v2/internal/core"
applesilicon "github.com/scaleway/scaleway-cli/v2/internal/namespaces/applesilicon/v1alpha1"
)

func Test_OSDisplay(t *testing.T) {
t.Run("Simple", core.Test(&core.TestConfig{
Commands: applesilicon.GetCommands(),
Cmd: "scw apple-silicon os get e08d1e5d-b4b9-402a-9f9a-97732d17e374",
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
),
DisableParallel: false,
}))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
version: 1
interactions:
- request:
body: '{"id":"e08d1e5d-b4b9-402a-9f9a-97732d17e374", "name":"macos-sonoma-14",
"label":"macOS Sonoma 14", "image_url":"https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
"family":"Sonoma", "is_beta":false, "xcode_version":"15", "version":"14.4",
"compatible_server_types":["M1-M", "M2-M", "M2-L"]}'
form: {}
headers:
User-Agent:
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.22.2; darwin; amd64) cli-e2e-test
url: https://api.scaleway.com/apple-silicon/v1alpha1/zones/fr-par-1/os/e08d1e5d-b4b9-402a-9f9a-97732d17e374
method: GET
response:
body: '{"id":"e08d1e5d-b4b9-402a-9f9a-97732d17e374", "name":"macos-sonoma-14",
"label":"macOS Sonoma 14", "image_url":"https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
"family":"Sonoma", "is_beta":false, "xcode_version":"15", "version":"14.4",
"compatible_server_types":["M1-M", "M2-M", "M2-L"]}'
headers:
Content-Length:
- "319"
Content-Security-Policy:
- default-src 'none'; frame-ancestors 'none'
Content-Type:
- application/json
Date:
- Tue, 11 Jun 2024 08:37:10 GMT
Server:
- Scaleway API Gateway (fr-par-1;edge02)
Strict-Transport-Security:
- max-age=63072000
X-Content-Type-Options:
- nosniff
X-Frame-Options:
- DENY
X-Request-Id:
- 08a51853-e9da-4643-aaf8-13d240591fb3
status: 200 OK
code: 200
duration: ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
ID e08d1e5d-b4b9-402a-9f9a-97732d17e374
Name macos-sonoma-14
Label macOS Sonoma 14
ImageURL https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png
Family Sonoma
IsBeta false
Version 14.4
XcodeVersion 15

CompatibleServerTypes:
[M1-M M2-M M2-L]
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
{
"id": "e08d1e5d-b4b9-402a-9f9a-97732d17e374",
"name": "macos-sonoma-14",
"label": "macOS Sonoma 14",
"image_url": "https://scw-apple-silicon.s3.fr-par.scw.cloud/scw-console/os/macos-sonoma.png",
"family": "Sonoma",
"is_beta": false,
"version": "14.4",
"xcode_version": "15",
"compatible_server_types": [
"M1-M",
"M2-M",
"M2-L"
]
}
Loading