Skip to content

Commit 92f47d5

Browse files
committed
Change the string representation of effects to be JSON.
1 parent 3f707e1 commit 92f47d5

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

payload/payload.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package payload
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"strings"
67
"testing"
@@ -181,12 +182,18 @@ var (
181182

182183
// String representation of the supported payload types.
183184
func (s Supported) String() string {
184-
a := []string{}
185-
for effect := range s.Effects {
186-
a = append(a, fmt.Sprintf("(%s: %s)", effect.String(), strings.Join(s.Effects[effect], ", ")))
185+
tostr := map[string][]string{}
186+
for effect, details := range s.Effects {
187+
tostr[effect.String()] = details
187188
}
189+
a, err := json.Marshal(tostr)
190+
if err != nil {
191+
output.PrintfFrameworkError("Could not marshal payload effects: %s", err.Error())
188192

189-
return fmt.Sprintf("%s (%s): Effects - %s", s.Type.String(), s.Arch.String(), strings.Join(a, ", "))
193+
return ""
194+
}
195+
196+
return fmt.Sprintf("%s (%s) - Effects: %s", s.Type.String(), s.Arch.String(), a)
190197
}
191198

192199
// String representation of the payload supported architecture.
@@ -447,14 +454,9 @@ func (e Effect) String() string {
447454
return "Unknown"
448455
case maxKey:
449456
return "Unknown"
450-
}
457+
default:
458+
output.PrintFrameworkError("Effect is not recognized.")
451459

452-
var n []string
453-
for key := FileCreate; key < maxKey; key <<= 1 {
454-
if e&key != 0 {
455-
n = append(n, e.String())
456-
}
460+
return ""
457461
}
458-
459-
return strings.Join(n, "|")
460462
}

0 commit comments

Comments
 (0)