Move workflow to its own package

This causes the workflow command to have the same capabilities and
restrictions as any other plugin.
This commit is contained in:
Ian Howell 2019-05-21 10:16:33 -05:00
parent 09f1995485
commit 3329e193d0
5 changed files with 12 additions and 20 deletions

View File

@ -3,18 +3,15 @@ package cmd
import (
"io"
// "github.com/ian-howell/exampleplugin"
"github.com/spf13/cobra"
"github.com/ian-howell/airshipctl/cmd/workflow"
// "github.com/ian-howell/exampleplugin"
)
// builtinPlugins are the plugins that are built and maintained by the
// airshipctl team. They may be disabled if desired
var builtinPlugins = []func(io.Writer, []string) *cobra.Command{
NewWorkflowCommand,
}
// externalPlugins are external. The function to create a command should be
// placed here
var externalPlugins = []func(io.Writer, []string) *cobra.Command{
// pluginCommands are the functions that create the entrypoint command for a plugin
var pluginCommands = []func(io.Writer, []string) *cobra.Command{
// exampleplugin.NewExampleCommand, // This is an example and shouldn't be enabled in production builds
workflow.NewWorkflowCommand,
}

View File

@ -47,14 +47,9 @@ func Execute(out io.Writer) {
}
}
// loadPluginCommands finds all of the plugins in the builtinPlugins and
// externalPlugins datastructures, and loads them as subcommands to cmd
// loadPluginCommands loads all of the plugins as subcommands to cmd
func loadPluginCommands(cmd *cobra.Command, out io.Writer, args []string) {
for _, subcmd := range builtinPlugins {
cmd.AddCommand(subcmd(out, args))
}
for _, subcmd := range externalPlugins {
for _, subcmd := range pluginCommands {
cmd.AddCommand(subcmd(out, args))
}
}

View File

@ -1,4 +1,4 @@
package cmd
package workflow
import (
"io"

View File

@ -1,4 +1,4 @@
package cmd
package workflow
import (
"fmt"

View File

@ -1,4 +1,4 @@
package cmd
package workflow
import (
"fmt"