Skip to content

Commit c64d740

Browse files
authored
pkg/deployment: Remove package from ecctl (#285)
Removes the `pkg/deployment` and its subpackages in favor of having them in the SDK as available APIs for consumers to use. Additionally, swaps out all of the `multierror.Error` packages in favor of the `multierror.Prefixed` cloud-sdk-go type. Signed-off-by: Marc Lopez <marc5.12@outlook.com>
1 parent 7c145c9 commit c64d740

File tree

170 files changed

+549
-12484
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

170 files changed

+549
-12484
lines changed

cmd/auth/key/delete.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import (
2222
"sync"
2323
"time"
2424

25+
"github.com/elastic/cloud-sdk-go/pkg/multierror"
2526
"github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
26-
multierror "github.com/hashicorp/go-multierror"
2727
"github.com/spf13/cobra"
2828

2929
"github.com/elastic/ecctl/pkg/ecctl"
@@ -42,19 +42,19 @@ var deleteCmd = &cobra.Command{
4242
}
4343
}
4444

45-
var merr = new(multierror.Error)
45+
var merr = multierror.NewPrefixed("delete key")
4646
var wg sync.WaitGroup
4747
for i := range args {
4848
wg.Add(1)
49-
go func(index int, err *multierror.Error) {
50-
merr = multierror.Append(err,
49+
go func(index int) {
50+
merr = merr.Append(
5151
userauth.DeleteKey(userauth.DeleteKeyParams{
5252
API: ecctl.Get().API,
5353
ID: args[index],
5454
}),
5555
)
5656
wg.Done()
57-
}(i, merr)
57+
}(i)
5858

5959
// Only delete a key per second as anything below causes a 500
6060
<-time.After(time.Second)

cmd/deployment/create.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,14 @@ import (
2121
"fmt"
2222
"os"
2323

24+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
25+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2426
"github.com/elastic/cloud-sdk-go/pkg/models"
2527
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2628
"github.com/spf13/cobra"
2729

2830
cmdutil "github.com/elastic/ecctl/cmd/util"
29-
"github.com/elastic/ecctl/pkg/deployment"
30-
"github.com/elastic/ecctl/pkg/deployment/depresource"
3131
"github.com/elastic/ecctl/pkg/ecctl"
32-
"github.com/elastic/ecctl/pkg/util"
3332
)
3433

3534
var createCmd = &cobra.Command{
@@ -81,7 +80,7 @@ var createCmd = &cobra.Command{
8180

8281
if payload == nil {
8382
var err error
84-
payload, err = depresource.New(depresource.NewParams{
83+
payload, err = depresourceapi.New(depresourceapi.NewParams{
8584
API: ecctl.Get().API,
8685
Name: name,
8786
DeploymentTemplateID: dt,
@@ -92,22 +91,22 @@ var createCmd = &cobra.Command{
9291
TopologyElements: te,
9392
ApmEnable: apmEnable,
9493
AppsearchEnable: appsearchEnable,
95-
ElasticsearchInstance: depresource.InstanceParams{
94+
ElasticsearchInstance: depresourceapi.InstanceParams{
9695
RefID: esRefID,
9796
Size: esSize,
9897
ZoneCount: esZoneCount,
9998
},
100-
KibanaInstance: depresource.InstanceParams{
99+
KibanaInstance: depresourceapi.InstanceParams{
101100
RefID: kibanaRefID,
102101
Size: kibanaSize,
103102
ZoneCount: kibanaZoneCount,
104103
},
105-
ApmInstance: depresource.InstanceParams{
104+
ApmInstance: depresourceapi.InstanceParams{
106105
RefID: apmRefID,
107106
Size: apmSize,
108107
ZoneCount: apmZoneCount,
109108
},
110-
AppsearchInstance: depresource.InstanceParams{
109+
AppsearchInstance: depresourceapi.InstanceParams{
111110
RefID: appsearchRefID,
112111
Size: appsearchSize,
113112
ZoneCount: appsearchZoneCount,
@@ -124,17 +123,15 @@ var createCmd = &cobra.Command{
124123
}
125124

126125
reqID, _ := cmd.Flags().GetString("request-id")
127-
if reqID == "" {
128-
reqID = util.RandomString(64)
129-
}
126+
reqID = deploymentapi.RequestID(reqID)
130127

131-
var createParams = deployment.CreateParams{
128+
var createParams = deploymentapi.CreateParams{
132129
API: ecctl.Get().API,
133130
RequestID: reqID,
134131
Request: payload,
135132
}
136133

137-
res, err := deployment.Create(createParams)
134+
res, err := deploymentapi.Create(createParams)
138135
if err != nil {
139136
fmt.Fprintln(os.Stderr,
140137
"The deployment creation returned with an error. Use the displayed request ID to recreate the deployment resources",

cmd/deployment/delete.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
package cmddeployment
1919

2020
import (
21+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
2122
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2223
"github.com/spf13/cobra"
2324

2425
cmdutil "github.com/elastic/ecctl/cmd/util"
25-
"github.com/elastic/ecctl/pkg/deployment"
2626
"github.com/elastic/ecctl/pkg/ecctl"
2727
)
2828

@@ -31,7 +31,7 @@ var deleteCmd = &cobra.Command{
3131
Short: cmdutil.AdminReqDescription("Deletes a previously shutdown deployment"),
3232
PreRunE: sdkcmdutil.MinimumNArgsAndUUID(1),
3333
RunE: func(cmd *cobra.Command, args []string) error {
34-
res, err := deployment.Delete(deployment.DeleteParams{
34+
res, err := deploymentapi.Delete(deploymentapi.DeleteParams{
3535
API: ecctl.Get().API,
3636
DeploymentID: args[0],
3737
})

cmd/deployment/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
package cmddeployment
1919

2020
import (
21+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi"
2122
"github.com/spf13/cobra"
2223

23-
"github.com/elastic/ecctl/pkg/deployment"
2424
"github.com/elastic/ecctl/pkg/ecctl"
2525
)
2626

@@ -29,7 +29,7 @@ var listCmd = &cobra.Command{
2929
Short: "Lists the platform's deployments",
3030
PreRunE: cobra.NoArgs,
3131
RunE: func(cmd *cobra.Command, args []string) error {
32-
res, err := deployment.List(deployment.ListParams{
32+
res, err := deploymentapi.List(deploymentapi.ListParams{
3333
API: ecctl.Get().API,
3434
})
3535
if err != nil {

cmd/deployment/note/command.go

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ package cmddeploymentnote
2020
import (
2121
"path/filepath"
2222

23+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/noteapi"
2324
"github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2425
"github.com/spf13/cobra"
2526

26-
"github.com/elastic/ecctl/pkg/deployment"
27-
"github.com/elastic/ecctl/pkg/deployment/note"
2827
"github.com/elastic/ecctl/pkg/ecctl"
2928
"github.com/elastic/ecctl/pkg/util"
3029
)
@@ -44,12 +43,11 @@ var deploymentNoteCreateCmd = &cobra.Command{
4443
PreRunE: cmdutil.MinimumNArgsAndUUID(1),
4544
RunE: func(cmd *cobra.Command, args []string) error {
4645
comment, _ := cmd.Flags().GetString("comment")
47-
return note.Add(note.AddParams{
48-
Params: note.Params{
49-
Params: deployment.Params{
50-
API: ecctl.Get().API,
51-
ID: args[0],
52-
}},
46+
return noteapi.Add(noteapi.AddParams{
47+
Params: noteapi.Params{
48+
API: ecctl.Get().API,
49+
ID: args[0],
50+
},
5351
Message: comment,
5452
UserID: ecctl.Get().Config.User,
5553
})
@@ -61,11 +59,9 @@ var deploymentNoteListCmd = &cobra.Command{
6159
Short: "Lists the deployment notes",
6260
PreRunE: cmdutil.MinimumNArgsAndUUID(1),
6361
RunE: func(cmd *cobra.Command, args []string) error {
64-
res, err := note.List(note.Params{
65-
Params: deployment.Params{
66-
API: ecctl.Get().API,
67-
ID: args[0],
68-
},
62+
res, err := noteapi.List(noteapi.Params{
63+
API: ecctl.Get().API,
64+
ID: args[0],
6965
})
7066
if err != nil {
7167
return err
@@ -83,15 +79,13 @@ var deploymentNoteUpdateCmd = &cobra.Command{
8379
comment, _ := cmd.Flags().GetString("comment")
8480
noteID, _ := cmd.Flags().GetString("id")
8581
return util.ReturnErrOnly(
86-
note.Update(note.UpdateParams{
82+
noteapi.Update(noteapi.UpdateParams{
8783
Message: comment,
8884
UserID: ecctl.Get().Config.User,
8985
NoteID: noteID,
90-
Params: note.Params{
91-
Params: deployment.Params{
92-
API: ecctl.Get().API,
93-
ID: args[0],
94-
},
86+
Params: noteapi.Params{
87+
API: ecctl.Get().API,
88+
ID: args[0],
9589
},
9690
}),
9791
)
@@ -104,13 +98,11 @@ var deploymentNoteShowCmd = &cobra.Command{
10498
PreRunE: cmdutil.MinimumNArgsAndUUID(1),
10599
RunE: func(cmd *cobra.Command, args []string) error {
106100
noteID, _ := cmd.Flags().GetString("id")
107-
res, err := note.Get(note.GetParams{
101+
res, err := noteapi.Get(noteapi.GetParams{
108102
NoteID: noteID,
109-
Params: note.Params{
110-
Params: deployment.Params{
111-
API: ecctl.Get().API,
112-
ID: args[0],
113-
},
103+
Params: noteapi.Params{
104+
API: ecctl.Get().API,
105+
ID: args[0],
114106
},
115107
})
116108
if err != nil {

cmd/deployment/plan/cancel.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@
1818
package cmddeploymentplan
1919

2020
import (
21+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2122
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2223
"github.com/spf13/cobra"
2324

2425
cmdutil "github.com/elastic/ecctl/cmd/util"
25-
"github.com/elastic/ecctl/pkg/deployment"
26-
"github.com/elastic/ecctl/pkg/deployment/depresource"
2726
"github.com/elastic/ecctl/pkg/ecctl"
2827
)
2928

@@ -37,8 +36,8 @@ var cancelPlan = &cobra.Command{
3736
resKind, _ := cmd.Flags().GetString("kind")
3837
refID, _ := cmd.Flags().GetString("ref-id")
3938

40-
_, err := depresource.CancelPlan(depresource.CancelPlanParams{
41-
ResourceParams: deployment.ResourceParams{
39+
_, err := depresourceapi.CancelPlan(depresourceapi.CancelPlanParams{
40+
Params: depresourceapi.Params{
4241
API: ecctl.Get().API,
4342
DeploymentID: args[0],
4443
Kind: resKind,

cmd/deployment/resource/delete.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ package cmddeploymentresource
2020
import (
2121
"os"
2222

23+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2324
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2425
"github.com/spf13/cobra"
2526

2627
cmdutil "github.com/elastic/ecctl/cmd/util"
27-
"github.com/elastic/ecctl/pkg/deployment"
28-
"github.com/elastic/ecctl/pkg/deployment/depresource"
2928
"github.com/elastic/ecctl/pkg/ecctl"
3029
)
3130

@@ -44,8 +43,8 @@ var deleteCmd = &cobra.Command{
4443
return nil
4544
}
4645

47-
return depresource.DeleteStateless(depresource.DeleteStatelessParams{
48-
ResourceParams: deployment.ResourceParams{
46+
return depresourceapi.DeleteStateless(depresourceapi.DeleteStatelessParams{
47+
Params: depresourceapi.Params{
4948
API: ecctl.Get().API,
5049
DeploymentID: args[0],
5150
Kind: resKind,

cmd/deployment/resource/restore.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,11 @@ import (
2121
"fmt"
2222
"os"
2323

24+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2425
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2526
"github.com/spf13/cobra"
2627

2728
cmdutil "github.com/elastic/ecctl/cmd/util"
28-
"github.com/elastic/ecctl/pkg/deployment"
29-
"github.com/elastic/ecctl/pkg/deployment/depresource"
3029
"github.com/elastic/ecctl/pkg/ecctl"
3130
)
3231

@@ -54,8 +53,8 @@ var restoreCmd = &cobra.Command{
5453
)
5554
}
5655

57-
return depresource.Restore(depresource.RestoreParams{
58-
ResourceParams: deployment.ResourceParams{
56+
return depresourceapi.Restore(depresourceapi.RestoreParams{
57+
Params: depresourceapi.Params{
5958
API: ecctl.Get().API,
6059
DeploymentID: args[0],
6160
Kind: resKind,

cmd/deployment/resource/shutdown.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@ package cmddeploymentresource
2020
import (
2121
"os"
2222

23+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2324
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2425
"github.com/spf13/cobra"
2526

2627
cmdutil "github.com/elastic/ecctl/cmd/util"
27-
"github.com/elastic/ecctl/pkg/deployment"
28-
"github.com/elastic/ecctl/pkg/deployment/depresource"
2928
"github.com/elastic/ecctl/pkg/ecctl"
3029
)
3130

@@ -47,8 +46,8 @@ var shutdownCmd = &cobra.Command{
4746
return nil
4847
}
4948

50-
return depresource.Shutdown(depresource.ShutdownParams{
51-
ResourceParams: deployment.ResourceParams{
49+
return depresourceapi.Shutdown(depresourceapi.ShutdownParams{
50+
Params: depresourceapi.Params{
5251
API: ecctl.Get().API,
5352
DeploymentID: args[0],
5453
Kind: resKind,

cmd/deployment/resource/start-maintenance.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import (
2121
"fmt"
2222
"os"
2323

24+
"github.com/elastic/cloud-sdk-go/pkg/api/deploymentapi/depresourceapi"
2425
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
2526
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
2627
"github.com/spf13/cobra"
2728

2829
cmdutil "github.com/elastic/ecctl/cmd/util"
29-
"github.com/elastic/ecctl/pkg/deployment"
30-
"github.com/elastic/ecctl/pkg/deployment/depresource"
3130
"github.com/elastic/ecctl/pkg/ecctl"
3231
)
3332

@@ -52,9 +51,9 @@ var startMaintCmd = &cobra.Command{
5251
return nil
5352
}
5453

55-
_, err := depresource.StartMaintenanceModeAllOrSpecified(depresource.StartInstancesParams{
56-
StartParams: depresource.StartParams{
57-
ResourceParams: deployment.ResourceParams{
54+
_, err := depresourceapi.StartMaintenanceModeAllOrSpecified(depresourceapi.StartInstancesParams{
55+
StartParams: depresourceapi.StartParams{
56+
Params: depresourceapi.Params{
5857
API: ecctl.Get().API,
5958
DeploymentID: args[0],
6059
Kind: resKind,

0 commit comments

Comments
 (0)