Skip to content
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
3 changes: 0 additions & 3 deletions cmd/base/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ func CheckFormatterFlags(cmdContext *CmdContext, entities map[string]entities.En
if entity == nil {
return fmt.Errorf("can't find entity")
}
if err := entity.SetCmdDefaultFields(cmd.Name()); err != nil {
return err
}
if fieldList {
formatter.ListEntityFields(entity.GetFields())
os.Exit(0)
Expand Down
6 changes: 3 additions & 3 deletions cmd/entities/cloud-instances/ptr.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ func newAddPTRCmd(cmdContext *base.CmdContext) *cobra.Command {

base.SetupProxy(cmd, manager)

input := serverscom.PTRRecordCreateInput{
Domain: data,
IP: ip,
input := serverscom.CloudComputingInstancePTRRecordCreateInput{
Data: data,
IP: ip,
}
if cmd.Flags().Changed("ttl") {
input.TTL = &ttl
Expand Down
10 changes: 5 additions & 5 deletions cmd/entities/cloud-instances/ptr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ func TestAddPTRCmd(t *testing.T) {
output: "json",
expectedOutput: testutils.ReadFixture(filepath.Join(ptrFixtureBasePath, "get.json")),
configureMock: func(mock *mocks.MockCloudComputingInstancesService) {
in := serverscom.PTRRecordCreateInput{
Domain: testPTR.Domain,
in := serverscom.CloudComputingInstancePTRRecordCreateInput{
Data: testPTR.Domain,
IP: testPTR.IP,
TTL: &testPTR.TTL,
Priority: &testPTR.Priority,
Expand All @@ -177,9 +177,9 @@ func TestAddPTRCmd(t *testing.T) {
args: []string{testInstanceID, "--data", testPTR.Domain, "--ip", testPTR.IP},
expectError: true,
configureMock: func(mock *mocks.MockCloudComputingInstancesService) {
in := serverscom.PTRRecordCreateInput{
Domain: testPTR.Domain,
IP: testPTR.IP,
in := serverscom.CloudComputingInstancePTRRecordCreateInput{
Data: testPTR.Domain,
IP: testPTR.IP,
}
mock.EXPECT().
CreatePTRRecord(gomock.Any(), testInstanceID, in).
Expand Down
6 changes: 0 additions & 6 deletions cmd/entities/cloud-volumes/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import (
func newUpdateCmd(cmdContext *base.CmdContext) *cobra.Command {
var name string
var description string
var imageID string
var snapshotID string
var labels []string

cmd := &cobra.Command{
Expand All @@ -35,8 +33,6 @@ func newUpdateCmd(cmdContext *base.CmdContext) *cobra.Command {
input := serverscom.CloudBlockStorageVolumeUpdateInput{
Name: name,
Description: description,
ImageID: imageID,
SnapshotID: snapshotID,
Labels: labelsMap,
}

Expand All @@ -58,8 +54,6 @@ func newUpdateCmd(cmdContext *base.CmdContext) *cobra.Command {

cmd.Flags().StringVarP(&name, "name", "n", "", "A name of the cloud volume")
cmd.Flags().StringVar(&description, "description", "", "Description of the volume")
cmd.Flags().StringVar(&imageID, "image-id", "", "ID of the image")
cmd.Flags().StringVar(&snapshotID, "snapshot-id", "", "ID of the snapshot")
cmd.Flags().StringArrayVarP(&labels, "label", "l", []string{}, "string in key=value format")

return cmd
Expand Down
5 changes: 5 additions & 0 deletions cmd/entities/l2_segments/l2_segments.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ func NewCmd(cmdContext *base.CmdContext) *cobra.Command {
if err != nil {
log.Fatal(err)
}
l2NetworkEntity, err := entities.Registry.GetEntityFromValue(serverscom.L2SegmentNetwork{})
if err != nil {
log.Fatal(err)
}
entitiesMap := make(map[string]entities.EntityInterface)
entitiesMap["l2-segments"] = l2Entity
entitiesMap["list-networks"] = l2NetworkEntity
cmd := &cobra.Command{
Use: "l2-segments",
Short: "Manage L2 segments",
Expand Down
24 changes: 12 additions & 12 deletions cmd/entities/l2_segments/l2_segments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (

cidr = "127.1.182.0/24"
title = "testNetwork"
testNetwork = serverscom.Network{
testNetwork = serverscom.L2SegmentNetwork{
ID: testID,
Title: &title,
Status: "new",
Expand Down Expand Up @@ -882,55 +882,55 @@ func TestListL2NetworksCmd(t *testing.T) {
args []string
expectedOutput []byte
expectError bool
configureMock func(*mocks.MockCollection[serverscom.Network])
configureMock func(*mocks.MockCollection[serverscom.L2SegmentNetwork])
}{
{
name: "list all l2 networks",
output: "json",
args: []string{testID, "-A"},
expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_networks_all.json")),
configureMock: func(mock *mocks.MockCollection[serverscom.Network]) {
configureMock: func(mock *mocks.MockCollection[serverscom.L2SegmentNetwork]) {
mock.EXPECT().
Collect(gomock.Any()).
Return([]serverscom.Network{n1, n2}, nil)
Return([]serverscom.L2SegmentNetwork{n1, n2}, nil)
},
},
{
name: "list l2 networks",
output: "json",
args: []string{testID},
expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_networks.json")),
configureMock: func(mock *mocks.MockCollection[serverscom.Network]) {
configureMock: func(mock *mocks.MockCollection[serverscom.L2SegmentNetwork]) {
mock.EXPECT().
List(gomock.Any()).
Return([]serverscom.Network{n1}, nil)
Return([]serverscom.L2SegmentNetwork{n1}, nil)
},
},
{
name: "list l2 networks with template",
args: []string{testID, "--template", "{{range .}}ID: {{.ID}} Title: {{.Title}}\n{{end}}"},
expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_networks_template.txt")),
configureMock: func(mock *mocks.MockCollection[serverscom.Network]) {
configureMock: func(mock *mocks.MockCollection[serverscom.L2SegmentNetwork]) {
mock.EXPECT().
List(gomock.Any()).
Return([]serverscom.Network{n1, n2}, nil)
Return([]serverscom.L2SegmentNetwork{n1, n2}, nil)
},
},
{
name: "list l2 networks with pageView",
args: []string{testID, "--page-view"},
expectedOutput: testutils.ReadFixture(filepath.Join(fixtureBasePath, "list_networks_pageview.txt")),
configureMock: func(mock *mocks.MockCollection[serverscom.Network]) {
configureMock: func(mock *mocks.MockCollection[serverscom.L2SegmentNetwork]) {
mock.EXPECT().
List(gomock.Any()).
Return([]serverscom.Network{n1, n2}, nil)
Return([]serverscom.L2SegmentNetwork{n1, n2}, nil)
},
},
{
name: "list l2 networks error",
args: []string{testID},
expectError: true,
configureMock: func(mock *mocks.MockCollection[serverscom.Network]) {
configureMock: func(mock *mocks.MockCollection[serverscom.L2SegmentNetwork]) {
mock.EXPECT().
List(gomock.Any()).
Return(nil, errors.New("some error"))
Expand All @@ -941,7 +941,7 @@ func TestListL2NetworksCmd(t *testing.T) {
mockCtrl := gomock.NewController(t)
defer mockCtrl.Finish()

collectionHandler := mocks.NewMockCollection[serverscom.Network](mockCtrl)
collectionHandler := mocks.NewMockCollection[serverscom.L2SegmentNetwork](mockCtrl)
l2ServiceHandler := mocks.NewMockL2SegmentsService(mockCtrl)
l2ServiceHandler.EXPECT().
Networks(testID).
Expand Down
6 changes: 3 additions & 3 deletions cmd/entities/l2_segments/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ func newListMembersCmd(cmdContext *base.CmdContext) *cobra.Command {

func newListNetworksCmd(cmdContext *base.CmdContext) *cobra.Command {

factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.Network] {
factory := func(verbose bool, args ...string) serverscom.Collection[serverscom.L2SegmentNetwork] {
scClient := cmdContext.GetClient().SetVerbose(verbose).GetScClient()
return scClient.L2Segments.Networks(args[0])
}

opts := base.NewListOptions(
&base.BaseListOptions[serverscom.Network]{},
&base.L2SegmentGroupTypeOption[serverscom.Network]{},
&base.BaseListOptions[serverscom.L2SegmentNetwork]{},
&base.L2SegmentGroupTypeOption[serverscom.L2SegmentNetwork]{},
)

cmd := base.NewListCmd("list-networks", "l2 segment networks", factory, cmdContext, opts...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ var (
Name: "test-lb-cluster",
LocationID: 1,
LocationCode: testLocationCode,
Status: "active",
Created: fixedTime,
Updated: fixedTime,
}
Expand Down
2 changes: 1 addition & 1 deletion docs/srvctl-lb-l4-add/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JSON structure example:
"location_id": "",
"cluster_id": "",
"store_logs": true,
"store_logs_region_id": "",
"store_logs_region_id": 0,
"vhost_zones": [
{
"id": "",
Expand Down
2 changes: 1 addition & 1 deletion docs/srvctl-lb-l4-update/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JSON structure example:
"shared_cluster": "",
"name": "",
"store_logs": true,
"store_logs_region_id": "",
"store_logs_region_id": 0,
"new_external_ips_count": "",
"delete_external_ips": [],
"vhost_zones": [
Expand Down
2 changes: 1 addition & 1 deletion docs/srvctl-lb-l7-add/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JSON structure example:
"location_id": "",
"cluster_id": "",
"store_logs": true,
"store_logs_region_id": "",
"store_logs_region_id": 0,
"geoip": "true",
"vhost_zones": [
{
Expand Down
2 changes: 1 addition & 1 deletion docs/srvctl-lb-l7-update/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ JSON structure example:
"cluster_id": "",
"shared_cluster": "",
"store_logs": true,
"store_logs_region_id": "",
"store_logs_region_id": 0,
"geoip": "true",
"new_external_ips_count": "",
"delete_external_ips": [],
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require (
github.com/creack/pty v1.1.24
github.com/jmespath/go-jmespath v0.4.0
github.com/onsi/gomega v1.42.1
github.com/serverscom/serverscom-go-client v1.0.33
github.com/serverscom/serverscom-go-client v1.1.2
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/spf13/viper v1.21.0
Expand All @@ -33,5 +33,5 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.57.0 // indirect
golang.org/x/sys v0.47.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
)
11 changes: 7 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9Y
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/onsi/gomega v1.42.1 h1:iN1rCUX+44NZ1Dc97MPoeFYbFR0vh8zxoxMFwKdyZ6I=
Expand All @@ -38,8 +41,8 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagikazarmark/locafero v0.12.0 h1:/NQhBAkUb4+fH1jivKHWusDYFjMOOKU88eegjfxfHb4=
github.com/sagikazarmark/locafero v0.12.0/go.mod h1:sZh36u/YSZ918v0Io+U9ogLYQJ9tLLBmM4eneO6WwsI=
github.com/serverscom/serverscom-go-client v1.0.33 h1:JdpzoJnOjUEappDxxGSzhHC4At7RaZItrg7o7wVQZpg=
github.com/serverscom/serverscom-go-client v1.0.33/go.mod h1:/Nf+XygKOxm19Sl2gvMzT55O4X+tWDkj/UM4mjzfKgM=
github.com/serverscom/serverscom-go-client v1.1.2 h1:ddSKFrHRu38zdkk8OXg9Ugr5oTQX1ESfanTls8vb7vI=
github.com/serverscom/serverscom-go-client v1.1.2/go.mod h1:RVmx6+Dop/gvs7FETe6TrzdSEzQZGOzImyUTgUwsBoU=
github.com/spf13/afero v1.15.0 h1:b/YBCLWAJdFWJTN9cLhiXXcD7mzKn9Dm86dNnfyQw1I=
github.com/spf13/afero v1.15.0/go.mod h1:NC2ByUVxtQs4b3sIUphxK0NioZnmxgyCrfzeuq8lxMg=
github.com/spf13/cast v1.10.0 h1:h2x0u2shc1QuLHfxi+cTJvs30+ZAHOGRic8uyGTDWxY=
Expand Down Expand Up @@ -78,8 +81,8 @@ golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
golang.org/x/time v0.12.0/go.mod h1:CDIdPxbZBQxdj6cxyCIdrNogrJKMJ7pr37NYpMcMDSg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
2 changes: 1 addition & 1 deletion internal/mocks/cloud_instances_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading