MCPcopy
hub / github.com/minio/minio-go / SetExpiration

Method SetExpiration

pkg/credentials/credentials.go:119–129  ·  view source on GitHub ↗

SetExpiration sets the expiration IsExpired will check when called. If window is greater than 0 the expiration time will be reduced by the window value. Using a window is helpful to trigger credentials to expire sooner than the expiration time given to ensure no requests are made with expired toke

(expiration time.Time, window time.Duration)

Source from the content-addressed store, hash-verified

117// the expiration time given to ensure no requests are made with expired
118// tokens.
119func (e *Expiry) SetExpiration(expiration time.Time, window time.Duration) {
120 if e.CurrentTime == nil {
121 e.CurrentTime = time.Now
122 }
123 cut := window
124 if cut < 0 {
125 expireIn := expiration.Sub(e.CurrentTime())
126 cut = time.Duration(float64(expireIn) * (1 - defaultExpiryWindow))
127 }
128 e.expiration = expiration.Add(-cut)
129}
130
131// IsExpired returns if the credentials are expired.
132func (e *Expiry) IsExpired() bool {

Callers 8

retrieveMethod · 0.80

Calls 1

AddMethod · 0.45

Tested by

no test coverage detected