4
4
"fmt"
5
5
"strings"
6
6
"time"
7
-
8
- "github.com/Azure/go-autorest/autorest/date"
9
7
)
10
8
11
9
type (
@@ -14,9 +12,21 @@ type (
14
12
secret string
15
13
creationTime * time.Time
16
14
expirationTime * time.Time
15
+
16
+ annotations map [string ]string
17
17
}
18
18
)
19
19
20
+ func NewBootstrapToken (id , secret string ) * BootstrapToken {
21
+ token := BootstrapToken {
22
+ id : id ,
23
+ secret : secret ,
24
+ annotations : make (map [string ]string ),
25
+ }
26
+
27
+ return & token
28
+ }
29
+
20
30
func (t * BootstrapToken ) Id () string {
21
31
return t .id
22
32
}
@@ -33,11 +43,6 @@ func (t *BootstrapToken) SetExpirationTime(val time.Time) {
33
43
t .expirationTime = & val
34
44
}
35
45
36
- func (t * BootstrapToken ) SetExpirationUnixTime (val date.UnixTime ) {
37
- expirationTime := date .UnixEpoch ().Add (val .Duration ())
38
- t .expirationTime = & expirationTime
39
- }
40
-
41
46
func (t * BootstrapToken ) ExpirationTime () * time.Time {
42
47
return t .expirationTime
43
48
}
@@ -55,52 +60,27 @@ func (t *BootstrapToken) ExpirationString() (expiration string) {
55
60
return
56
61
}
57
62
58
- func (t * BootstrapToken ) ExpirationUnixTime () (val * date.UnixTime ) {
59
- if t .expirationTime != nil {
60
- unixTime := date .NewUnixTimeFromDuration (t .expirationTime .Sub (date .UnixEpoch ()))
61
- val = & unixTime
62
- }
63
- return
64
- }
65
-
66
63
func (t * BootstrapToken ) SetCreationTime (val time.Time ) {
67
64
t .creationTime = & val
68
65
}
69
66
70
- func (t * BootstrapToken ) SetCreationUnixTime (val date.UnixTime ) {
71
- creationTime := date .UnixEpoch ().Add (val .Duration ())
72
- t .creationTime = & creationTime
73
- }
74
-
75
67
func (t * BootstrapToken ) CreationTime () * time.Time {
76
68
return t .creationTime
77
69
}
78
70
79
- func (t * BootstrapToken ) CreationUnixTime () (val * date.UnixTime ) {
80
- if t .creationTime != nil {
81
- unixTime := date .NewUnixTimeFromDuration (t .creationTime .Sub (date .UnixEpoch ()))
82
- val = & unixTime
83
- }
84
- return
85
- }
86
-
87
- func NewBootstrapToken (id , secret string ) * BootstrapToken {
88
- token := BootstrapToken {
89
- id : id ,
90
- secret : secret ,
91
- }
92
- return & token
93
- }
94
-
95
71
func ParseFromString (value string ) * BootstrapToken {
96
72
tokenParts := strings .SplitN (value , "." , 2 )
97
73
if len (tokenParts ) == 2 {
98
- token := BootstrapToken {
99
- id : tokenParts [0 ],
100
- secret : tokenParts [1 ],
101
- }
102
- return & token
74
+ return NewBootstrapToken (tokenParts [0 ], tokenParts [1 ])
103
75
}
104
76
105
77
return nil
106
78
}
79
+
80
+ func (t * BootstrapToken ) SetAnnotation (name , value string ) {
81
+ t .annotations [name ] = value
82
+ }
83
+
84
+ func (t * BootstrapToken ) Annotations () map [string ]string {
85
+ return t .annotations
86
+ }
0 commit comments