readCache reads the cached API key from credstore.
(helperCmd string)
| 36 | |
| 37 | // readCache reads the cached API key from credstore. |
| 38 | func readCache(helperCmd string) (*apiKeyCache, error) { |
| 39 | key := helperCacheKey(helperCmd) |
| 40 | val, err := GetCredential(key) |
| 41 | if err != nil { |
| 42 | return nil, err |
| 43 | } |
| 44 | if val == "" { |
| 45 | return nil, nil //nolint:nilnil // nil cache indicates cache miss, not an error |
| 46 | } |
| 47 | |
| 48 | var cache apiKeyCache |
| 49 | if err := json.Unmarshal([]byte(val), &cache); err != nil { |
| 50 | return nil, err |
| 51 | } |
| 52 | |
| 53 | return &cache, nil |
| 54 | } |
| 55 | |
| 56 | // writeCache writes the API key cache to credstore. |
| 57 | func writeCache(helperCmd, apiKey string) error { |
no test coverage detected