MCPcopy Create free account
hub / github.com/cli/cli / optionalSeconds

Method optionalSeconds

internal/config/refreshable.go:288–301  ·  view source on GitHub ↗

optionalSeconds reads a raw lifetime in seconds (an ExpiresIn field) from config, returning 0 when the key is absent so a credential without the value is still valid.

(path []string)

Source from the content-addressed store, hash-verified

286// optionalSeconds reads a raw lifetime in seconds (an ExpiresIn field) from config, returning 0 when the key is absent
287// so a credential without the value is still valid.
288func (c *AuthConfig) optionalSeconds(path []string) (int, error) {
289 value, err := c.cfg.Get(path)
290 if isKeyNotFound(err) {
291 return 0, nil
292 }
293 if err != nil {
294 return 0, err
295 }
296 seconds, err := strconv.Atoi(value)
297 if err != nil {
298 return 0, errors.New("invalid refreshable credential expiration seconds")
299 }
300 return seconds, nil
301}
302
303func (c *AuthConfig) optionalTimestamp(path []string) (*time.Time, error) {
304 value, err := c.cfg.Get(path)

Callers 1

refreshableFromConfigMethod · 0.95

Calls 2

isKeyNotFoundFunction · 0.85
GetMethod · 0.65

Tested by

no test coverage detected