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

Method optionalSeconds

internal/config/refreshable.go:287–300  ·  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

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