refactor: changed how plugin kwargs are sent and other minor changes
This commit is contained in:
parent
d1e892dd98
commit
47c9d48735
3 changed files with 11 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
|
@ -15,10 +16,7 @@ import (
|
|||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
pluginArgs []string
|
||||
pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{}
|
||||
)
|
||||
var pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{}
|
||||
var downloadCmd = cobra.Command{
|
||||
Use: "download",
|
||||
Example: `
|
||||
|
|
@ -52,6 +50,7 @@ var downloadCmd = cobra.Command{
|
|||
configPath, _ = cmd.Flags().GetString("config")
|
||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
||||
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
||||
pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args")
|
||||
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
||||
extract, _ = cmd.Flags().GetBool("extract")
|
||||
removeArchive, _ = cmd.Flags().GetBool("remove-archive")
|
||||
|
|
@ -75,7 +74,7 @@ var downloadCmd = cobra.Command{
|
|||
query += "&args=" + url.QueryEscape(strings.Join(pluginArgs, ","))
|
||||
}
|
||||
if len(pluginKWArgs) > 0 {
|
||||
query += "&kwargs=" + url.QueryEscape(pluginKWArgs.String())
|
||||
query += "&kwargs=" + base64.RawURLEncoding.EncodeToString(pluginKWArgs.Bytes())
|
||||
}
|
||||
|
||||
log.Debug().
|
||||
|
|
@ -86,6 +85,8 @@ var downloadCmd = cobra.Command{
|
|||
Str("output", outputPath).
|
||||
Strs("profiles", profileIDs).
|
||||
Strs("plugins", pluginNames).
|
||||
Strs("args", pluginArgs).
|
||||
Any("kwargs", pluginKWArgs).
|
||||
Send()
|
||||
|
||||
if cacertPath != "" {
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ var runCmd = &cobra.Command{
|
|||
keyfile, _ = cmd.Flags().GetString("keyfile")
|
||||
timeout, _ = cmd.Flags().GetInt("timeout")
|
||||
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
||||
pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args")
|
||||
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
||||
extract, _ = cmd.Flags().GetBool("extract")
|
||||
removeArchive, _ = cmd.Flags().GetBool("remove-archive")
|
||||
|
|
|
|||
|
|
@ -94,8 +94,10 @@ func init() {
|
|||
serveCmd.Flags().String("host", "localhost:5050", "Set the configurator server host (can be set with MAKESHIFT_HOST)")
|
||||
serveCmd.Flags().String("root", "./", "Set the root path to serve files (can be set with MAKESHIFT_ROOT)")
|
||||
serveCmd.Flags().IntP("timeout", "t", 60, "Set the timeout in seconds for requests (can be set with MAKESHIFT_TIMEOUT)")
|
||||
serveCmd.Flags().String("cacert", "", "Set the CA certificate path to load (can be set with MAKESHIFT_CACERT)")
|
||||
serveCmd.Flags().String("keyfile", "", "Set the CA key file to use (can be set with MAKESHIFT_KEYFILE)")
|
||||
serveCmd.Flags().String("cacert", "", "Set the CA certificate path to load (can be set with MAKESHIFT_CACERT, only used if set with '--keyfile' flag)")
|
||||
serveCmd.Flags().String("keyfile", "", "Set the CA key file to use (can be set with MAKESHIFT_KEYFILE, only used if set with '--cacert' flag)")
|
||||
serveCmd.Flags().String("keyurl", "", "Set the JWKS remote host for JWT verification")
|
||||
serveCmd.Flags().StringSlice("protect-routes", []string{}, "Set the routes to require authentication (uses default routes if not set with '--keyurl' flag)")
|
||||
|
||||
serveCmd.MarkFlagsRequiredTogether("cacert", "keyfile")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue