...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package signature
17
18 import (
19 _ "crypto/sha256"
20 "fmt"
21 "strings"
22 )
23
24 type AnnotationsMap struct {
25 Annotations map[string]interface{}
26 }
27
28 func (a *AnnotationsMap) Set(s string) error {
29 if a.Annotations == nil {
30 a.Annotations = map[string]interface{}{}
31 }
32 kvp := strings.SplitN(s, "=", 2)
33 if len(kvp) != 2 {
34 return fmt.Errorf("invalid flag: %s, expected key=value", s)
35 }
36
37 a.Annotations[kvp[0]] = kvp[1]
38 return nil
39 }
40
41 func (a *AnnotationsMap) String() string {
42 s := []string{}
43 for k, v := range a.Annotations {
44 s = append(s, fmt.Sprintf("%s=%s", k, v))
45 }
46 return strings.Join(s, ",")
47 }
48
View as plain text