diff --git a/cmd/status.go b/cmd/status.go index 4d73ab894..f6a6f9d1e 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -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) } @@ -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 { @@ -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 diff --git a/internal/cobraext/const.go b/internal/cobraext/const.go index bfdb500a6..85a149b33 100644 --- a/internal/cobraext/const.go +++ b/internal/cobraext/const.go @@ -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" diff --git a/internal/registry/revisions.go b/internal/registry/revisions.go index b0c800f01..a67c80e0f 100644 --- a/internal/registry/revisions.go +++ b/internal/registry/revisions.go @@ -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