MCPcopy Create free account
hub / github.com/conforma/cli / setExpiration

Method setExpiration

internal/tracker/tracker.go:305–321  ·  view source on GitHub ↗

setExpiration sets the expires_on attribute on records using a duration-based approach. Each record expires after a configurable duration based on inEffectDays from when it's added. The most recent record (index 0) gets no expiration date, making it the current active record.

(inEffectDays int)

Source from the content-addressed store, hash-verified

303// Each record expires after a configurable duration based on inEffectDays from when it's added.
304// The most recent record (index 0) gets no expiration date, making it the current active record.
305func (t *Tracker) setExpiration(inEffectDays int) {
306 expirationDuration := time.Duration(inEffectDays) * oneDay // Use --in-effect-days flag value
307 now := time.Now().UTC().Round(oneDay)
308
309 for _, records := range t.TrustedTasks {
310 for i := range records {
311 if i == 0 {
312 // Most recent record doesn't expire
313 records[i].ExpiresOn = nil
314 } else if records[i].ExpiresOn == nil {
315 // Add expires_on to any record that doesn't have one already
316 expiresOn := now.Add(expirationDuration)
317 records[i].ExpiresOn = &expiresOn
318 }
319 }
320 }
321}
322
323// ociRefFromGroup returns the OCI image reference from the given group, e.g.
324// oci://registry.local/spam:latest -> registry.local/spam:latest

Callers 2

TestSetExpirationFunction · 0.95
TrackFunction · 0.80

Calls

no outgoing calls

Tested by 1

TestSetExpirationFunction · 0.76