MCPcopy
hub / github.com/NVIDIA/aistore / LoadToken

Function LoadToken

api/authn/loadtoken.go:18–37  ·  view source on GitHub ↗

NOTE: must load when tokenFile != ""

(tokenFile string)

Source from the content-addressed store, hash-verified

16
17// NOTE: must load when tokenFile != ""
18func LoadToken(tokenFile string) string {
19 var (
20 token TokenMsg
21 mustLoad = true
22 )
23 if tokenFile == "" {
24 tokenFile = os.Getenv(env.AuthN.TokenFile)
25 }
26 if tokenFile == "" {
27 // when generated via CLI (and without the `-f` option) - the location:
28 // $HOME/.config/ais/cli/<fname.Token>
29 tokenFile = filepath.Join(cos.HomeConfigDir(fname.HomeCLI), fname.Token)
30 mustLoad = false
31 }
32 _, err := jsp.LoadMeta(tokenFile, &token)
33 if err != nil && (mustLoad || !os.IsNotExist(err)) {
34 cos.Errorf("Failed to load token %q: %v", tokenFile, err)
35 }
36 return token.Token
37}

Callers 3

initClusterParamsFunction · 0.92
StartFunction · 0.92
InitClusterFunction · 0.92

Calls 4

HomeConfigDirFunction · 0.92
LoadMetaFunction · 0.92
ErrorfFunction · 0.92
JoinMethod · 0.80

Tested by

no test coverage detected