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(instance): use zone field in listing #731

Merged
merged 5 commits into from
Feb 28, 2020
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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ require (
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-isatty v0.0.9
github.com/pkg/errors v0.9.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200212160027-75ab2f6aeda3
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200226081452-7bdc7806b035
github.com/sergi/go-diff v1.0.0 // indirect
github.com/spf13/cobra v0.0.5
github.com/spf13/pflag v1.0.5 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200212160027-75ab2f6aeda3 h1:BQb9gbsenI8ZwZmfN7O93VrlXW8eiDlL7Mz+glsK/os=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200212160027-75ab2f6aeda3/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200226081452-7bdc7806b035 h1:PGuOvUWTkkNFh/cN4IIR45YaFWfbLgijvarr7mBqUFg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.5.0.20200226081452-7bdc7806b035/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/spf13/afero v1.1.2 h1:m8/z1t7/fwjysjQRYbP0RD+bUIF/8tJwPdEZsI83ACI=
Expand Down
10 changes: 1 addition & 9 deletions internal/namespaces/instance/v1/custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func imageListBuilder(c *core.Command) *core.Command {
Public: image.Public,
RootVolume: image.RootVolume,
State: image.State,
Zone: image.Zone,
}

if image.FromServer != "" {
Expand All @@ -74,17 +75,8 @@ func imageListBuilder(c *core.Command) *core.Command {
if err != nil {
return nil, err
}
zone := scw.Zone("")
if getServerResponse.Server.Location != nil {
parsedZone, err := scw.ParseZone(getServerResponse.Server.Location.ZoneID)
if err != nil {
return nil, err
}
zone = parsedZone
}
newCustomImage.ServerID = getServerResponse.Server.ID
newCustomImage.ServerName = getServerResponse.Server.Name
newCustomImage.Zone = zone
}
customImages = append(customImages, newCustomImage)
}
Expand Down
10 changes: 1 addition & 9 deletions internal/namespaces/instance/v1/custom_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,6 @@ func serversMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error)
servers := i.([]*instance.Server)
humanServers := make([]*humanServerInList, 0)
for _, server := range servers {
var zone scw.Zone
if server.Location != nil {
parsedZone, err := scw.ParseZone(server.Location.ZoneID)
if err != nil {
return "", err
}
zone = parsedZone
}
publicIPAddress := net.IP(nil)
if server.PublicIP != nil {
publicIPAddress = server.PublicIP.Address
Expand All @@ -94,7 +86,7 @@ func serversMarshalerFunc(i interface{}, opt *human.MarshalOpt) (string, error)
ID: server.ID,
Name: server.Name,
State: server.State,
Zone: zone,
Zone: server.Zone,
ModificationDate: server.ModificationDate,
CreationDate: server.CreationDate,
ImageID: serverImageID,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
id 94de5a1b-173e-4add-8229-b228ce85979b
name cli-srv-condescending-buck
organization aba2d0d0-b01d-4d88-b322-935edc96d0fd
id ffb226b8-b196-4b8a-b92d-9691250cce2e
name cli-srv-xenodochial-payne
organization b2593aa3-d0e8-4366-89c3-6e666abe1f6f
allowed-actions.0 poweron
allowed-actions.1 backup
commercial-type DEV1-S
creation-date few seconds ago
dynamic-ip-required false
enable-ipv6 false
hostname cli-srv-condescending-buck
hostname cli-srv-xenodochial-payne
image.id f974feac-abae-4365-b988-8ec7d1cec10d
image.name Ubuntu Bionic Beaver
image.arch x86_64
Expand All @@ -20,16 +20,18 @@ image.organization 51b656e3-4865-41e8-adbc-0c45bdd780db
image.public true
image.root-volume dd5f5c10-23b1-4c9c-8445-eb6740957c84
image.state available
image.zone fr-par-1
protected false
public-ip.id 75588e7a-1e08-4e82-960b-c2be7ca13b39
public-ip.address 163.172.140.16
public-ip.id 46cafeb6-9ea3-4a04-91ec-bf8f0a519ded
public-ip.address 51.158.117.86
public-ip.dynamic false
modification-date few seconds ago
state archived
bootscript x86_64 mainline 4.9.93 rev1
boot-type local
volumes 1
security-group.id 49822f6c-1d32-465c-a017-720691d159b2
security-group.id 980142a3-a959-4aee-8325-91a6ba787439
security-group.name Default security group
state-detail
arch x86_64
zone fr-par-1
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ image.organization 51b656e3-4865-41e8-adbc-0c45bdd780db
image.public true
image.root-volume dd5f5c10-23b1-4c9c-8445-eb6740957c84
image.state available
image.zone fr-par-1
protected false
public-ip.id febae361-dcf5-428d-a8ca-5ee64fc46190
public-ip.address 51.158.117.222
Expand All @@ -34,6 +35,7 @@ security-group.id e5bf4522-94b4-4933-bebb-9b21f786b4af
security-group.name Default security group
state-detail
arch x86_64
zone fr-par-1

Server Image:
id f974feac-abae-4365-b988-8ec7d1cec10d
Expand All @@ -48,10 +50,11 @@ organization 51b656e3-4865-41e8-adbc-0c45bdd780db
public true
root-volume dd5f5c10-23b1-4c9c-8445-eb6740957c84
state available
zone fr-par-1

Server - Allowed Actions:
[poweron backup]

Volumes:
ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION STATE
db2275ad-aed3-4150-a106-0044e86b1e6b snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 20 GB l_ssd few seconds ago few seconds ago 14d2f7ae-9775-414c-9bed-6810e060d500 available
ID NAME EXPORT URI SIZE VOLUME TYPE CREATION DATE MODIFICATION DATE ORGANIZATION STATE ZONE
db2275ad-aed3-4150-a106-0044e86b1e6b snapshot-de728daa-0bf6-4c64-abf5-a9477e791c83-2019-03-05_10:13 20 GB l_ssd few seconds ago few seconds ago 14d2f7ae-9775-414c-9bed-6810e060d500 available fr-par-1
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ organization aba2d0d0-b01d-4d88-b322-935edc96d0fd
public false
root-volume 26a882cd-62d5-47d6-b52f-c3e677c806b5
state available
zone fr-par-1
Loading