Skip to content

Commit

Permalink
chore: bump sdk-go (#3523)
Browse files Browse the repository at this point in the history
  • Loading branch information
Codelax authored Dec 4, 2023
1 parent 1899440 commit a642c48
Show file tree
Hide file tree
Showing 15 changed files with 18,711 additions and 3,925 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ require (
github.com/moby/buildkit v0.11.6
github.com/opencontainers/go-digest v1.0.0
github.com/pkg/errors v0.9.1
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231128131307-c646e1e0b2cd
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231204101346-c5bd7ba3032a
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.8.0
github.com/spf13/pflag v1.0.5
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -490,8 +490,8 @@ github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDN
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231128131307-c646e1e0b2cd h1:6dpfWGj/wJKaSsFXYV2Rx7TlyLrEZkFIzv/zqjwtjSU=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231128131307-c646e1e0b2cd/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231204101346-c5bd7ba3032a h1:8YL3e+eToTCcjnTtLUkOLtG/uksSCtDUVM93gSEl1B0=
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.21.0.20231204101346-c5bd7ba3032a/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
github.com/sclevine/spec v1.4.0 h1:z/Q9idDcay5m5irkZ28M7PtQM4aOISzOpj4bUPkDee8=
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
Expand Down
40 changes: 0 additions & 40 deletions internal/namespaces/instance/v1/custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package instance

import (
"context"
"fmt"
"reflect"
"sort"
"strconv"
Expand Down Expand Up @@ -352,45 +351,6 @@ func imageUpdateCommand() *core.Command {
client := core.ExtractClient(ctx)
api := instance.NewAPI(client)

getImageResponse, err := api.GetImage(&instance.GetImageRequest{
Zone: request.Zone,
ImageID: request.ImageID,
})
if err != nil {
return nil, fmt.Errorf("cannot get image %s: %w", request.ImageID, err)
}

if request.Name == nil {
request.Name = &getImageResponse.Image.Name
}
if request.Arch == "" {
request.Arch = getImageResponse.Image.Arch
}
if request.CreationDate == nil {
request.CreationDate = getImageResponse.Image.CreationDate
}
if request.ModificationDate == nil {
request.ModificationDate = getImageResponse.Image.ModificationDate
}
if request.ExtraVolumes == nil {
request.ExtraVolumes = make(map[string]*instance.VolumeTemplate)
for k, v := range getImageResponse.Image.ExtraVolumes {
volume := instance.VolumeTemplate{
ID: v.ID,
Name: v.Name,
Size: v.Size,
VolumeType: v.VolumeType,
}
request.ExtraVolumes[k] = &volume
}
}
if request.RootVolume == nil {
request.RootVolume = getImageResponse.Image.RootVolume
}
if !request.Public && !getImageResponse.Image.Public {
request.Public = getImageResponse.Image.Public
}

return api.UpdateImage(request)
},
Examples: []*core.Example{
Expand Down
9 changes: 6 additions & 3 deletions internal/namespaces/instance/v1/custom_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func Test_ImageDelete(t *testing.T) {

func createImage(metaKey string) core.BeforeFunc {
return core.BeforeFuncCombine(
createServerBionic("Server"),
createServer("Server"),
core.ExecStoreBeforeCmd("Snapshot", `scw instance snapshot create volume-id={{ (index .Server.Volumes "0").ID }}`),
core.ExecStoreBeforeCmd(metaKey, `scw instance image create snapshot-id={{ .Snapshot.Snapshot.ID }} arch=x86_64`),
)
Expand Down Expand Up @@ -102,6 +102,7 @@ func Test_ImageUpdate(t *testing.T) {
Cmd: "scw instance image update {{ .ImageName.Image.ID }} name=foo",
Check: core.TestCheckCombine(
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
assert.Equal(t, "foo", ctx.Result.(*instance.UpdateImageResponse).Image.Name)
},
core.TestCheckGolden(),
Expand All @@ -118,11 +119,12 @@ func Test_ImageUpdate(t *testing.T) {
Commands: GetCommands(),
Cmd: "scw instance image update {{ .ImagePub.Image.ID }} public=true",
Check: core.TestCheckCombine(
core.TestCheckGolden(),
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
assert.Equal(t, true, ctx.Result.(*instance.UpdateImageResponse).Image.Public)
},
core.TestCheckGolden(),
core.TestCheckExitCode(0),
),
AfterFunc: core.AfterFuncCombine(
deleteServer("Server"),
Expand All @@ -140,6 +142,7 @@ func Test_ImageUpdate(t *testing.T) {
Cmd: "scw instance image update {{ .ImageExtraVol.Image.ID }} extra-volumes.1.id={{ .SnapshotVol.ID }}",
Check: core.TestCheckCombine(
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
assert.Equal(t, "snapVol", ctx.Result.(*instance.UpdateImageResponse).Image.ExtraVolumes["1"].Name)
},
core.TestCheckGolden(),
Expand Down
2 changes: 2 additions & 0 deletions internal/namespaces/instance/v1/custom_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func Test_UpdateSnapshot(t *testing.T) {
core.TestCheckGolden(),
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
snapshot := ctx.Result.(*instance.Snapshot)
assert.Equal(t, snapshot.Name, "cli-test-snapshot-update-tags")
assert.Len(t, snapshot.Tags, 2)
Expand All @@ -44,6 +45,7 @@ func Test_UpdateSnapshot(t *testing.T) {
core.TestCheckGolden(),
core.TestCheckExitCode(0),
func(t *testing.T, ctx *core.CheckFuncCtx) {
assert.NotNil(t, ctx.Result)
snapshot := ctx.Result.(*instance.Snapshot)
assert.Equal(t, snapshot.Name, "cli-test-snapshot-update-name-updated")
assert.Len(t, snapshot.Tags, 2)
Expand Down
Loading

0 comments on commit a642c48

Please sign in to comment.