Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --config-version flag to instance configuration show command #669

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 24 additions & 3 deletions cmd/platform/instance-configuration/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ package cmdinstanceconfig

import (
"path/filepath"
"strconv"

"github.com/elastic/cloud-sdk-go/pkg/api/platformapi/instanceconfigapi"
"github.com/elastic/cloud-sdk-go/pkg/util/ec"
"github.com/spf13/cobra"

cmdutil "github.com/elastic/ecctl/cmd/util"
Expand All @@ -32,10 +34,27 @@ var showCmd = &cobra.Command{
Short: cmdutil.AdminReqDescription("Shows an instance configuration"),
PreRunE: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
configVersion, _ := cmd.Flags().GetString("config-version")
showDeleted, _ := cmd.Flags().GetBool("show-deleted")

var version *int64 = nil

if configVersion != "" {
parsedVersion, err := strconv.ParseInt(configVersion, 10, 64)

version = ec.Int64(parsedVersion)

if err != nil {
return err
}
}

res, err := instanceconfigapi.Get(instanceconfigapi.GetParams{
API: ecctl.Get().API,
Region: ecctl.Get().Config.Region,
ID: args[0],
API: ecctl.Get().API,
Region: ecctl.Get().Config.Region,
ID: args[0],
ConfigVersion: version,
ShowDeleted: showDeleted,
})

if err != nil {
Expand All @@ -48,4 +67,6 @@ var showCmd = &cobra.Command{

func init() {
Command.AddCommand(showCmd)
showCmd.Flags().StringP("config-version", "v", "", "Instance configuration version")
showCmd.Flags().Bool("show-deleted", false, "If set to true, allows to show deleted instance configurations")
}
4 changes: 3 additions & 1 deletion docs/ecctl_platform_instance-configuration_show.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ ecctl platform instance-configuration show <config id> [flags]
=== Options

----
-h, --help help for show
-v, --config-version string Instance configuration version
-h, --help help for show
--show-deleted If set to true, allows to show deleted instance configurations
----

[float]
Expand Down
4 changes: 3 additions & 1 deletion docs/ecctl_platform_instance-configuration_show.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ ecctl platform instance-configuration show <config id> [flags]
### Options

```
-h, --help help for show
-v, --config-version string Instance configuration version
-h, --help help for show
--show-deleted If set to true, allows to show deleted instance configurations
```

### Options inherited from parent commands
Expand Down
Loading