diff --git a/go.mod b/go.mod index 8cabd511..d4f7c200 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/golang/mock v1.6.0 github.com/google/go-cmp v0.6.0 github.com/guptarohit/asciigraph v0.5.6 - github.com/hetznercloud/hcloud-go/v2 v2.4.0 + github.com/hetznercloud/hcloud-go/v2 v2.5.0 github.com/pelletier/go-toml/v2 v2.1.1 github.com/rjeczalik/interfaces v0.3.0 github.com/spf13/cobra v1.8.0 @@ -40,7 +40,7 @@ require ( github.com/prometheus/procfs v0.11.1 // indirect github.com/rivo/uniseg v0.2.0 // indirect golang.org/x/mod v0.9.0 // indirect - golang.org/x/net v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect golang.org/x/sys v0.15.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/tools v0.6.0 // indirect diff --git a/go.sum b/go.sum index 32a10a28..8dbb63ce 100644 --- a/go.sum +++ b/go.sum @@ -37,8 +37,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/guptarohit/asciigraph v0.5.6 h1:0tra3HEhfdj1sP/9IedrCpfSiXYTtHdCgBhBL09Yx6E= github.com/guptarohit/asciigraph v0.5.6/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= -github.com/hetznercloud/hcloud-go/v2 v2.4.0 h1:MqlAE+w125PLvJRCpAJmEwrIxoVdUdOyuFUhE/Ukbok= -github.com/hetznercloud/hcloud-go/v2 v2.4.0/go.mod h1:l7fA5xsncFBzQTyw29/dw5Yr88yEGKKdc6BHf24ONS0= +github.com/hetznercloud/hcloud-go/v2 v2.5.0 h1:FkfiqB2Bz2mLSQqOskWULpmVRYOQgFy7k0hfIuXv4YI= +github.com/hetznercloud/hcloud-go/v2 v2.5.0/go.mod h1:y75vdFT0eNNnYyGWO55Qv0LI23kSgsQZl3Gyy0KMrI4= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= @@ -101,8 +101,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/internal/cmd/all/list_test.go b/internal/cmd/all/list_test.go index bf5f4722..873e8d16 100644 --- a/internal/cmd/all/list_test.go +++ b/internal/cmd/all/list_test.go @@ -2,6 +2,7 @@ package all import ( "context" + _ "embed" "net" "testing" "time" @@ -13,6 +14,9 @@ import ( "github.com/hetznercloud/hcloud-go/v2/hcloud" ) +//go:embed testdata/all_list_response.json +var allListResponseJson string + func TestListAll(t *testing.T) { fx := testutil.NewFixture(t) defer fx.Finish() @@ -287,15 +291,8 @@ func TestListAllPaidJSON(t *testing.T) { AllWithOpts(gomock.Any(), hcloud.VolumeListOpts{}). Return([]*hcloud.Volume{}, nil) - out, _, err := fx.Run(cmd, []string{"--paid", "-o=json"}) - - expOut := "{\"floating_ips\":[],\"images\":[{\"id\":114690387,\"status\":\"available\",\"type\":\"system\"," + - "\"name\":\"debian-12\",\"description\":\"Debian 12\",\"image_size\":0,\"disk_size\":5,\"created\":" + - "\"2023-06-13T06:00:00Z\",\"created_from\":null,\"bound_to\":null,\"os_flavor\":\"debian\",\"os_version\":" + - "\"12\",\"architecture\":\"x86\",\"rapid_deploy\":true,\"protection\":{\"delete\":false},\"deprecated\":" + - "\"0001-01-01T00:00:00Z\",\"deleted\":\"0001-01-01T00:00:00Z\",\"labels\":null}],\"load_balancers\":[]," + - "\"primary_ips\":[],\"servers\":[],\"volumes\":[]}\n" + jsonOut, _, err := fx.Run(cmd, []string{"--paid", "-o=json"}) assert.NoError(t, err) - assert.JSONEq(t, expOut, out) + assert.JSONEq(t, allListResponseJson, jsonOut) } diff --git a/internal/cmd/all/testdata/all_list_response.json b/internal/cmd/all/testdata/all_list_response.json new file mode 100644 index 00000000..02c9b693 --- /dev/null +++ b/internal/cmd/all/testdata/all_list_response.json @@ -0,0 +1,31 @@ +{ + "floating_ips": [], + "images": [ + { + "id": 114690387, + "status": "available", + "type": "system", + "name": "debian-12", + "description": "Debian 12", + "image_size": 0, + "disk_size": 5, + "created": "2023-06-13T06:00:00Z", + "created_from": null, + "bound_to": null, + "os_flavor": "debian", + "os_version": "12", + "architecture": "x86", + "rapid_deploy": true, + "protection": { + "delete": false + }, + "deprecated": "0001-01-01T00:00:00Z", + "deleted": null, + "labels": null + } + ], + "load_balancers": [], + "primary_ips": [], + "servers": [], + "volumes": [] +} diff --git a/internal/cmd/loadbalancer/testdata/create_response.json b/internal/cmd/loadbalancer/testdata/create_response.json index fcf364a2..3027880d 100644 --- a/internal/cmd/loadbalancer/testdata/create_response.json +++ b/internal/cmd/loadbalancer/testdata/create_response.json @@ -9,6 +9,7 @@ "ingoing_traffic": null, "labels": {}, "load_balancer_type": { + "deprecated": null, "description": "", "id": 0, "max_assigned_certificates": 0, @@ -48,4 +49,4 @@ "services": [], "targets": [] } -} \ No newline at end of file +} diff --git a/internal/cmd/primaryip/testdata/create_response.json b/internal/cmd/primaryip/testdata/create_response.json index ae901858..dd17fa00 100644 --- a/internal/cmd/primaryip/testdata/create_response.json +++ b/internal/cmd/primaryip/testdata/create_response.json @@ -21,6 +21,7 @@ "name": "fsn1-dc14", "server_types": { "available": null, + "available_for_migration": null, "supported": null } }, diff --git a/internal/cmd/server/create_test.go b/internal/cmd/server/create_test.go index c0facce8..7bf8c68b 100644 --- a/internal/cmd/server/create_test.go +++ b/internal/cmd/server/create_test.go @@ -127,7 +127,7 @@ func TestCreateJSON(t *testing.T) { Status: "available", Name: hcloud.Ptr("ubuntu-20.04"), Description: "Ubuntu 20.04", - Deprecated: time.Time{}, + Deprecated: nil, Labels: make(map[string]string), OSFlavor: "ubuntu", OSVersion: hcloud.Ptr("20.04"), @@ -141,7 +141,7 @@ func TestCreateJSON(t *testing.T) { Name: "FreeBSD-11.0-RELEASE-amd64-dvd1", Description: "FreeBSD 11.0 x64", Type: "public", - Deprecated: time.Time{}, + Deprecated: nil, }, RescueEnabled: true, Locked: true, diff --git a/internal/cmd/server/testdata/create_response.json b/internal/cmd/server/testdata/create_response.json index 87f4a8d3..c051a64f 100644 --- a/internal/cmd/server/testdata/create_response.json +++ b/internal/cmd/server/testdata/create_response.json @@ -19,6 +19,7 @@ "name": "fsn1-dc14", "server_types": { "available": null, + "available_for_migration": null, "supported": null } }, @@ -26,10 +27,10 @@ "image": { "architecture": "", "bound_to": null, - "created": "0001-01-01T00:00:00Z", + "created": null, "created_from": null, - "deleted": "0001-01-01T00:00:00Z", - "deprecated": "0001-01-01T00:00:00Z", + "deleted": null, + "deprecated": null, "description": "Ubuntu 20.04", "disk_size": 0, "id": 1, @@ -49,7 +50,7 @@ "ingoing_traffic": null, "iso": { "architecture": null, - "deprecated": "0001-01-01T00:00:00Z", + "deprecated": null, "deprecation": null, "description": "FreeBSD 11.0 x64", "id": 1, @@ -57,6 +58,7 @@ "type": "public" }, "labels": {}, + "load_balancers": null, "locked": true, "name": "cli-test", "outgoing_traffic": null, @@ -88,6 +90,7 @@ "architecture": "x86", "cores": 1, "cpu_type": "shared", + "deprecated": false, "deprecation": null, "description": "", "disk": 20, @@ -101,4 +104,4 @@ "status": "running", "volumes": null } -} \ No newline at end of file +} diff --git a/internal/cmd/util/util.go b/internal/cmd/util/util.go index f3ccb77f..5fc05949 100644 --- a/internal/cmd/util/util.go +++ b/internal/cmd/util/util.go @@ -236,7 +236,7 @@ func ImageToSchema(image hcloud.Image) schema.Image { Type: string(image.Type), ImageSize: &image.ImageSize, DiskSize: image.DiskSize, - Created: image.Created, + Created: &image.Created, OSFlavor: image.OSFlavor, OSVersion: hcloud.String(image.OSVersion), Architecture: string(image.Architecture), @@ -244,7 +244,7 @@ func ImageToSchema(image hcloud.Image) schema.Image { Protection: schema.ImageProtection{ Delete: image.Protection.Delete, }, - Deprecated: image.Deprecated, + Deprecated: &image.Deprecated, Labels: image.Labels, } if image.CreatedFrom != nil { @@ -265,7 +265,7 @@ func ISOToSchema(iso hcloud.ISO) schema.ISO { Name: iso.Name, Description: iso.Description, Type: string(iso.Type), - Deprecated: iso.Deprecated, + Deprecated: &iso.Deprecated, } if iso.Architecture != nil {