diff --git a/cmd/deployment/elasticsearch/start.go b/cmd/deployment/elasticsearch/start.go index 9bdb52eb..ea7515c0 100644 --- a/cmd/deployment/elasticsearch/start.go +++ b/cmd/deployment/elasticsearch/start.go @@ -45,7 +45,7 @@ var startElasticsearchCmd = &cobra.Command{ return err } - if c.Status == "started" { + if *c.Status == "started" { return fmt.Errorf("cluster [%s][Elasticsearch]: is already started", args[0]) } diff --git a/cmd/deployment/kibana/show_test.go b/cmd/deployment/kibana/show_test.go index f52d8db3..85703172 100644 --- a/cmd/deployment/kibana/show_test.go +++ b/cmd/deployment/kibana/show_test.go @@ -58,7 +58,7 @@ func TestRunShowKibanaClusterCmd(t *testing.T) { cmd: showKibanaClusterCmd, args: []string{"d558cdf210dc4737960906a83b1db52c"}, }, - err: "Get http://localhost/api/v1/clusters/kibana/d558cdf210dc4737960906a83b1db52c?convert_legacy_plans=false&show_metadata=false&show_plan_defaults=true&show_plan_logs=false&show_plans=false&show_settings=false", + err: `Get http://somehost/api/v1/clusters/kibana/d558cdf210dc4737960906a83b1db52c?convert_legacy_plans=false&show_metadata=false&show_plan_defaults=true&show_plan_logs=false&show_plans=false&show_settings=false`, }, } diff --git a/cmd/deployment/kibana/start.go b/cmd/deployment/kibana/start.go index e1331489..7d27a617 100644 --- a/cmd/deployment/kibana/start.go +++ b/cmd/deployment/kibana/start.go @@ -51,7 +51,7 @@ var startKibanaCmd = &cobra.Command{ return err } - if c.Status == "started" { + if *c.Status == "started" { return fmt.Errorf("cluster [%s][Kibana]: is already started", args[0]) } diff --git a/cmd/util/testutils/testutils.go b/cmd/util/testutils/testutils.go index 8e8005e0..6cc6f0fa 100644 --- a/cmd/util/testutils/testutils.go +++ b/cmd/util/testutils/testutils.go @@ -34,7 +34,7 @@ func MockInitApp() error { OutputDevice: output.NewDevice(os.Stdout), ErrorDevice: os.Stderr, Output: "json", - Host: "http://localhost", + Host: "http://somehost", APIKey: "helloiamakey", } diff --git a/go.mod b/go.mod index 373920d3..ad894e0a 100644 --- a/go.mod +++ b/go.mod @@ -8,12 +8,12 @@ require ( github.com/chzyer/logex v1.1.10 // indirect github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1 // indirect github.com/davecgh/go-spew v1.1.1 - github.com/elastic/cloud-sdk-go v1.0.0-beta1.0.20200305114619-8877c73631de + github.com/elastic/cloud-sdk-go v1.0.0-beta2 github.com/ghodss/yaml v1.0.0 github.com/go-openapi/runtime v0.19.12 github.com/go-openapi/strfmt v0.19.5 github.com/hashicorp/go-multierror v1.0.0 - github.com/marclop/elasticsearch-cli v0.0.0-20190212132418-ee09f7ae57f1 + github.com/marclop/elasticsearch-cli v0.0.0-20190212133917-c1d1bf9d46e4 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 github.com/spf13/cobra v0.0.6 diff --git a/go.sum b/go.sum index bc422680..aa8caa55 100644 --- a/go.sum +++ b/go.sum @@ -1,4 +1,5 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= @@ -7,6 +8,7 @@ github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tN github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/Songmu/retry v0.1.0/go.mod h1:7sXIW7eseB9fq0FUvigRcQMVLR9tuHI0Scok+rkpAuA= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= @@ -48,8 +50,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/docker/go-units v0.4.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= -github.com/elastic/cloud-sdk-go v1.0.0-beta1.0.20200305114619-8877c73631de h1:jrm7EH6xEa91qcSM8enWKIu3XJvUofjS9pVhm8s16WQ= -github.com/elastic/cloud-sdk-go v1.0.0-beta1.0.20200305114619-8877c73631de/go.mod h1:38n6D67eYnItpkxserWdK6lBJ+mJH946q1dkTkvdiCs= +github.com/elastic/cloud-sdk-go v1.0.0-beta2 h1:INSj4Z3Xdm3Jn8Vl8/CtSe+ImBT2PZ6HHp0oAM6ZfRw= +github.com/elastic/cloud-sdk-go v1.0.0-beta2/go.mod h1:kAQwliTmnTjeHdIt5nk8Y24IfegfVhlDEy8oWlIod3A= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= github.com/fsnotify/fsnotify v0.0.0-20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -75,8 +77,8 @@ github.com/go-openapi/errors v0.18.0 h1:+RnmJ5MQccF7jwWAoMzwOpzJEspZ18ZIWfg9Z2ei github.com/go-openapi/errors v0.18.0/go.mod h1:LcZQpmvG4wyF5j4IhA73wkLFQg+QJXOQHVjmcZxhka0= github.com/go-openapi/errors v0.19.2 h1:a2kIyV3w+OS3S97zxUndRVD46+FhGOUBDFY7nmu4CsY= github.com/go-openapi/errors v0.19.2/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= -github.com/go-openapi/errors v0.19.3 h1:7MGZI1ibQDLasvAz8HuhvYk9eNJbJkCOXWsSjjMS+Zc= -github.com/go-openapi/errors v0.19.3/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= +github.com/go-openapi/errors v0.19.4 h1:fSGwO1tSYHFu70NKaWJt5Qh0qoBRtCm/mXS1yhf+0W0= +github.com/go-openapi/errors v0.19.4/go.mod h1:qX0BLWsyaKfvhluLejVpVNwNRdXZhEbTA4kxxpKBC94= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.18.0 h1:KVRzjXpMzgdM4GEMDmDTnGcY5yBwGWreJwmmk4k35yU= github.com/go-openapi/jsonpointer v0.18.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= @@ -103,8 +105,6 @@ github.com/go-openapi/runtime v0.0.0-20180920151709-4f900dc2ade9/go.mod h1:6v9a6 github.com/go-openapi/runtime v0.19.0 h1:sU6pp4dSV2sGlNKKyHxZzi1m1kG4WnYtWcJ+HYbygjE= github.com/go-openapi/runtime v0.19.0/go.mod h1:OwNfisksmmaZse4+gpV3Ne9AyMOlP1lt4sK4FXt0O64= github.com/go-openapi/runtime v0.19.4/go.mod h1:X277bwSUBxVlCYR3r7xgZZGKVvBd/29gLDlFGtJ8NL4= -github.com/go-openapi/runtime v0.19.11 h1:6J11dQiIV+BOLlMbk2YmM8RvGaOU38syeqy62qhh3W8= -github.com/go-openapi/runtime v0.19.11/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= github.com/go-openapi/runtime v0.19.12 h1:5lQlCr1HL0ZVRPL+0PHKhRpMCSPMV2qF842rhQx8CYY= github.com/go-openapi/runtime v0.19.12/go.mod h1:dhGWCTKRXlAfGnQG0ONViOZpjfg0m2gUt9nTQPQZuoo= github.com/go-openapi/spec v0.17.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= @@ -113,8 +113,8 @@ github.com/go-openapi/spec v0.18.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsd github.com/go-openapi/spec v0.19.2/go.mod h1:sCxk3jxKgioEJikev4fgkNmwS+3kuYdJtcsZsD5zxMY= github.com/go-openapi/spec v0.19.3 h1:0XRyw8kguri6Yw4SxhsQA/atC88yqrk0+G4YhI2wabc= github.com/go-openapi/spec v0.19.3/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= -github.com/go-openapi/spec v0.19.6 h1:rMMMj8cV38KVXK7SFc+I2MWClbEfbK705+j+dyqun5g= -github.com/go-openapi/spec v0.19.6/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/spec v0.19.7 h1:0xWSeMd35y5avQAThZR2PkEuqSosoS5t6gDH4L8n11M= +github.com/go-openapi/spec v0.19.7/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= github.com/go-openapi/strfmt v0.17.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.18.0/go.mod h1:P82hnJI0CXkErkXi8IKjPbNBM6lV6+5pLP5l494TcyU= github.com/go-openapi/strfmt v0.19.0 h1:0Dn9qy1G9+UJfRU7TR8bmdGxb4uifB7HNrJjOnV0yPk= @@ -122,8 +122,6 @@ github.com/go-openapi/strfmt v0.19.0/go.mod h1:+uW+93UVvGGq2qGaZxdDeJqSAqBqBdl+Z github.com/go-openapi/strfmt v0.19.2/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= github.com/go-openapi/strfmt v0.19.3 h1:eRfyY5SkaNJCAwmmMcADjY31ow9+N7MCLW7oRkbsINA= github.com/go-openapi/strfmt v0.19.3/go.mod h1:0yX7dbo8mKIvc3XSKp7MNfxw4JytCfCD6+bY1AVL9LU= -github.com/go-openapi/strfmt v0.19.4 h1:eRvaqAhpL0IL6Trh5fDsGnGhiXndzHFuA05w6sXH6/g= -github.com/go-openapi/strfmt v0.19.4/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/strfmt v0.19.5 h1:0utjKrw+BAh8s57XE9Xz8DUBsVvPmRUB6styvl9wWIM= github.com/go-openapi/strfmt v0.19.5/go.mod h1:eftuHTlB/dI8Uq8JJOyRlieZf+WkkxUuk0dgdHXr2Qk= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= @@ -132,15 +130,15 @@ github.com/go-openapi/swag v0.18.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/ github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.7 h1:VRuXN2EnMSsZdauzdss6JBC29YotDqG59BZ+tdlIL1s= -github.com/go-openapi/swag v0.19.7/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= +github.com/go-openapi/swag v0.19.8 h1:vfK6jLhs7OI4tAXkvkooviaE1JEPcw3mutyegLHHjmk= +github.com/go-openapi/swag v0.19.8/go.mod h1:ao+8BpOPyKdpQz3AOJfbeEVpLmWAvlT1IfTe5McPyhY= github.com/go-openapi/validate v0.18.0 h1:PVXYcP1GkTl+XIAJnyJxOmK6CSG5Q1UcvoCvNO++5Kg= github.com/go-openapi/validate v0.18.0/go.mod h1:Uh4HdOzKt19xGIGm1qHf/ofbX1YQ4Y+MYsct2VUrAJ4= github.com/go-openapi/validate v0.19.2/go.mod h1:1tRCw7m3jtI8eNWEEliiAqUIcBztB2KDnRCRMUi7GTA= github.com/go-openapi/validate v0.19.3 h1:PAH/2DylwWcIU1s0Y7k3yNmeAgWOcKrNE2Q7Ww/kCg4= github.com/go-openapi/validate v0.19.3/go.mod h1:90Vh6jjkTn+OT1Eefm0ZixWNFjhtOH7vS9k0lo6zwJo= -github.com/go-openapi/validate v0.19.6 h1:WsKw9J1WzYBVxWRYwLqEk3325RL6G0SSWksuamkk6q0= -github.com/go-openapi/validate v0.19.6/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= +github.com/go-openapi/validate v0.19.7 h1:fR4tP2xc+25pdo5Qvv4v6g+5QKFgNg8nrifTE7V8ibA= +github.com/go-openapi/validate v0.19.7/go.mod h1:8DJv2CVJQ6kGNpFW6eV9N3JviE1C85nY1c2z52x1Gk4= github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= @@ -157,6 +155,8 @@ github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.3.0 h1:crn/baboCvb5fXaQ0IJ1SGTsTVrWpDsCWC8EGETZijY= github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= +github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -170,6 +170,7 @@ github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/U github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/hcl v0.0.0-20170914154624-68e816d1c783/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= @@ -202,12 +203,15 @@ github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.7.0 h1:aizVhC/NAAcKWb+5QsU1iNOZb4Yws5UO2I+aIprQITM= github.com/mailru/easyjson v0.7.0/go.mod h1:KAzv3t3aY1NaHWoQz1+4F1ccyAH66Jk7yos7ldAVICs= -github.com/marclop/elasticsearch-cli v0.0.0-20190212132418-ee09f7ae57f1 h1:AjKJSp3BJvuT8IZI0qmK4UtST/Gl+W+ohf7QO87Xfd4= -github.com/marclop/elasticsearch-cli v0.0.0-20190212132418-ee09f7ae57f1/go.mod h1:5IsNi9k3pZY5PtppCpl0QRBsmmtUOb4vJMoky6DXjy8= +github.com/marclop/elasticsearch-cli v0.0.0-20190212133917-c1d1bf9d46e4 h1:63z9zzAu1Th+mIGXe4B8AuhdFwB/58ph7aQ19FQ+kx8= +github.com/marclop/elasticsearch-cli v0.0.0-20190212133917-c1d1bf9d46e4/go.mod h1:MN0JBU7YvNYdaNrgjDnMYFeYFHb1ZZOuRPL5gRCzKag= +github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= @@ -221,6 +225,7 @@ github.com/pelletier/go-toml v0.0.0-20170904195809-1d6b12b7cb29/go.mod h1:5z9KED github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -280,6 +285,9 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tcnksm/ghr v0.12.0/go.mod h1:2YSVCxP2GsVRnE6R3bZxEiVnpJ9GUkotqlq2No0kTMU= +github.com/tcnksm/go-gitconfig v0.1.2/go.mod h1:/8EhP4H7oJZdIPyT+/UIsG87kTzrzM4UsLGSItWYCpE= +github.com/tcnksm/go-latest v0.0.0-20170313132115-e3007ae9052e/go.mod h1:d7u6HkTYKSv5m6MCKkOQlHwaShTMl3HjqSGW3XtVhXM= github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= @@ -307,10 +315,12 @@ golang.org/x/crypto v0.0.0-20190829043050-9756ffdc2472/go.mod h1:yigFU9vqHzYiE8U golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181005035420-146acd28ed58/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53 h1:kcXqo9vE6fsZY5X5Rd7R1l7fTgnWaDCVmln65REefiE= golang.org/x/net v0.0.0-20190320064053-1272bf9dcd53/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= @@ -320,6 +330,7 @@ golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM= golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190211225200-5f6b76b7c9dd/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= @@ -339,7 +350,6 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190616124812-15dcb6c0061f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.0.0-20170915090833-1cbadb444a80/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= @@ -355,6 +365,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3 golang.org/x/tools v0.0.0-20190614205625-5aca471b1d59/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190617190820-da514acc4774/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= diff --git a/pkg/deployment/apm/delete.go b/pkg/deployment/apm/delete.go index 5d8e4edc..60a5e2f1 100644 --- a/pkg/deployment/apm/delete.go +++ b/pkg/deployment/apm/delete.go @@ -55,7 +55,7 @@ func Delete(params DeleteParams) error { return api.UnwrapError(err) } - if dep.Status != "stopped" { + if *dep.Status != "stopped" { return errors.New("apm delete: deployment must be stopped") } diff --git a/pkg/deployment/apm/delete_test.go b/pkg/deployment/apm/delete_test.go index 88f81556..b1d01573 100644 --- a/pkg/deployment/apm/delete_test.go +++ b/pkg/deployment/apm/delete_test.go @@ -29,6 +29,7 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/output" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" multierror "github.com/hashicorp/go-multierror" "github.com/elastic/ecctl/pkg/util" @@ -57,7 +58,7 @@ func TestDelete(t *testing.T) { ID: "d324608c97154bdba2dff97511d40368", API: api.NewMock(mock.Response{Response: http.Response{ Body: mock.NewStructBody(models.ApmInfo{ - Status: "started", + Status: ec.String("started"), }), StatusCode: 200, }}), @@ -71,7 +72,7 @@ func TestDelete(t *testing.T) { API: api.NewMock( mock.Response{Response: http.Response{ Body: mock.NewStructBody(models.ApmInfo{ - Status: "stopped", + Status: ec.String("stopped"), }), StatusCode: 200, }}, diff --git a/pkg/deployment/apm/plan_test.go b/pkg/deployment/apm/plan_test.go index 6b3a1946..bbe2ea99 100644 --- a/pkg/deployment/apm/plan_test.go +++ b/pkg/deployment/apm/plan_test.go @@ -210,7 +210,7 @@ func TestCancelPlan(t *testing.T) { ID: "d324608c97154bdba2dff97511d40368", API: api.NewMock(mock.Response{Response: http.Response{ Body: mock.NewStructBody(models.ApmInfo{ - Status: "success", + Status: ec.String("success"), }), StatusCode: 200, }}), @@ -240,7 +240,7 @@ func TestCancelPlan(t *testing.T) { ID: "d324608c97154bdba2dff97511d40368", API: api.NewMock(util.AppendTrackResponses(mock.Response{Response: http.Response{ Body: mock.NewStructBody(models.ApmInfo{ - Status: "success", + Status: ec.String("success"), }), StatusCode: 200, }})...), @@ -363,7 +363,7 @@ func TestReapplyLatestPlanAttempt(t *testing.T) { }, want: &models.ApmCrudResponse{ ApmID: "181a0cc28c9143b5a0bda51cd65676b3", - SecretToken: "wPYRlBJauhJGEZU6Ug", + SecretToken: ec.String("wPYRlBJauhJGEZU6Ug"), }, }, } diff --git a/pkg/deployment/apm/read_test.go b/pkg/deployment/apm/read_test.go index 65b92e11..5578375e 100644 --- a/pkg/deployment/apm/read_test.go +++ b/pkg/deployment/apm/read_test.go @@ -59,14 +59,14 @@ func TestList(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }, { ID: ec.String("d324608c97154bdba2dff97511d40368"), ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("86d2ec6217774eedb93ba38483141997"), }, - Status: "stopped", + Status: ec.String("stopped"), }, }, }), @@ -81,14 +81,14 @@ func TestList(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }, { ID: ec.String("d324608c97154bdba2dff97511d40368"), ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("86d2ec6217774eedb93ba38483141997"), }, - Status: "stopped", + Status: ec.String("stopped"), }, }, }, @@ -135,7 +135,7 @@ func TestShow(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }), StatusCode: 200, }}), @@ -145,7 +145,7 @@ func TestShow(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }, }, { diff --git a/pkg/deployment/create_test.go b/pkg/deployment/create_test.go index 278c5227..ab6e6e3c 100644 --- a/pkg/deployment/create_test.go +++ b/pkg/deployment/create_test.go @@ -107,8 +107,8 @@ func TestCreate(t *testing.T) { { CloudID: "my_elasticsearch_cluster:MTkyLjE2OC40NC4xMC5pcC5lcy5pbzo5MjQzJDAxZmEyODU4NzZmNTRlNjk5ZGEzZDNkNmZkOGE4NGYxJGNhOGFjNjU1NWYwZDQzZDhiYTEwNDhjOThlYTYwMjY1", Credentials: &models.ClusterCredentials{ - Password: "6n7Q5fXoFZDnpLOVPi5FnVLa", - Username: "elastic", + Password: ec.String("6n7Q5fXoFZDnpLOVPi5FnVLa"), + Username: ec.String("elastic"), }, ID: ec.String("01fa285876f54e699da3d3d6fd8a84f1"), Kind: ec.String("elasticsearch"), @@ -154,8 +154,8 @@ func TestCreate(t *testing.T) { { CloudID: "my_elasticsearch_cluster:MTkyLjE2OC40NC4xMC5pcC5lcy5pbzo5MjQzJDAxZmEyODU4NzZmNTRlNjk5ZGEzZDNkNmZkOGE4NGYxJGNhOGFjNjU1NWYwZDQzZDhiYTEwNDhjOThlYTYwMjY1", Credentials: &models.ClusterCredentials{ - Password: "6n7Q5fXoFZDnpLOVPi5FnVLa", - Username: "elastic", + Password: ec.String("6n7Q5fXoFZDnpLOVPi5FnVLa"), + Username: ec.String("elastic"), }, ID: ec.String("01fa285876f54e699da3d3d6fd8a84f1"), Kind: ec.String("elasticsearch"), @@ -201,8 +201,8 @@ func TestCreate(t *testing.T) { { CloudID: "my_elasticsearch_cluster:MTkyLjE2OC40NC4xMC5pcC5lcy5pbzo5MjQzJDAxZmEyODU4NzZmNTRlNjk5ZGEzZDNkNmZkOGE4NGYxJGNhOGFjNjU1NWYwZDQzZDhiYTEwNDhjOThlYTYwMjY1", Credentials: &models.ClusterCredentials{ - Password: "6n7Q5fXoFZDnpLOVPi5FnVLa", - Username: "elastic", + Password: ec.String("6n7Q5fXoFZDnpLOVPi5FnVLa"), + Username: ec.String("elastic"), }, ID: ec.String("01fa285876f54e699da3d3d6fd8a84f1"), Kind: ec.String("elasticsearch"), diff --git a/pkg/deployment/depresource/apm_test.go b/pkg/deployment/depresource/apm_test.go index ea403b76..cb81224e 100644 --- a/pkg/deployment/depresource/apm_test.go +++ b/pkg/deployment/depresource/apm_test.go @@ -69,7 +69,8 @@ func TestNewApm(t *testing.T) { {}, }, } - internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") + internalErrorBytes, _ := json.Marshal(internalError) + internalErrorBytesIndented, _ := json.MarshalIndent(internalError, "", " ") var getResponse = models.DeploymentGetResponse{ Resources: &models.DeploymentResources{ @@ -115,7 +116,7 @@ func TestNewApm(t *testing.T) { API: api.NewMock(mock.New500Response(mock.NewStructBody(internalError))), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytes) + "\n"), }, { name: "obtains the deployment info but fails getting the template ID info", @@ -146,7 +147,7 @@ func TestNewApm(t *testing.T) { ), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytesIndented)), }, { name: "obtains the deployment template but it's an invalid template for appsearch", diff --git a/pkg/deployment/depresource/appsearch_test.go b/pkg/deployment/depresource/appsearch_test.go index b643653b..dc26cbbc 100644 --- a/pkg/deployment/depresource/appsearch_test.go +++ b/pkg/deployment/depresource/appsearch_test.go @@ -69,7 +69,8 @@ func TestNewAppSearch(t *testing.T) { {}, }, } - internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") + internalErrorBytes, _ := json.Marshal(internalError) + internalErrorBytesIndented, _ := json.MarshalIndent(internalError, "", " ") var getResponse = models.DeploymentGetResponse{ Resources: &models.DeploymentResources{ @@ -115,7 +116,7 @@ func TestNewAppSearch(t *testing.T) { API: api.NewMock(mock.New500Response(mock.NewStructBody(internalError))), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytes) + "\n"), }, { name: "obtains the deployment info but fails getting the template ID info", @@ -146,7 +147,7 @@ func TestNewAppSearch(t *testing.T) { ), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytesIndented)), }, { name: "obtains the deployment template but it's an invalid template for appsearch", diff --git a/pkg/deployment/depresource/cancel_plan_test.go b/pkg/deployment/depresource/cancel_plan_test.go index 9c311786..60b33a8f 100644 --- a/pkg/deployment/depresource/cancel_plan_test.go +++ b/pkg/deployment/depresource/cancel_plan_test.go @@ -40,15 +40,7 @@ func TestCancelPlan(t *testing.T) { }, } internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") - var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` + var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" type args struct { params CancelPlanParams } diff --git a/pkg/deployment/depresource/kibana_test.go b/pkg/deployment/depresource/kibana_test.go index fa2e6d48..004a512c 100644 --- a/pkg/deployment/depresource/kibana_test.go +++ b/pkg/deployment/depresource/kibana_test.go @@ -69,7 +69,8 @@ func TestNewKibana(t *testing.T) { {}, }, } - internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") + internalErrorBytes, _ := json.Marshal(internalError) + internalErrorBytesIndent, _ := json.MarshalIndent(internalError, "", " ") var getResponse = models.DeploymentGetResponse{ Resources: &models.DeploymentResources{ @@ -115,7 +116,7 @@ func TestNewKibana(t *testing.T) { API: api.NewMock(mock.New500Response(mock.NewStructBody(internalError))), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytes) + "\n"), }, { name: "obtains the deployment info but fails getting the template ID info", @@ -146,7 +147,7 @@ func TestNewKibana(t *testing.T) { ), Region: "ece-region", }}, - err: errors.New(string(internalErrorBytes)), + err: errors.New(string(internalErrorBytesIndent)), }, { name: "obtains the deployment template but it's an invalid template for kibana", diff --git a/pkg/deployment/depresource/start_maintenance_test.go b/pkg/deployment/depresource/start_maintenance_test.go index 508560ea..8af673eb 100644 --- a/pkg/deployment/depresource/start_maintenance_test.go +++ b/pkg/deployment/depresource/start_maintenance_test.go @@ -40,15 +40,7 @@ func TestStartMaintenanceMode(t *testing.T) { }, } internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") - var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` + var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" type args struct { params StartParams } @@ -154,15 +146,7 @@ func TestStartInstancesMaintenanceMode(t *testing.T) { }, } internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") - var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` + var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" type args struct { params StartInstancesParams } diff --git a/pkg/deployment/depresource/start_test.go b/pkg/deployment/depresource/start_test.go index c109f0ab..4277291c 100644 --- a/pkg/deployment/depresource/start_test.go +++ b/pkg/deployment/depresource/start_test.go @@ -117,15 +117,7 @@ func TestStart(t *testing.T) { }, } internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") - var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` + var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" type args struct { params StartParams } @@ -231,15 +223,7 @@ func TestStartInstances(t *testing.T) { }, } internalErrorBytes, _ := json.MarshalIndent(internalError, "", " ") - var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` + var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" type args struct { params StartInstancesParams } diff --git a/pkg/deployment/depresource/stop_test.go b/pkg/deployment/depresource/stop_test.go index 4ef4cb1f..3d2fb2c3 100644 --- a/pkg/deployment/depresource/stop_test.go +++ b/pkg/deployment/depresource/stop_test.go @@ -39,15 +39,7 @@ var internalError = models.BasicFailedReply{ }, } var internalErrorBytes, _ = json.MarshalIndent(internalError, "", " ") -var errGet500 = `failed auto-discovering the resource ref id: { - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` +var errGet500 = `failed auto-discovering the resource ref id: {"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" func TestStopInstancesParams_Validate(t *testing.T) { tests := []struct { diff --git a/pkg/deployment/elasticsearch/delete.go b/pkg/deployment/elasticsearch/delete.go index bd091fa1..2680b48e 100644 --- a/pkg/deployment/elasticsearch/delete.go +++ b/pkg/deployment/elasticsearch/delete.go @@ -48,7 +48,7 @@ func DeleteCluster(params DeleteClusterParams) error { // Even though the cluster state can change in between querying the state // and performing the shutdown, it's not that relevant and thus accepted. - if res.Status != stoppedState { + if *res.Status != stoppedState { return errors.New("elasticsearch delete: deployment must be stopped") } diff --git a/pkg/deployment/elasticsearch/delete_test.go b/pkg/deployment/elasticsearch/delete_test.go index 2338f21d..8f8c24a4 100644 --- a/pkg/deployment/elasticsearch/delete_test.go +++ b/pkg/deployment/elasticsearch/delete_test.go @@ -26,6 +26,7 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/api" "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" "github.com/elastic/ecctl/pkg/util" ) @@ -48,7 +49,7 @@ func TestDeleteCluster(t *testing.T) { Response: http.Response{ StatusCode: 200, Body: mock.NewStructBody(models.ElasticsearchClusterInfo{ - Status: stoppedState, + Status: ec.String(stoppedState), }), }, }, mock.Response{ @@ -69,7 +70,7 @@ func TestDeleteCluster(t *testing.T) { Response: http.Response{ StatusCode: 200, Body: mock.NewStructBody(models.ElasticsearchClusterInfo{ - Status: stoppedState, + Status: ec.String(stoppedState), }), }, }, mock.Response{ @@ -91,7 +92,7 @@ func TestDeleteCluster(t *testing.T) { Response: http.Response{ StatusCode: 200, Body: mock.NewStructBody(models.ElasticsearchClusterInfo{ - Status: "started", + Status: ec.String("started"), }), }, }), diff --git a/pkg/deployment/elasticsearch/instances/override.go b/pkg/deployment/elasticsearch/instances/override.go index 0de336ad..88b082e6 100644 --- a/pkg/deployment/elasticsearch/instances/override.go +++ b/pkg/deployment/elasticsearch/instances/override.go @@ -184,8 +184,8 @@ func GetSizeFromTopology(topology *models.ElasticsearchClusterTopologyElement) ( func NewOverrideRequest(instances []*models.ClusterInstanceInfo, size TopologySize, newValue int32, filter []string) OverrideRequest { var override = OverrideRequest{Capacity: newValue} for _, instance := range instances { - legacyMatches := instance.InstanceConfiguration.Name == size.ID - instanceConfigMatches := instance.InstanceConfiguration.ID == size.ID + legacyMatches := *instance.InstanceConfiguration.Name == size.ID + instanceConfigMatches := *instance.InstanceConfiguration.ID == size.ID if legacyMatches || instanceConfigMatches { if slice.HasString(filter, *instance.InstanceName) { override.Instances = append(override.Instances, *instance.InstanceName) diff --git a/pkg/deployment/elasticsearch/instances/override_test.go b/pkg/deployment/elasticsearch/instances/override_test.go index c1a9b8b1..0e7c5cb0 100644 --- a/pkg/deployment/elasticsearch/instances/override_test.go +++ b/pkg/deployment/elasticsearch/instances/override_test.go @@ -145,25 +145,25 @@ func TestNewOverrideRequest(t *testing.T) { { InstanceName: ec.String("instance-0000000008"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.highio.legacy", - Name: "highio.legacy", - Resource: "memory", + ID: ec.String("aws.highio.legacy"), + Name: ec.String("highio.legacy"), + Resource: ec.String("memory"), }, }, { InstanceName: ec.String("instance-0000000009"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.highio.legacy", - Name: "highio.legacy", - Resource: "memory", + ID: ec.String("aws.highio.legacy"), + Name: ec.String("highio.legacy"), + Resource: ec.String("memory"), }, }, { InstanceName: ec.String("instance-0000000010"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.master.legacy", - Name: "master.legacy", - Resource: "memory", + ID: ec.String("aws.master.legacy"), + Name: ec.String("master.legacy"), + Resource: ec.String("memory"), }, }, }, @@ -192,25 +192,25 @@ func TestNewOverrideRequest(t *testing.T) { { InstanceName: ec.String("instance-0000000008"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.highio.classic", - Name: "highio.classic", - Resource: "memory", + ID: ec.String("aws.highio.classic"), + Name: ec.String("highio.classic"), + Resource: ec.String("memory"), }, }, { InstanceName: ec.String("instance-0000000009"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.highio.classic", - Name: "highio.classic", - Resource: "memory", + ID: ec.String("aws.highio.classic"), + Name: ec.String("highio.classic"), + Resource: ec.String("memory"), }, }, { InstanceName: ec.String("instance-0000000010"), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.master.classic", - Name: "master.classic", - Resource: "memory", + ID: ec.String("aws.master.classic"), + Name: ec.String("master.classic"), + Resource: ec.String("memory"), }, }, }, diff --git a/pkg/deployment/get_resource_test.go b/pkg/deployment/get_resource_test.go index 74a29c30..50971dec 100644 --- a/pkg/deployment/get_resource_test.go +++ b/pkg/deployment/get_resource_test.go @@ -32,15 +32,7 @@ import ( "github.com/elastic/ecctl/pkg/util" ) -var errGet500 = `{ - "errors": [ - { - "code": "deployment.missing", - "fields": null, - "message": null - } - ] -}` +var errGet500 = `{"errors":[{"code":"deployment.missing","fields":null,"message":null}]}` + "\n" func TestGetResource(t *testing.T) { type args struct { diff --git a/pkg/deployment/get_test.go b/pkg/deployment/get_test.go index c6570e00..c2760765 100644 --- a/pkg/deployment/get_test.go +++ b/pkg/deployment/get_test.go @@ -108,11 +108,6 @@ func TestGet(t *testing.T) { "healthy": true, "id": "f1d329b0fb34470ba8b18361cabdd2bc" }` - - const getErrorResponse = `{ - "errors": null -}` - type args struct { params GetParams } @@ -144,7 +139,7 @@ func TestGet(t *testing.T) { }, }, wantErr: true, - err: errors.New(getErrorResponse), + err: errors.New(""), }, { name: "Get succeeds", @@ -516,11 +511,6 @@ func TestGetElasticsearchID(t *testing.T) { }] } }` - - const getErrorResponse = `{ - "errors": null -}` - type args struct { params GetParams } @@ -543,7 +533,7 @@ func TestGetElasticsearchID(t *testing.T) { }, }, wantErr: true, - err: errors.New(getErrorResponse), + err: errors.New(""), }, { name: "Get succeeds", diff --git a/pkg/deployment/kibana/delete.go b/pkg/deployment/kibana/delete.go index e4c422ab..cebd5b5b 100644 --- a/pkg/deployment/kibana/delete.go +++ b/pkg/deployment/kibana/delete.go @@ -47,7 +47,7 @@ func Delete(params DeploymentParams) error { return err } - if res.Status != stoppedState { + if *res.Status != stoppedState { return errors.New("kibana delete: deployment must be stopped") } diff --git a/pkg/deployment/kibana/delete_test.go b/pkg/deployment/kibana/delete_test.go index c8dbc70b..4fd97ecc 100644 --- a/pkg/deployment/kibana/delete_test.go +++ b/pkg/deployment/kibana/delete_test.go @@ -30,6 +30,7 @@ import ( "github.com/elastic/cloud-sdk-go/pkg/api/mock" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/output" + "github.com/elastic/cloud-sdk-go/pkg/util/ec" multierror "github.com/hashicorp/go-multierror" "github.com/elastic/ecctl/pkg/util" @@ -75,7 +76,7 @@ func TestDelete(t *testing.T) { mock.Response{Response: http.Response{ StatusCode: 200, Body: mock.NewStructBody(models.KibanaClusterInfo{ - Status: "stopped", + Status: ec.String("stopped"), }), }}, mock.Response{Response: http.Response{ @@ -100,7 +101,7 @@ func TestDelete(t *testing.T) { mock.Response{Response: http.Response{ StatusCode: 200, Body: mock.NewStructBody(models.KibanaClusterInfo{ - Status: "stopped", + Status: ec.String("stopped"), }), }}, mock.Response{Response: http.Response{ diff --git a/pkg/deployment/kibana/read_test.go b/pkg/deployment/kibana/read_test.go index 5aabe328..90bd631b 100644 --- a/pkg/deployment/kibana/read_test.go +++ b/pkg/deployment/kibana/read_test.go @@ -151,7 +151,7 @@ func TestGet(t *testing.T) { Healthy: ec.Bool(true), }, Region: "us-east-1", - Status: "started", + Status: ec.String("started"), Topology: &models.ClusterTopologyInfo{ Healthy: ec.Bool(true), Instances: []*models.ClusterInstanceInfo{ @@ -160,9 +160,9 @@ func TestGet(t *testing.T) { ContainerStarted: ec.Bool(true), Healthy: ec.Bool(true), InstanceConfiguration: &models.ClusterInstanceConfigurationInfo{ - ID: "aws.kibana.r4", - Name: "aws.kibana.r4", - Resource: "memory", + ID: ec.String("aws.kibana.r4"), + Name: ec.String("aws.kibana.r4"), + Resource: ec.String("memory"), }, InstanceName: ec.String("instance-0000000002"), MaintenanceMode: ec.Bool(false), @@ -243,14 +243,14 @@ func TestList(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }, { ClusterID: ec.String("d324608c97154bdba2dff97511d40368"), ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("86d2ec6217774eedb93ba38483141997"), }, - Status: "stopped", + Status: ec.String("stopped"), }, }, }), @@ -264,14 +264,14 @@ func TestList(t *testing.T) { ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("d324608c97154bdba2dff97511d40368"), }, - Status: "started", + Status: ec.String("started"), }, { ClusterID: ec.String("d324608c97154bdba2dff97511d40368"), ElasticsearchCluster: &models.TargetElasticsearchCluster{ ElasticsearchID: ec.String("86d2ec6217774eedb93ba38483141997"), }, - Status: "stopped", + Status: ec.String("stopped"), }, }, }, diff --git a/pkg/deployment/note/list.go b/pkg/deployment/note/list.go index 43e6b747..b71c99d6 100644 --- a/pkg/deployment/note/list.go +++ b/pkg/deployment/note/list.go @@ -19,7 +19,7 @@ package note import ( "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/client/deployments" + "github.com/elastic/cloud-sdk-go/pkg/client/deployments_notes" "github.com/elastic/cloud-sdk-go/pkg/models" ) @@ -38,8 +38,8 @@ func List(params Params) (*models.Notes, error) { return nil, err } - res, err := params.API.V1API.Deployments.GetDeploymentNotes( - deployments.NewGetDeploymentNotesParams(). + res, err := params.V1API.DeploymentsNotes.GetDeploymentNotes( + deployments_notes.NewGetDeploymentNotesParams(). WithDeploymentID(params.ID), params.AuthWriter, ) diff --git a/pkg/deployment/note/show.go b/pkg/deployment/note/show.go index 2b9373c7..4dfd8c12 100644 --- a/pkg/deployment/note/show.go +++ b/pkg/deployment/note/show.go @@ -21,7 +21,7 @@ import ( "errors" "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/client/deployments" + "github.com/elastic/cloud-sdk-go/pkg/client/deployments_notes" "github.com/elastic/cloud-sdk-go/pkg/models" multierror "github.com/hashicorp/go-multierror" ) @@ -55,8 +55,8 @@ func Get(params GetParams) (*models.Note, error) { return nil, err } - res, err := params.API.V1API.Deployments.GetDeploymentNote( - deployments.NewGetDeploymentNoteParams(). + res, err := params.V1API.DeploymentsNotes.GetDeploymentNote( + deployments_notes.NewGetDeploymentNoteParams(). WithDeploymentID(params.ID). WithNoteID(params.NoteID), params.AuthWriter, diff --git a/pkg/deployment/note/update.go b/pkg/deployment/note/update.go index f540289c..84464f2d 100644 --- a/pkg/deployment/note/update.go +++ b/pkg/deployment/note/update.go @@ -21,7 +21,7 @@ import ( "errors" "github.com/elastic/cloud-sdk-go/pkg/api" - "github.com/elastic/cloud-sdk-go/pkg/client/deployments" + "github.com/elastic/cloud-sdk-go/pkg/client/deployments_notes" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" multierror "github.com/hashicorp/go-multierror" @@ -66,8 +66,8 @@ func Update(params UpdateParams) (*models.Note, error) { return nil, err } - res, err := params.API.V1API.Deployments.UpdateDeploymentNote( - deployments.NewUpdateDeploymentNoteParams(). + res, err := params.API.V1API.DeploymentsNotes.UpdateDeploymentNote( + deployments_notes.NewUpdateDeploymentNoteParams(). WithDeploymentID(params.ID). WithNoteID(params.NoteID). WithBody(&models.Note{ diff --git a/pkg/deployment/note/write.go b/pkg/deployment/note/write.go index 7bd4a9af..bed7fd4f 100644 --- a/pkg/deployment/note/write.go +++ b/pkg/deployment/note/write.go @@ -20,7 +20,7 @@ package note import ( "errors" - "github.com/elastic/cloud-sdk-go/pkg/client/deployments" + "github.com/elastic/cloud-sdk-go/pkg/client/deployments_notes" "github.com/elastic/cloud-sdk-go/pkg/models" "github.com/elastic/cloud-sdk-go/pkg/util/ec" multierror "github.com/hashicorp/go-multierror" @@ -69,8 +69,8 @@ func Add(params AddParams) error { message = params.Commentator.Message(message) } - return util.ReturnErrOnly(params.V1API.Deployments.CreateDeploymentNote( - deployments.NewCreateDeploymentNoteParams(). + return util.ReturnErrOnly(params.V1API.DeploymentsNotes.CreateDeploymentNote( + deployments_notes.NewCreateDeploymentNoteParams(). WithDeploymentID(params.ID). WithBody(&models.Note{ Message: ec.String(message), diff --git a/pkg/ecctl/config.go b/pkg/ecctl/config.go index 1d9eaf7c..6f5f3561 100644 --- a/pkg/ecctl/config.go +++ b/pkg/ecctl/config.go @@ -66,6 +66,9 @@ type Config struct { Insecure bool `json:"insecure,omitempty"` // SkipLogin skips loging in when user and pass are set. SkipLogin bool `json:"-"` + + // SkipLogin skips loging in when user and pass are set. + UserAgent string `json:"-"` } // Validate checks that the application config is a valid one diff --git a/pkg/platform/allocator/vacate_test.go b/pkg/platform/allocator/vacate_test.go index f3bf658b..74de0d0c 100644 --- a/pkg/platform/allocator/vacate_test.go +++ b/pkg/platform/allocator/vacate_test.go @@ -953,7 +953,7 @@ func Test_fillVacateClusterParams(t *testing.T) { Output: output.NewDevice(new(bytes.Buffer)), }, }, - err: errors.New("allocator allocator-1: cluster [3ee11eb40eda22cac0cce259625c6734][elasticsearch]: allocator health autodiscovery: Get https://mock-host/mock-path/platform/infrastructure/allocators/allocator-1: unauthorized"), + err: errors.New(`allocator allocator-1: cluster [3ee11eb40eda22cac0cce259625c6734][elasticsearch]: allocator health autodiscovery: Get https://mock-host/mock-path/platform/infrastructure/allocators/allocator-1: unauthorized`), }, { name: "sets defaults on parameters that aren't specified", @@ -1053,7 +1053,7 @@ func Test_newMoveClusterParams(t *testing.T) { Kind: "elasticsearch", Output: output.NewDevice(new(bytes.Buffer)), }}, - err: errors.New("allocator allocator-1: cluster [3ee11eb40eda22cac0cce259625c6734][elasticsearch]: validate_only: Post https://mock-host/mock-path/platform/infrastructure/allocators/allocator-1/clusters/_move?force_update=false&validate_only=true: unauthorized"), + err: errors.New(`allocator allocator-1: cluster [3ee11eb40eda22cac0cce259625c6734][elasticsearch]: validate_only: Post https://mock-host/mock-path/platform/infrastructure/allocators/allocator-1/clusters/_move?force_update=false&validate_only=true: unauthorized`), }, { name: "elasticsearch move succeeds to get parameters", diff --git a/pkg/platform/constructor/constructor_test.go b/pkg/platform/constructor/constructor_test.go index ca7d76be..8b21cca8 100644 --- a/pkg/platform/constructor/constructor_test.go +++ b/pkg/platform/constructor/constructor_test.go @@ -62,7 +62,7 @@ func TestList(t *testing.T) { want: &models.ConstructorOverview{ Constructors: []*models.ConstructorInfo{ { - ConstructorID: "192.168.44.10", + ConstructorID: ec.String("192.168.44.10"), Status: &models.ConstructorHealthStatus{ Connected: ec.Bool(true), MaintenanceMode: ec.Bool(false), @@ -136,7 +136,7 @@ func TestGet(t *testing.T) { }, }, want: &models.ConstructorInfo{ - ConstructorID: "192.168.44.10", + ConstructorID: ec.String("192.168.44.10"), Status: &models.ConstructorHealthStatus{ Connected: ec.Bool(true), MaintenanceMode: ec.Bool(false), diff --git a/pkg/platform/deployment/template_test.go b/pkg/platform/deployment/template_test.go index 4f14f84f..42f8c092 100644 --- a/pkg/platform/deployment/template_test.go +++ b/pkg/platform/deployment/template_test.go @@ -92,7 +92,7 @@ func TestList(t *testing.T) { API: api.NewMock(mock.Response{Error: errors.New("error")}), }, wantErr: true, - error: "Get https://mock-host/mock-path/platform/configuration/templates/deployments?show_hidden=false&show_instance_configurations=false: error", + error: `Get https://mock-host/mock-path/platform/configuration/templates/deployments?format=cluster&show_hidden=false&show_instance_configurations=false: error`, }, { name: "Platform deployment templates fails with an empty API", @@ -232,7 +232,7 @@ func TestGet(t *testing.T) { }, }, wantErr: true, - error: "Get https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e?show_instance_configurations=false: error", + error: `Get https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e?format=cluster&show_instance_configurations=false: error`, }, { name: "Platform deployment template show fails with an empty API reference", @@ -309,7 +309,7 @@ func TestDelete(t *testing.T) { }, }, wantErr: true, - error: "Delete https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e: error", + error: `Delete https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e: error`, }, { name: "Platform deployment template delete fails with an empty API reference", @@ -391,7 +391,7 @@ func TestCreate(t *testing.T) { API: api.NewMock(mock.Response{Error: errors.New("error")}), }, wantErr: true, - error: "Post https://mock-host/mock-path/platform/configuration/templates/deployments: error", + error: `Post https://mock-host/mock-path/platform/configuration/templates/deployments: error`, }, { name: "Platform deployment template create fails with an empty API reference", @@ -474,7 +474,7 @@ func TestUpdate(t *testing.T) { }, }, wantErr: true, - error: "Put https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e?create_only=false: error", + error: `Put https://mock-host/mock-path/platform/configuration/templates/deployments/84e0bd6d69bb44e294809d89cea88a7e?create_only=false: error`, }, { name: "Platform deployment template update fails with an empty API reference",