Skip to content

Commit b2e1340

Browse files
committed
refactoring and updates
- migrate to new azuresdk - switch to golang 1.24 - add auto GOMAXPROCS and memory limits - switch to zap logging - add annotations Signed-off-by: Markus Blaschke <[email protected]>
1 parent 4a7e7a0 commit b2e1340

File tree

13 files changed

+499
-930
lines changed

13 files changed

+499
-930
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#############################################
22
# Build
33
#############################################
4-
FROM --platform=$BUILDPLATFORM golang:1.19-alpine as build
4+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine as build
55

66
RUN apk upgrade --no-cache --force
77
RUN apk add --update build-base make git

bootstraptoken/token.go

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import (
44
"fmt"
55
"strings"
66
"time"
7-
8-
"github.com/Azure/go-autorest/autorest/date"
97
)
108

119
type (
@@ -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+
2030
func (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-
4146
func (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-
6663
func (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-
7567
func (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-
9571
func 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

Comments
 (0)