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 flag to select the kibana version in elastic-package status #590

Merged
merged 3 commits into from
Nov 18, 2021
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
25 changes: 15 additions & 10 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func setupStatusCommand() *cobraext.Command {
RunE: statusCommandAction,
}
cmd.Flags().BoolP(cobraext.ShowAllFlagName, "a", false, cobraext.ShowAllFlagDescription)
cmd.Flags().String(cobraext.StatusKibanaVersionFlagName, "", cobraext.StatusKibanaVersionFlagDescription)

return cobraext.NewCommand(cmd, cobraext.ContextPackage)
}
Expand All @@ -51,19 +52,26 @@ func statusCommandAction(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
packageName = args[0]
}
packageStatus, err := getPackageStatus(packageName, showAll)

kibanaVersion, err := cmd.Flags().GetString(cobraext.StatusKibanaVersionFlagName)
if err != nil {
return cobraext.FlagParsingError(err, cobraext.StatusKibanaVersionFlagName)
}
options := registry.SearchOptions{
All: showAll,
KibanaVersion: kibanaVersion,
Experimental: true,
}
packageStatus, err := getPackageStatus(packageName, options)
if err != nil {
return err
}
return print(packageStatus, os.Stdout)
}

func getPackageStatus(packageName string, showAll bool) (*status.PackageStatus, error) {
func getPackageStatus(packageName string, options registry.SearchOptions) (*status.PackageStatus, error) {
if packageName != "" {
return status.RemotePackage(packageName, registry.SearchOptions{
All: showAll,
Experimental: true,
})
return status.RemotePackage(packageName, options)
}
packageRootPath, found, err := packages.FindPackageRoot()
if !found {
Expand All @@ -72,10 +80,7 @@ func getPackageStatus(packageName string, showAll bool) (*status.PackageStatus,
if err != nil {
return nil, errors.Wrap(err, "locating package root failed")
}
return status.LocalPackage(packageRootPath, registry.SearchOptions{
All: showAll,
Experimental: true,
})
return status.LocalPackage(packageRootPath, options)
}

// print formats and prints package information into a table
Expand Down
3 changes: 3 additions & 0 deletions internal/cobraext/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ const (
StackDumpOutputFlagName = "output"
StackDumpOutputFlagDescription = "output location for the stack dump"

StatusKibanaVersionFlagName = "kibana-version"
StatusKibanaVersionFlagDescription = "show packages for the given kibana version"

TestCoverageFlagName = "test-coverage"
TestCoverageFlagDescription = "generate Cobertura test coverage reports"

Expand Down
5 changes: 3 additions & 2 deletions internal/registry/revisions.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (

// SearchOptions specify the query parameters without the package name for the search API
type SearchOptions struct {
Experimental bool `url:"experimental"`
All bool `url:"all"`
Experimental bool `url:"experimental"`
All bool `url:"all"`
KibanaVersion string `url:"kibana.version,omitempty"`
}

// searchQuery specify the package and query parameters for the search API
Expand Down