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

[experiment] First approach to extensible shell with plugins #1416

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,12 @@ _Context: package_

Boot up the stack.

### `elastic-package shell`

_Context: global_



### `elastic-package stack`

_Context: global_
Expand Down
2 changes: 1 addition & 1 deletion cmd/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ import (
"github.com/elastic/elastic-package/internal/benchrunner/runners/system"
"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/signal"
"github.com/elastic/elastic-package/internal/testrunner"
"github.com/elastic/elastic-package/pkg/packages"
)

const generateLongDescription = `
Expand Down
2 changes: 1 addition & 1 deletion cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/elastic/elastic-package/internal/docs"
"github.com/elastic/elastic-package/internal/files"
"github.com/elastic/elastic-package/internal/logger"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/pkg/packages"
)

const buildLongDescription = `Use this command to build a package. Currently it supports only the "integration" package type.
Expand Down
4 changes: 2 additions & 2 deletions cmd/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/changelog"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/changelog"
)

const changelogLongDescription = `Use this command to work with the changelog of the package.
Expand Down
4 changes: 2 additions & 2 deletions cmd/create_data_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/archetype"
"github.com/elastic/elastic-package/internal/surveyext"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/archetype"
)

const createDataStreamLongDescription = `Use this command to create a new data stream.
Expand Down
4 changes: 2 additions & 2 deletions cmd/create_package.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/licenses"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/archetype"
"github.com/elastic/elastic-package/internal/surveyext"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/archetype"
)

const createPackageLongDescription = `Use this command to create a new package.
Expand Down
2 changes: 1 addition & 1 deletion cmd/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/formatter"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/pkg/packages"
)

const formatLongDescription = `Use this command to format the package files.
Expand Down
4 changes: 2 additions & 2 deletions cmd/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/installer"
"github.com/elastic/elastic-package/internal/stack"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/installer"
)

const installLongDescription = `Use this command to install the package in Kibana.
Expand Down
2 changes: 1 addition & 1 deletion cmd/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/docs"
"github.com/elastic/elastic-package/internal/logger"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/validation"
"github.com/elastic/elastic-package/pkg/packages"
)

const lintLongDescription = `Use this command to validate the contents of a package using the package specification (see: https://github.com/elastic/package-spec).
Expand Down
1 change: 1 addition & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ var commands = []*cobraext.Command{
setupPublishCommand(),
setupReportsCommand(),
setupServiceCommand(),
setupShellCommand(),
setupStackCommand(),
setupStatusCommand(),
setupTestCommand(),
Expand Down
2 changes: 1 addition & 1 deletion cmd/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/service"
"github.com/elastic/elastic-package/internal/stack"
"github.com/elastic/elastic-package/internal/testrunner/runners/system"
"github.com/elastic/elastic-package/pkg/packages"
)

const serviceLongDescription = `Use this command to boot up the service stack that can be observed with the package.
Expand Down
29 changes: 29 additions & 0 deletions cmd/shell.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
// or more contributor license agreements. Licensed under the Elastic License;
// you may not use this file except in compliance with the Elastic License.

package cmd

import (
cshell "github.com/brianstrauch/cobra-shell"
"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/pkg/shell"
)

func setupShellCommand() *cobraext.Command {
cmd := &cobra.Command{
Use: "shell",
Hidden: true,
SilenceUsage: true,
}
cmd.CompletionOptions.DisableDefaultCmd = true
cmd.CompletionOptions.HiddenDefaultCmd = true

shell.AttachCommands(cmd)

shellCmd := cshell.New(cmd, nil)

return cobraext.NewCommand(shellCmd, cobraext.ContextGlobal)
}
6 changes: 3 additions & 3 deletions cmd/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ import (
"github.com/spf13/cobra"

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/changelog"
"github.com/elastic/elastic-package/internal/packages/status"
"github.com/elastic/elastic-package/internal/registry"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/changelog"
"github.com/elastic/elastic-package/pkg/packages/status"
)

const statusLongDescription = `Use this command to display the current deployment status of a package.
Expand Down
6 changes: 3 additions & 3 deletions cmd/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/changelog"
"github.com/elastic/elastic-package/internal/packages/status"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/changelog"
"github.com/elastic/elastic-package/pkg/packages/status"
)

var generateFlag = flag.Bool("generate", false, "Write golden files")
Expand Down
2 changes: 1 addition & 1 deletion cmd/testrunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ import (
"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/common"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/signal"
"github.com/elastic/elastic-package/internal/stack"
"github.com/elastic/elastic-package/internal/testrunner"
"github.com/elastic/elastic-package/internal/testrunner/reporters/formats"
"github.com/elastic/elastic-package/internal/testrunner/reporters/outputs"
_ "github.com/elastic/elastic-package/internal/testrunner/runners" // register all test runners
"github.com/elastic/elastic-package/pkg/packages"
)

const testLongDescription = `Use this command to run tests on a package. Currently, the following types of tests are available:
Expand Down
4 changes: 2 additions & 2 deletions cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ import (

"github.com/elastic/elastic-package/internal/cobraext"
"github.com/elastic/elastic-package/internal/install"
"github.com/elastic/elastic-package/internal/packages"
"github.com/elastic/elastic-package/internal/packages/installer"
"github.com/elastic/elastic-package/internal/stack"
"github.com/elastic/elastic-package/pkg/packages"
"github.com/elastic/elastic-package/pkg/packages/installer"
)

const uninstallLongDescription = `Use this command to uninstall the package in Kibana.
Expand Down
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/ProtonMail/gopenpgp/v2 v2.7.3
github.com/aymerick/raymond v2.0.2+incompatible
github.com/boumenot/gocover-cobertura v1.2.0
github.com/brianstrauch/cobra-shell v0.4.0
github.com/cbroglie/mustache v1.4.0
github.com/cespare/xxhash/v2 v2.2.0
github.com/dustin/go-humanize v1.0.1
Expand All @@ -24,6 +25,7 @@ require (
github.com/google/go-github/v32 v32.1.0
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.3.1
github.com/hashicorp/go-plugin v1.5.0
github.com/jedib0t/go-pretty v4.3.0+incompatible
github.com/magefile/mage v1.15.0
github.com/mholt/archiver/v3 v3.5.1
Expand Down Expand Up @@ -59,6 +61,7 @@ require (
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/bitfield/gotestdox v0.2.1 // indirect
github.com/c-bata/go-prompt v0.2.6 // indirect
github.com/chai2010/gettext-go v1.0.2 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/creasty/defaults v1.7.0 // indirect
Expand Down Expand Up @@ -93,7 +96,9 @@ require (
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect
github.com/gregjones/httpcache v0.0.0-20190611155906-901d90724c79 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-hclog v0.14.1 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
Expand All @@ -112,8 +117,10 @@ require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-tty v0.0.3 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
Expand All @@ -124,11 +131,13 @@ require (
github.com/monochromegane/go-gitignore v0.0.0-20200626010858-205db1a8cc00 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/nwaples/rardecode v1.1.3 // indirect
github.com/oklog/run v1.0.0 // indirect
github.com/oklog/ulid v1.3.1 // indirect
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
github.com/pierrec/lz4/v4 v4.1.17 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pkg/term v1.2.0-beta.2 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down Expand Up @@ -162,6 +171,8 @@ require (
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect
google.golang.org/grpc v1.54.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading