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
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/base64"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -15,10 +16,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{}
|
||||||
pluginArgs []string
|
|
||||||
pluginKWArgs kwargs.KWArgs = kwargs.KWArgs{}
|
|
||||||
)
|
|
||||||
var downloadCmd = cobra.Command{
|
var downloadCmd = cobra.Command{
|
||||||
Use: "download",
|
Use: "download",
|
||||||
Example: `
|
Example: `
|
||||||
|
|
@ -52,6 +50,7 @@ var downloadCmd = cobra.Command{
|
||||||
configPath, _ = cmd.Flags().GetString("config")
|
configPath, _ = cmd.Flags().GetString("config")
|
||||||
cacertPath, _ = cmd.Flags().GetString("cacert")
|
cacertPath, _ = cmd.Flags().GetString("cacert")
|
||||||
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
||||||
|
pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args")
|
||||||
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
||||||
extract, _ = cmd.Flags().GetBool("extract")
|
extract, _ = cmd.Flags().GetBool("extract")
|
||||||
removeArchive, _ = cmd.Flags().GetBool("remove-archive")
|
removeArchive, _ = cmd.Flags().GetBool("remove-archive")
|
||||||
|
|
@ -75,7 +74,7 @@ var downloadCmd = cobra.Command{
|
||||||
query += "&args=" + url.QueryEscape(strings.Join(pluginArgs, ","))
|
query += "&args=" + url.QueryEscape(strings.Join(pluginArgs, ","))
|
||||||
}
|
}
|
||||||
if len(pluginKWArgs) > 0 {
|
if len(pluginKWArgs) > 0 {
|
||||||
query += "&kwargs=" + url.QueryEscape(pluginKWArgs.String())
|
query += "&kwargs=" + base64.RawURLEncoding.EncodeToString(pluginKWArgs.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug().
|
log.Debug().
|
||||||
|
|
@ -86,6 +85,8 @@ var downloadCmd = cobra.Command{
|
||||||
Str("output", outputPath).
|
Str("output", outputPath).
|
||||||
Strs("profiles", profileIDs).
|
Strs("profiles", profileIDs).
|
||||||
Strs("plugins", pluginNames).
|
Strs("plugins", pluginNames).
|
||||||
|
Strs("args", pluginArgs).
|
||||||
|
Any("kwargs", pluginKWArgs).
|
||||||
Send()
|
Send()
|
||||||
|
|
||||||
if cacertPath != "" {
|
if cacertPath != "" {
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ var runCmd = &cobra.Command{
|
||||||
keyfile, _ = cmd.Flags().GetString("keyfile")
|
keyfile, _ = cmd.Flags().GetString("keyfile")
|
||||||
timeout, _ = cmd.Flags().GetInt("timeout")
|
timeout, _ = cmd.Flags().GetInt("timeout")
|
||||||
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
pluginNames, _ = cmd.Flags().GetStringSlice("plugins")
|
||||||
|
pluginArgs, _ = cmd.Flags().GetStringSlice("plugin-args")
|
||||||
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
profileIDs, _ = cmd.Flags().GetStringSlice("profiles")
|
||||||
extract, _ = cmd.Flags().GetBool("extract")
|
extract, _ = cmd.Flags().GetBool("extract")
|
||||||
removeArchive, _ = cmd.Flags().GetBool("remove-archive")
|
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("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().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().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("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)")
|
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")
|
serveCmd.MarkFlagsRequiredTogether("cacert", "keyfile")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue