diff --git a/cmd/cli.go b/cmd/cli.go index 7225d3e..dc74bf3 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -52,6 +52,7 @@ func NewCLI(version, commitHash, builtAt string) *CLI { c.addVersionCmd() c.addListCmd() c.addGenPluginCmd() + c.addInstallCmd() return c } diff --git a/cmd/generate-plugin.go b/cmd/generate-plugin.go index a8d749c..0ea3e11 100644 --- a/cmd/generate-plugin.go +++ b/cmd/generate-plugin.go @@ -33,9 +33,9 @@ func (c *CLI) addGenPluginCmd() { } func (c *CLI) generatePlugin() error { - cfg, err := command.SetupTemplatingEnvironment(c.logger) + templatesDir, sourcePath, outputDir, serviceName, err := command.SetupTemplatingEnvironment(c.logger) if err != nil { return err } - return command.GeneratePlugin(c.logger, cfg) + return command.GeneratePlugin(c.logger, templatesDir, sourcePath, outputDir, serviceName) } diff --git a/cmd/install.go b/cmd/install.go new file mode 100644 index 0000000..04af2c5 --- /dev/null +++ b/cmd/install.go @@ -0,0 +1,22 @@ +package cmd + +import ( + "github.com/spf13/cobra" + + "github.com/privateerproj/privateer-sdk/command" +) + +func (c *CLI) addInstallCmd() { + installCmd := &cobra.Command{ + Use: "install [plugin-name]", + Short: "Install a vetted plugin from the registry.", + Long: "Resolve the plugin name to registry metadata, then download the plugin binary from the release URL into the binaries path.", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) error { + sdkInstall := command.GetInstallCmd(c.writer) + sdkInstall.SetArgs(args) + return sdkInstall.Execute() + }, + } + c.rootCmd.AddCommand(installCmd) +} diff --git a/cmd/list.go b/cmd/list.go index 8b71833..8405354 100644 --- a/cmd/list.go +++ b/cmd/list.go @@ -1,24 +1,10 @@ package cmd import ( - "github.com/spf13/cobra" - "github.com/spf13/viper" - "github.com/privateerproj/privateer-sdk/command" ) func (c *CLI) addListCmd() { - listCmd := &cobra.Command{ - Use: "list", - Short: "Consult the Charts! List all plugins that have been installed.", - Run: func(cmd *cobra.Command, args []string) { - sdkListCmd := command.GetListCmd(c.writer) - sdkListCmd.Run(cmd, args) - }, - } - - listCmd.PersistentFlags().BoolP("all", "a", false, "Review the Fleet! List all plugins that have been installed or requested in the current config") - _ = viper.BindPFlag("all", listCmd.PersistentFlags().Lookup("all")) - + listCmd := command.GetListCmd(func() command.Writer { return c.writer }) c.rootCmd.AddCommand(listCmd) } diff --git a/go.mod b/go.mod index d0a1380..b57265f 100644 --- a/go.mod +++ b/go.mod @@ -62,7 +62,7 @@ require ( ) // For SDK Development Only -// replace github.com/privateerproj/privateer-sdk => ../privateer-sdk +replace github.com/privateerproj/privateer-sdk => ../privateer-sdk // Use local go-gemara when developing (same as privateer-sdk); replace is not transitive // replace github.com/gemaraproj/go-gemara => ../../gemaraproj/go-gemara diff --git a/go.sum b/go.sum index 63ca4b4..5434424 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,6 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/privateerproj/privateer-sdk v1.22.1 h1:L3aPuEJFoTBfDyk/aF304qaOoZcFhltBI55MAZAycaA= -github.com/privateerproj/privateer-sdk v1.22.1/go.mod h1:Ydgaph696cp8jkVmt6GGIl/4hVpGZ3RzAoF7e8APhmA= github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=