summaryrefslogtreecommitdiff
path: root/internal/config/args.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2021-10-02 11:54:07 +0300
committerPaul Buetow <paul@buetow.org>2021-10-02 15:11:23 +0300
commit12c79f68bb5bda6673819d7b754820ecfe6d08ff (patch)
treea779dc77dc8bf5a2dfc2030c718ce4543bfba6c7 /internal/config/args.go
parent6e1af993924bc7bebe898b403962db5a6b3505d1 (diff)
reduce logging in serverless mode
Diffstat (limited to 'internal/config/args.go')
-rw-r--r--internal/config/args.go30
1 files changed, 28 insertions, 2 deletions
diff --git a/internal/config/args.go b/internal/config/args.go
index 484aa8b..3e2eb1f 100644
--- a/internal/config/args.go
+++ b/internal/config/args.go
@@ -1,6 +1,7 @@
package config
import (
+ "encoding/base64"
"fmt"
"strings"
@@ -69,7 +70,32 @@ func (a *Args) String() string {
// SerializeOptions returns a string ready to be sent over the wire to the server.
func (a *Args) SerializeOptions() string {
- return fmt.Sprintf("quiet=%v:spartan=%v", a.Quiet, a.Spartan)
+ return fmt.Sprintf("quiet=%v:spartan=%v:serverless=%v", a.Quiet, a.Spartan, a.Serverless)
}
-// NEXT: Put the DeseializeOptions function here (move it away from the internal/server package)
+// DeserializeOptions deserializes the options, but into a map.
+func DeserializeOptions(opts []string) (map[string]string, error) {
+ options := make(map[string]string, len(opts))
+
+ for _, o := range opts {
+ kv := strings.SplitN(o, "=", 2)
+ if len(kv) != 2 {
+ return options, fmt.Errorf("Unable to parse options: %v", kv)
+ }
+ key := kv[0]
+ val := kv[1]
+
+ if strings.HasPrefix(val, "base64%") {
+ s := strings.SplitN(val, "%", 2)
+ decoded, err := base64.StdEncoding.DecodeString(s[1])
+ if err != nil {
+ return options, err
+ }
+ val = string(decoded)
+ }
+
+ options[key] = val
+ }
+
+ return options, nil
+}