From 74e36f0ead717105f26087c2cab08b41ba5a7ce8 Mon Sep 17 00:00:00 2001 From: jwijenbergh Date: Mon, 12 Feb 2024 19:18:05 +0100 Subject: All: Document everything to pass revive lint --- client/token.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'client/token.go') diff --git a/client/token.go b/client/token.go index d62308b..03ec1d6 100644 --- a/client/token.go +++ b/client/token.go @@ -10,12 +10,17 @@ import ( type cacheMap map[string]eduoauth.Token +// TokenCacher is a structure that caches tokens for each type of server type TokenCacher struct { + // InstituteAccess is the cached map for institute access servers InstituteAccess cacheMap - CustomServer cacheMap - SecureInternet *eduoauth.Token + // CustomServer is the cached map for custom server + CustomServer cacheMap + // SecureInternet is the cached map for the secure internet server + SecureInternet *eduoauth.Token } +// Get gets tokens from the cache map func (c *cacheMap) Get(id string) (*eduoauth.Token, error) { if c == nil || len(*c) == 0 { return nil, errors.New("no cache map available") @@ -26,6 +31,7 @@ func (c *cacheMap) Get(id string) (*eduoauth.Token, error) { return nil, fmt.Errorf("identifier: '%s' does not exist in token cache map", id) } +// Get gets tokens using a server id and type from the cacher func (tc *TokenCacher) Get(id string, t srvtypes.Type) (*eduoauth.Token, error) { switch t { case srvtypes.TypeCustom: @@ -41,6 +47,7 @@ func (tc *TokenCacher) Get(id string, t srvtypes.Type) (*eduoauth.Token, error) return nil, fmt.Errorf("invalid type for token cacher get: %d", t) } +// Set updates the cache for the server id `id` with tokens `t` func (c *cacheMap) Set(id string, t eduoauth.Token) { if c == nil || len(*c) == 0 { *c = make(cacheMap) @@ -48,6 +55,7 @@ func (c *cacheMap) Set(id string, t eduoauth.Token) { (*c)[id] = t } +// Set updates the top-level cacher for a specific server type func (tc *TokenCacher) Set(id string, t srvtypes.Type, tok eduoauth.Token) error { switch t { case srvtypes.TypeCustom: -- cgit v1.2.3