Skip to content

Commit a48a843

Browse files
authored
api: Remove code that is related to clusters API (#258)
Removes code related to Clusters APIs which won't be available in ESS.
1 parent 4cc6cce commit a48a843

File tree

8 files changed

+0
-487
lines changed

8 files changed

+0
-487
lines changed

cmd/util/flag.go

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424

2525
"github.com/spf13/cobra"
2626

27-
"github.com/elastic/ecctl/pkg/deployment/elasticsearch/instances"
2827
"github.com/elastic/ecctl/pkg/util"
2928
)
3029

@@ -58,16 +57,6 @@ var (
5857
AllKindsCompFunc = fmt.Sprintf(compFuncTpl, "all", strings.Join(AllKinds, " "))
5958
)
6059

61-
// GetInstances tries to obtain a slice with the elasticsearch cluster
62-
// instance names either from the current cluster topology or from the
63-
// specified --instance flag in the cobra.Command.
64-
func GetInstances(cmd *cobra.Command, params util.ClusterParams, flagName string) ([]string, error) {
65-
if all, _ := cmd.Flags().GetBool("all"); all {
66-
return instances.List(params)
67-
}
68-
return cmd.Flags().GetStringSlice(flagName)
69-
}
70-
7160
// AddKindFlag adds a kind string flag to the specified command, with the
7261
// resource kinds autocompletion function. It is intended to be used for any
7362
// commands which call the deployment/resource APIs.

cmd/util/flag_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -19,88 +19,17 @@ package cmdutil
1919

2020
import (
2121
"errors"
22-
"net/http"
2322
"reflect"
2423
"strconv"
2524
"testing"
2625
"time"
2726

28-
"github.com/elastic/cloud-sdk-go/pkg/api"
29-
"github.com/elastic/cloud-sdk-go/pkg/api/mock"
30-
"github.com/elastic/cloud-sdk-go/pkg/models"
31-
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
3227
"github.com/spf13/cobra"
3328
flag "github.com/spf13/pflag"
3429

3530
"github.com/elastic/ecctl/pkg/util"
3631
)
3732

38-
func TestGetInstances(t *testing.T) {
39-
cmdWithSliceFlag := &cobra.Command{
40-
Use: "something",
41-
Run: func(cmd *cobra.Command, args []string) {},
42-
}
43-
cmdWithSliceFlag.Flags().StringSlice("instance", []string{"1", "2", "3"}, "instance")
44-
cmdWithSliceFlag.Flags().Bool("all", false, "all")
45-
cmdWithAllFlag := &cobra.Command{
46-
Use: "something",
47-
Run: func(cmd *cobra.Command, args []string) {},
48-
}
49-
cmdWithAllFlag.Flags().Bool("all", true, "all")
50-
type args struct {
51-
cmd *cobra.Command
52-
params util.ClusterParams
53-
flagName string
54-
}
55-
tests := []struct {
56-
name string
57-
args args
58-
want []string
59-
err error
60-
}{
61-
{
62-
name: "obtains the instances explicitly set",
63-
args: args{
64-
cmd: cmdWithSliceFlag,
65-
flagName: "instance",
66-
},
67-
want: []string{"1", "2", "3"},
68-
},
69-
{
70-
name: "obtains the instances from the cluster topology",
71-
args: args{
72-
cmd: cmdWithAllFlag,
73-
params: util.ClusterParams{
74-
ClusterID: util.ValidClusterID,
75-
API: api.NewMock(mock.Response{Response: http.Response{
76-
StatusCode: 200,
77-
Body: mock.NewStructBody(models.ElasticsearchClusterInfo{
78-
Topology: &models.ClusterTopologyInfo{
79-
Instances: []*models.ClusterInstanceInfo{
80-
{InstanceName: ec.String("instance-000000")},
81-
},
82-
},
83-
}),
84-
}}),
85-
},
86-
},
87-
want: []string{"instance-000000"},
88-
},
89-
}
90-
for _, tt := range tests {
91-
t.Run(tt.name, func(t *testing.T) {
92-
got, err := GetInstances(tt.args.cmd, tt.args.params, tt.args.flagName)
93-
if !reflect.DeepEqual(err, tt.err) {
94-
t.Errorf("GetInstances() error = %v, wantErr %v", err, tt.err)
95-
return
96-
}
97-
if !reflect.DeepEqual(got, tt.want) {
98-
t.Errorf("GetInstances() = %v, want %v", got, tt.want)
99-
}
100-
})
101-
}
102-
}
103-
10433
func TestAddKindFlag(t *testing.T) {
10534
var wantSomethingAssert = &flag.Flag{
10635
Name: "kind",

pkg/deployment/elasticsearch/get.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

pkg/deployment/elasticsearch/get_test.go

Lines changed: 0 additions & 88 deletions
This file was deleted.

pkg/deployment/elasticsearch/instances/reducer.go

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)