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): list image with image from not found server #854

Merged
merged 7 commits into from
Apr 17, 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.4
github.com/mattn/go-isatty v0.0.11
github.com/pkg/errors v0.9.1 // indirect
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200409105057-297e3dbdccb5
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200414183251-a6244a393e63
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 @@ -67,6 +67,8 @@ github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403173805-25a10631420d
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200403173805-25a10631420d/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200409105057-297e3dbdccb5 h1:QmrgbtSAIDKRTnzAjdpop3yFAqHFO4MEc8W+/0Epu88=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200409105057-297e3dbdccb5/go.mod h1:CJJ5VAbozOl0yEw7nHB9+7BXTJbIn6h7W+f6Gau5IP8=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200414183251-a6244a393e63 h1:8tRzNwnY+PK6TD21bvKU0p334p+kApiKdHRO3xsZgpg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.6.0.20200414183251-a6244a393e63/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/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
Expand Down
30 changes: 18 additions & 12 deletions internal/namespaces/instance/v1/custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,26 @@ func imageListBuilder(c *core.Command) *core.Command {
State: image.State,
Zone: image.Zone,
}
customImages = append(customImages, newCustomImage)

if image.FromServer != "" {
serverReq := instance.GetServerRequest{
Zone: req.Zone,
ServerID: image.FromServer,
}
getServerResponse, err := api.GetServer(&serverReq)
if err != nil {
return nil, err
}
newCustomImage.ServerID = getServerResponse.Server.ID
newCustomImage.ServerName = getServerResponse.Server.Name
if image.FromServer == "" {
continue
}
customImages = append(customImages, newCustomImage)

serverReq := instance.GetServerRequest{
Zone: req.Zone,
ServerID: image.FromServer,
}
getServerResponse, err := api.GetServer(&serverReq)
if _, ok := err.(*scw.ResourceNotFoundError); ok {
newCustomImage.ServerName = "-"
continue
}
if err != nil {
return nil, err
}
newCustomImage.ServerID = getServerResponse.Server.ID
newCustomImage.ServerName = getServerResponse.Server.Name
}

return customImages, nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WARNING: 2019/12/09 16:04:07 cannot get image 7a892c1a-bbdc-491f-9974-4008e3708664: scaleway-sdk-go: http error 404 Not Found: "7a892c1a-bbdc-491f-9974-4008e3708664" not found
WARNING: 2019/12/09 16:04:07 cannot get image 7a892c1a-bbdc-491f-9974-4008e3708664: scaleway-sdk-go: resource with ID 7a892c1a-bbdc-491f-9974-4008e3708664 is not found
WARNING: 2019/12/09 16:04:07 skipping image server-type compatibility validation
Cannot create the server: scaleway-sdk-go: http error 404 Not Found: "7a892c1a-bbdc-491f-9974-4008e3708664" not found
Cannot create the server: scaleway-sdk-go: resource with ID 7a892c1a-bbdc-491f-9974-4008e3708664 is not found
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"11111111-1111-1111-1111-111111111111" not found
Cannot find resource '' with ID '11111111-1111-1111-1111-111111111111'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"11111111-1111-1111-1111-111111111111" not found
Cannot find resource '' with ID '11111111-1111-1111-1111-111111111111'
Original file line number Diff line number Diff line change
@@ -1 +1 @@
"11111111-1111-1111-1111-111111111111" not found
Cannot find resource '' with ID '11111111-1111-1111-1111-111111111111'