Skip to content

Commit 6f3bc2c

Browse files
authored
cmd: new appsearch show <deployment id> (#186)
Implements an `ecctl deployment appsearch show <deployment id>` command which shows information about the specified AppSearch deployment.
1 parent bdb5e3d commit 6f3bc2c

File tree

6 files changed

+205
-0
lines changed

6 files changed

+205
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package cmdappsearch
19+
20+
import (
21+
"github.com/spf13/cobra"
22+
)
23+
24+
// Command is the deployment subcommand
25+
var Command = &cobra.Command{
26+
Use: "appsearch",
27+
Short: "Manages AppSearch deployments",
28+
PreRunE: cobra.MaximumNArgs(0),
29+
Run: func(cmd *cobra.Command, args []string) {
30+
cmd.Help()
31+
},
32+
}
33+
34+
func init() {
35+
Command.AddCommand(
36+
showAppSearchCmd,
37+
)
38+
}

cmd/deployment/appsearch/show.go

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
// Licensed to Elasticsearch B.V. under one or more contributor
2+
// license agreements. See the NOTICE file distributed with
3+
// this work for additional information regarding copyright
4+
// ownership. Elasticsearch B.V. licenses this file to you under
5+
// the Apache License, Version 2.0 (the "License"); you may
6+
// not use this file except in compliance with the License.
7+
// You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package cmdappsearch
19+
20+
import (
21+
"github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
22+
"github.com/spf13/cobra"
23+
24+
"github.com/elastic/ecctl/pkg/deployment"
25+
"github.com/elastic/ecctl/pkg/deployment/deputil"
26+
"github.com/elastic/ecctl/pkg/ecctl"
27+
)
28+
29+
var showAppSearchCmd = &cobra.Command{
30+
Use: "show <deployment id>",
31+
Short: "Shows the specified AppSearch deployment",
32+
PreRunE: cmdutil.MinimumNArgsAndUUID(1),
33+
RunE: func(cmd *cobra.Command, args []string) error {
34+
refID, _ := cmd.Flags().GetString("ref-id")
35+
planLogs, _ := cmd.Flags().GetBool("plan-logs")
36+
planDefaults, _ := cmd.Flags().GetBool("plan-defaults")
37+
metadata, _ := cmd.Flags().GetBool("metadata")
38+
settings, _ := cmd.Flags().GetBool("settings")
39+
plans, _ := cmd.Flags().GetBool("plans")
40+
var showPlans bool
41+
if planLogs || planDefaults || plans {
42+
showPlans = true
43+
}
44+
res, err := deployment.GetResource(deployment.GetResourceParams{
45+
Type: "appsearch",
46+
GetParams: deployment.GetParams{
47+
API: ecctl.Get().API,
48+
DeploymentID: args[0],
49+
RefID: refID,
50+
QueryParams: deputil.QueryParams{
51+
ShowPlans: showPlans,
52+
ShowPlanLogs: planLogs,
53+
ShowPlanDefaults: planDefaults,
54+
ShowMetadata: metadata,
55+
ShowSettings: settings,
56+
},
57+
},
58+
})
59+
if err != nil {
60+
return err
61+
}
62+
return ecctl.Get().Formatter.Format("", res)
63+
},
64+
}
65+
66+
func init() {
67+
showAppSearchCmd.Flags().String("ref-id", "", "Optional RefId, auto-discovered if not specified")
68+
showAppSearchCmd.Flags().Bool("plans", false, "Shows the deployment plans")
69+
showAppSearchCmd.Flags().Bool("plan-logs", false, "Shows the deployment plan logs")
70+
showAppSearchCmd.Flags().Bool("plan-defaults", false, "Shows the deployment plan defaults")
71+
showAppSearchCmd.Flags().BoolP("metadata", "m", false, "Shows the deployment metadata")
72+
showAppSearchCmd.Flags().BoolP("settings", "s", false, "Shows the deployment settings")
73+
}

cmd/deployment/command.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/spf13/cobra"
2222

2323
cmdapm "github.com/elastic/ecctl/cmd/deployment/apm"
24+
cmdappsearch "github.com/elastic/ecctl/cmd/deployment/appsearch"
2425
cmdelasticsearch "github.com/elastic/ecctl/cmd/deployment/elasticsearch"
2526
cmdkibana "github.com/elastic/ecctl/cmd/deployment/kibana"
2627
cmddeploymentnote "github.com/elastic/ecctl/cmd/deployment/note"
@@ -44,6 +45,7 @@ func init() {
4445
cmdelasticsearch.Command,
4546
cmdkibana.Command,
4647
cmdapm.Command,
48+
cmdappsearch.Command,
4749
cmddeploymentplan.Command,
4850
cmddeploymentresource.Command,
4951
)

docs/ecctl_deployment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ ecctl deployment [flags]
4040

4141
* [ecctl](ecctl.md) - Elastic Cloud Control
4242
* [ecctl deployment apm](ecctl_deployment_apm.md) - Manages APM deployments
43+
* [ecctl deployment appsearch](ecctl_deployment_appsearch.md) - Manages AppSearch deployments
4344
* [ecctl deployment create](ecctl_deployment_create.md) - Creates a deployment from a file definition, allowing certain flag overrides
4445
* [ecctl deployment delete](ecctl_deployment_delete.md) - Deletes a previously stopped deployment from the platform
4546
* [ecctl deployment elasticsearch](ecctl_deployment_elasticsearch.md) - Manages Elasticsearch clusters

docs/ecctl_deployment_appsearch.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
## ecctl deployment appsearch
2+
3+
Manages AppSearch deployments
4+
5+
### Synopsis
6+
7+
Manages AppSearch deployments
8+
9+
```
10+
ecctl deployment appsearch [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for appsearch
17+
```
18+
19+
### Options inherited from parent commands
20+
21+
```
22+
--apikey string API key to use to authenticate (If empty will look for EC_APIKEY environment variable)
23+
--config string Config name, used to have multiple configs in $HOME/.ecctl/<env> (default "config")
24+
--force Do not ask for confirmation
25+
--format string Formats the output using a Go template
26+
--host string Base URL to use
27+
--insecure Skips all TLS validation
28+
--message string A message to set on cluster operation
29+
--output string Output format [text|json] (default "text")
30+
--pass string Password to use to authenticate (If empty will look for EC_PASS environment variable)
31+
--pprof Enables pprofing and saves the profile to pprof-20060102150405
32+
-q, --quiet Suppresses the configuration file used for the run, if any
33+
--timeout duration Timeout to use on all HTTP calls (default 30s)
34+
--trace Enables tracing saves the trace to trace-20060102150405
35+
--user string Username to use to authenticate (If empty will look for EC_USER environment variable)
36+
--verbose Enable verbose mode
37+
```
38+
39+
### SEE ALSO
40+
41+
* [ecctl deployment](ecctl_deployment.md) - Manages deployments
42+
* [ecctl deployment appsearch show](ecctl_deployment_appsearch_show.md) - Shows the specified AppSearch deployment
43+
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
## ecctl deployment appsearch show
2+
3+
Shows the specified AppSearch deployment
4+
5+
### Synopsis
6+
7+
Shows the specified AppSearch deployment
8+
9+
```
10+
ecctl deployment appsearch show <deployment id> [flags]
11+
```
12+
13+
### Options
14+
15+
```
16+
-h, --help help for show
17+
-m, --metadata Shows the deployment metadata
18+
--plan-defaults Shows the deployment plan defaults
19+
--plan-logs Shows the deployment plan logs
20+
--plans Shows the deployment plans
21+
--ref-id string Optional RefId, auto-discovered if not specified
22+
-s, --settings Shows the deployment settings
23+
```
24+
25+
### Options inherited from parent commands
26+
27+
```
28+
--apikey string API key to use to authenticate (If empty will look for EC_APIKEY environment variable)
29+
--config string Config name, used to have multiple configs in $HOME/.ecctl/<env> (default "config")
30+
--force Do not ask for confirmation
31+
--format string Formats the output using a Go template
32+
--host string Base URL to use
33+
--insecure Skips all TLS validation
34+
--message string A message to set on cluster operation
35+
--output string Output format [text|json] (default "text")
36+
--pass string Password to use to authenticate (If empty will look for EC_PASS environment variable)
37+
--pprof Enables pprofing and saves the profile to pprof-20060102150405
38+
-q, --quiet Suppresses the configuration file used for the run, if any
39+
--timeout duration Timeout to use on all HTTP calls (default 30s)
40+
--trace Enables tracing saves the trace to trace-20060102150405
41+
--user string Username to use to authenticate (If empty will look for EC_USER environment variable)
42+
--verbose Enable verbose mode
43+
```
44+
45+
### SEE ALSO
46+
47+
* [ecctl deployment appsearch](ecctl_deployment_appsearch.md) - Manages AppSearch deployments
48+

0 commit comments

Comments
 (0)