44 "fmt"
55 "strings"
66 "time"
7-
8- "github.com/Azure/go-autorest/autorest/date"
97)
108
119type (
@@ -14,9 +12,21 @@ type (
1412 secret string
1513 creationTime * time.Time
1614 expirationTime * time.Time
15+
16+ annotations map [string ]string
1717 }
1818)
1919
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+
2030func (t * BootstrapToken ) Id () string {
2131 return t .id
2232}
@@ -33,11 +43,6 @@ func (t *BootstrapToken) SetExpirationTime(val time.Time) {
3343 t .expirationTime = & val
3444}
3545
36- func (t * BootstrapToken ) SetExpirationUnixTime (val date.UnixTime ) {
37- expirationTime := date .UnixEpoch ().Add (val .Duration ())
38- t .expirationTime = & expirationTime
39- }
40-
4146func (t * BootstrapToken ) ExpirationTime () * time.Time {
4247 return t .expirationTime
4348}
@@ -55,52 +60,27 @@ func (t *BootstrapToken) ExpirationString() (expiration string) {
5560 return
5661}
5762
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-
6663func (t * BootstrapToken ) SetCreationTime (val time.Time ) {
6764 t .creationTime = & val
6865}
6966
70- func (t * BootstrapToken ) SetCreationUnixTime (val date.UnixTime ) {
71- creationTime := date .UnixEpoch ().Add (val .Duration ())
72- t .creationTime = & creationTime
73- }
74-
7567func (t * BootstrapToken ) CreationTime () * time.Time {
7668 return t .creationTime
7769}
7870
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-
9571func ParseFromString (value string ) * BootstrapToken {
9672 tokenParts := strings .SplitN (value , "." , 2 )
9773 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 ])
10375 }
10476
10577 return nil
10678}
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