@@ -243,6 +243,7 @@ func NewAPIC(ctx context.Context, config *csconfig.OnlineApiClientCfg, dbClient
243
243
}
244
244
245
245
err = ret .Authenticate (ctx , config )
246
+
246
247
return ret , err
247
248
}
248
249
@@ -260,13 +261,14 @@ func loadAPICToken(ctx context.Context, db *database.Client) (string, time.Time,
260
261
return "" , time.Time {}, false
261
262
}
262
263
263
- if token == nil {
264
+ if token == "" {
264
265
log .Debug ("no token found in DB" )
265
266
return "" , time.Time {}, false
266
267
}
267
268
268
269
parser := new (jwt.Parser )
269
- tok , _ , err := parser .ParseUnverified (* token , jwt.MapClaims {})
270
+
271
+ tok , _ , err := parser .ParseUnverified (token , jwt.MapClaims {})
270
272
if err != nil {
271
273
log .Debugf ("error parsing token: %s" , err )
272
274
return "" , time.Time {}, false
@@ -285,12 +287,12 @@ func loadAPICToken(ctx context.Context, db *database.Client) (string, time.Time,
285
287
}
286
288
287
289
exp := time .Unix (int64 (expFloat ), 0 )
288
- if time .Now ().UTC ().After (exp .Add (- 1 * time .Minute )) {
290
+ if time .Now ().UTC ().After (exp .Add (- 1 * time .Minute )) {
289
291
log .Debug ("auth token expired" )
290
292
return "" , time.Time {}, false
291
293
}
292
294
293
- return * token , exp , true
295
+ return token , exp , true
294
296
}
295
297
296
298
// saveAPICToken stores the given JWT token in the local database under the "apic_token" config item.
@@ -310,6 +312,7 @@ func saveAPICToken(ctx context.Context, db *database.Client, token string) error
310
312
func (a * apic ) Authenticate (ctx context.Context , config * csconfig.OnlineApiClientCfg ) error {
311
313
if token , exp , valid := loadAPICToken (ctx , a .dbClient ); valid {
312
314
log .Debug ("using valid token from DB" )
315
+
313
316
a .apiClient .GetClient ().Transport .(* apiclient.JWTTransport ).Token = token
314
317
a .apiClient .GetClient ().Transport .(* apiclient.JWTTransport ).Expiration = exp
315
318
}
@@ -1043,7 +1046,7 @@ func (a *apic) updateBlocklist(ctx context.Context, client *apiclient.ApiClient,
1043
1046
blocklistConfigItemName := fmt .Sprintf ("blocklist:%s:last_pull" , * blocklist .Name )
1044
1047
1045
1048
var (
1046
- lastPullTimestamp * string
1049
+ lastPullTimestamp string
1047
1050
err error
1048
1051
)
1049
1052
@@ -1060,10 +1063,10 @@ func (a *apic) updateBlocklist(ctx context.Context, client *apiclient.ApiClient,
1060
1063
}
1061
1064
1062
1065
if ! hasChanged {
1063
- if lastPullTimestamp == nil {
1066
+ if lastPullTimestamp == "" {
1064
1067
log .Infof ("blocklist %s hasn't been modified or there was an error reading it, skipping" , * blocklist .Name )
1065
1068
} else {
1066
- log .Infof ("blocklist %s hasn't been modified since %s, skipping" , * blocklist .Name , * lastPullTimestamp )
1069
+ log .Infof ("blocklist %s hasn't been modified since %s, skipping" , * blocklist .Name , lastPullTimestamp )
1067
1070
}
1068
1071
1069
1072
return nil
0 commit comments