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
6 changes: 3 additions & 3 deletions cmd/deployment/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ Deployment [%s] - [Apm][%s]: running step "waiting-for-some-step" (Plan duration
Err: multierror.NewPrefixed("failed reading the file definition",
errors.New("invalid argument"),
errors.New("could not read the specified file, please make sure it exists"),
),
).Error(),
},
},
{
Expand Down Expand Up @@ -482,7 +482,7 @@ Deployment [%s] - [Apm][%s]: running step "waiting-for-some-step" (Plan duration
},
},
want: testutils.Assertion{
Err: errors.New("elasticsearch node topology: memory size cannot be empty"),
Err: "elasticsearch node topology: memory size cannot be empty",
},
},
{
Expand Down Expand Up @@ -658,7 +658,7 @@ Deployment [%s] - [Apm][%s]: running step "waiting-for-some-step" (Plan duration
},
},
want: testutils.Assertion{
Err: errors.New(`{"error": "some"}`),
Err: `{"error": "some"}`,
Stderr: "The deployment creation returned with an error. Use the displayed request ID to recreate the deployment resources" +
"\n" + "Request ID: some_request_id" + "\n",
},
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/elasticsearch/keystore/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmdeskeystore

import (
"encoding/json"
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -73,7 +72,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("requires at least 1 arg(s), only received 0"),
Err: "requires at least 1 arg(s), only received 0",
},
},
{
Expand All @@ -88,7 +87,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
7 changes: 3 additions & 4 deletions cmd/deployment/elasticsearch/keystore/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmdeskeystore

import (
"encoding/json"
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -72,7 +71,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("requires at least 1 arg(s), only received 0"),
Err: "requires at least 1 arg(s), only received 0",
},
},
{
Expand All @@ -87,7 +86,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("failed reading keystore secret definition: provide a valid keystore secret definition using the --file flag"),
Err: "failed reading keystore secret definition: provide a valid keystore secret definition using the --file flag",
},
},
{
Expand All @@ -103,7 +102,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
3 changes: 1 addition & 2 deletions cmd/deployment/note/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import (
"github.com/spf13/cobra"

"github.com/elastic/ecctl/pkg/ecctl"
"github.com/elastic/ecctl/pkg/util"
)

// Command represents the deployment note subcommand.
Expand Down Expand Up @@ -97,7 +96,7 @@ var deploymentNoteUpdateCmd = &cobra.Command{
return err
}

return util.ReturnErrOnly(
return api.ReturnErrOnly(
noteapi.Update(noteapi.UpdateParams{
Message: comment,
UserID: ecctl.Get().Config.User,
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmddeployment

import (
"encoding/json"
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -129,7 +128,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("requires at least 1 arg(s), only received 0"),
Err: "requires at least 1 arg(s), only received 0",
},
},
{
Expand All @@ -144,7 +143,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/template/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package cmddeploymenttemplate

import (
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -64,7 +63,7 @@ func Test_createCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("failed reading deployment template definition: provide a valid deployment template definition using the --file flag"),
Err: "failed reading deployment template definition: provide a valid deployment template definition using the --file flag",
},
},
{
Expand All @@ -79,7 +78,7 @@ func Test_createCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/template/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package cmddeploymenttemplate

import (
"errors"
"net/url"
"testing"

Expand Down Expand Up @@ -55,7 +54,7 @@ func Test_deleteCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New(`required flag(s) "template-id" not set`),
Err: `required flag(s) "template-id" not set`,
},
},
{
Expand All @@ -70,7 +69,7 @@ func Test_deleteCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
2 changes: 1 addition & 1 deletion cmd/deployment/template/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_listCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/template/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cmddeploymenttemplate

import (
"encoding/json"
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -75,7 +74,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New(`required flag(s) "template-id" not set`),
Err: `required flag(s) "template-id" not set`,
},
},
{
Expand All @@ -90,7 +89,7 @@ func Test_showCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
5 changes: 2 additions & 3 deletions cmd/deployment/template/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package cmddeploymenttemplate

import (
"errors"
"io/ioutil"
"net/url"
"testing"
Expand Down Expand Up @@ -64,7 +63,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: errors.New("failed reading deployment template definition: provide a valid deployment template definition using the --file flag"),
Err: "failed reading deployment template definition: provide a valid deployment template definition using the --file flag",
},
},
{
Expand All @@ -79,7 +78,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand Down
9 changes: 4 additions & 5 deletions cmd/platform/role/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package cmdrole

import (
"errors"
"io/ioutil"
"testing"

Expand Down Expand Up @@ -47,7 +46,7 @@ func Test_updateCmd(t *testing.T) {
},
},
want: testutils.Assertion{
Err: errors.New("accepts 1 arg(s), received 0"),
Err: "accepts 1 arg(s), received 0",
},
},
{
Expand All @@ -62,7 +61,7 @@ func Test_updateCmd(t *testing.T) {
}},
},
want: testutils.Assertion{
Err: mock.MultierrorInternalError,
Err: mock.MultierrorInternalError.Error(),
},
},
{
Expand All @@ -74,7 +73,7 @@ func Test_updateCmd(t *testing.T) {
},
},
want: testutils.Assertion{
Err: errors.New(`required flag(s) "file" not set`),
Err: `required flag(s) "file" not set`,
},
},
{
Expand All @@ -86,7 +85,7 @@ func Test_updateCmd(t *testing.T) {
},
},
want: testutils.Assertion{
Err: errors.New("role id [my-role] cannot be found in the role file"),
Err: "role id [my-role] cannot be found in the role file",
},
},
{
Expand Down
3 changes: 1 addition & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (

cmdutil "github.com/elastic/ecctl/cmd/util"
"github.com/elastic/ecctl/pkg/ecctl"
"github.com/elastic/ecctl/pkg/util"
)

const (
Expand Down Expand Up @@ -198,7 +197,7 @@ func initApp(cmd *cobra.Command, client *http.Client, v *viper.Viper) error {
c.Region = cmdutil.DefaultECERegion
}

err := util.ReturnErrOnly(ecctl.Instance(c))
err := api.ReturnErrOnly(ecctl.Instance(c))
// When no config file has been read and initApp returns an error, tell
// the user how to initialize the application.
if err != nil && v.ConfigFileUsed() == "" {
Expand Down
4 changes: 2 additions & 2 deletions cmd/util/testutils/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type Args struct {

// Assertion to use for tests.
type Assertion struct {
Err error
Err string
Stdout string
Stderr string
}
Expand Down Expand Up @@ -74,7 +74,7 @@ func RunCmdAssertion(t *testing.T, args Args, assertion Assertion) {
}

func assertCmd(t *testing.T, args Args, want Assertion, execErr error, track bool) {
if !assert.Equal(t, want.Err, execErr) {
if execErr != nil && !assert.EqualError(t, execErr, want.Err) {
t.Error(execErr)
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.13

require (
github.com/asaskevich/govalidator v0.0.0-20200907205600-7a23bdc65eef
github.com/elastic/cloud-sdk-go v1.1.1-0.20201201215440-1aa8a65e9add
github.com/elastic/cloud-sdk-go v1.1.1-0.20201207014834-7444fc44d078
github.com/go-openapi/runtime v0.19.24
github.com/go-openapi/strfmt v0.19.11
github.com/pkg/errors v0.9.1
Expand Down
Loading