Skip to content

Commit f12b3f2

Browse files
authored
cmd: new appsearch upgrade <deployment id> (#191)
Implements an `ecctl appsearch upgrade <deployment id>` command which upgrades the AppSearch deployment to match the Elasticsearch deployment.
1 parent f1f88c4 commit f12b3f2

File tree

3 files changed

+117
-0
lines changed

3 files changed

+117
-0
lines changed

cmd/deployment/appsearch/upgrade.go

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
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/models"
22+
sdkcmdutil "github.com/elastic/cloud-sdk-go/pkg/util/cmdutil"
23+
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
24+
"github.com/spf13/cobra"
25+
26+
cmdutil "github.com/elastic/ecctl/cmd/util"
27+
"github.com/elastic/ecctl/pkg/deployment"
28+
"github.com/elastic/ecctl/pkg/deployment/depresource"
29+
"github.com/elastic/ecctl/pkg/ecctl"
30+
)
31+
32+
// upgradeCmd is the deployment subcommand
33+
var upgradeCmd = &cobra.Command{
34+
Use: "upgrade <deployment id>",
35+
Short: "Upgrades an AppSearch deployment to the Elasticsearch deployment version",
36+
PreRunE: sdkcmdutil.MinimumNArgsAndUUID(1),
37+
RunE: func(cmd *cobra.Command, args []string) error {
38+
resType := "appsearch"
39+
refID, _ := cmd.Flags().GetString("ref-id")
40+
41+
res, err := depresource.UpgradeStateless(deployment.ResourceParams{
42+
API: ecctl.Get().API,
43+
DeploymentID: args[0],
44+
Type: resType,
45+
RefID: refID,
46+
})
47+
48+
if err != nil {
49+
return err
50+
}
51+
52+
if track, _ := cmd.Flags().GetBool("track"); !track {
53+
return nil
54+
}
55+
56+
return depresource.TrackResources(depresource.TrackResourcesParams{
57+
API: ecctl.Get().API,
58+
OutputDevice: ecctl.Get().Config.OutputDevice,
59+
Resources: []*models.DeploymentResource{{
60+
ID: ec.String(res.ResourceID),
61+
Kind: ec.String(resType),
62+
RefID: ec.String(refID),
63+
}},
64+
})
65+
},
66+
}
67+
68+
func init() {
69+
Command.AddCommand(upgradeCmd)
70+
upgradeCmd.Flags().BoolP("track", "t", false, cmdutil.TrackFlagMessage)
71+
upgradeCmd.Flags().String("ref-id", "", "Optional RefId, if not set, the RefId will be auto-discovered")
72+
}

docs/ecctl_deployment_appsearch.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ ecctl deployment appsearch [flags]
4343
* [ecctl deployment appsearch delete](ecctl_deployment_appsearch_delete.md) - Deletes a previously shut down AppSearch deployment resource
4444
* [ecctl deployment appsearch show](ecctl_deployment_appsearch_show.md) - Shows the specified AppSearch deployment
4545
* [ecctl deployment appsearch shutdown](ecctl_deployment_appsearch_shutdown.md) - Shuts down an AppSearch deployment
46+
* [ecctl deployment appsearch upgrade](ecctl_deployment_appsearch_upgrade.md) - Upgrades an AppSearch deployment to the Elasticsearch deployment version
4647

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

0 commit comments

Comments
 (0)