Documentation ¶
Index ¶
- Constants
- func Errorf(format string, a ...interface{}) error
- func ExpectedExpiryTime(modTime time.Time, days int) time.Time
- type Action
- type And
- type Error
- type Event
- type Expiration
- func (e Expiration) IsDateNull() bool
- func (e Expiration) IsDaysNull() bool
- func (e Expiration) IsNull() bool
- func (e Expiration) MarshalXML(enc *xml.Encoder, startElement xml.StartElement) error
- func (e *Expiration) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
- func (e Expiration) Validate() error
- type ExpirationDate
- type ExpirationDays
- type ExpireDeleteMarker
- type Filter
- type Lifecycle
- func (lc Lifecycle) ComputeAction(obj ObjectOpts) Action
- func (lc Lifecycle) Eval(obj ObjectOpts, now time.Time) Event
- func (lc Lifecycle) FilterRules(obj ObjectOpts) []Rule
- func (lc Lifecycle) HasActiveRules(prefix string, recursive bool) bool
- func (lc Lifecycle) HasTransition() bool
- func (lc Lifecycle) NoncurrentVersionsExpirationLimit(obj ObjectOpts) (string, int, int)
- func (lc Lifecycle) SetPredictionHeaders(w http.ResponseWriter, obj ObjectOpts)
- func (lc *Lifecycle) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error)
- func (lc Lifecycle) Validate() error
- type NoncurrentVersionExpiration
- func (n NoncurrentVersionExpiration) IsDaysNull() bool
- func (n NoncurrentVersionExpiration) IsNull() bool
- func (n NoncurrentVersionExpiration) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (n *NoncurrentVersionExpiration) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
- func (n NoncurrentVersionExpiration) Validate() error
- type NoncurrentVersionTransition
- func (n NoncurrentVersionTransition) IsNull() bool
- func (n NoncurrentVersionTransition) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (n NoncurrentVersionTransition) NextDue(obj ObjectOpts) (time.Time, bool)
- func (n *NoncurrentVersionTransition) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
- func (n NoncurrentVersionTransition) Validate() error
- type ObjectOpts
- type Prefix
- type Rule
- type Status
- type Tag
- type Transition
- func (t Transition) IsDateNull() bool
- func (t Transition) IsEnabled() bool
- func (t Transition) IsNull() bool
- func (t Transition) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
- func (t Transition) NextDue(obj ObjectOpts) (time.Time, bool)
- func (t *Transition) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
- func (t Transition) Validate() error
- type TransitionDate
- type TransitionDays
Constants ¶
const ( // TransitionComplete marks completed transition TransitionComplete = "complete" // TransitionPending - transition is yet to be attempted TransitionPending = "pending" )
Variables ¶
This section is empty.
Functions ¶
func Errorf ¶
Errorf - formats according to a format specifier and returns the string as a value that satisfies error of type tagging.Error
func ExpectedExpiryTime ¶
ExpectedExpiryTime calculates the expiry, transition or restore date/time based on a object modtime. The expected transition or restore time is always a midnight time following the object modification time plus the number of transition/restore days.
e.g. If the object modtime is `Thu May 21 13:42:50 GMT 2020` and the object should transition in 1 day, then the expected transition time is `Fri, 23 May 2020 00:00:00 GMT`
Types ¶
type Action ¶
type Action int
Action represents a delete action or other transition actions that will be implemented later.
const ( // NoneAction means no action required after evaluating lifecycle rules NoneAction Action = iota // DeleteAction means the object needs to be removed after evaluating lifecycle rules DeleteAction // DeleteVersionAction deletes a particular version DeleteVersionAction // TransitionAction transitions a particular object after evaluating lifecycle transition rules TransitionAction // TransitionVersionAction transitions a particular object version after evaluating lifecycle transition rules TransitionVersionAction // DeleteRestoredAction means the temporarily restored object needs to be removed after evaluating lifecycle rules DeleteRestoredAction // DeleteRestoredVersionAction deletes a particular version that was temporarily restored DeleteRestoredVersionAction // ActionCount must be the last action and shouldn't be used as a regular action. ActionCount )
type And ¶
type And struct { XMLName xml.Name `xml:"And"` Prefix Prefix `xml:"Prefix,omitempty"` Tags []Tag `xml:"Tag,omitempty"` }
And - a tag to combine a prefix and multiple tags for lifecycle configuration rule.
func (And) ContainsDuplicateTag ¶
ContainsDuplicateTag - returns true if duplicate keys are present in And
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is the generic type for any error happening during tag parsing.
type Expiration ¶
type Expiration struct { XMLName xml.Name `xml:"Expiration"` Days ExpirationDays `xml:"Days,omitempty"` Date ExpirationDate `xml:"Date,omitempty"` DeleteMarker ExpireDeleteMarker `xml:"ExpiredObjectDeleteMarker"` // contains filtered or unexported fields }
Expiration - expiration actions for a rule in lifecycle configuration.
func (Expiration) IsDateNull ¶
func (e Expiration) IsDateNull() bool
IsDateNull returns true if date field is null
func (Expiration) IsDaysNull ¶
func (e Expiration) IsDaysNull() bool
IsDaysNull returns true if days field is null
func (Expiration) IsNull ¶
func (e Expiration) IsNull() bool
IsNull returns true if both date and days fields are null
func (Expiration) MarshalXML ¶
func (e Expiration) MarshalXML(enc *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes expiration field into an XML form.
func (*Expiration) UnmarshalXML ¶
func (e *Expiration) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML decodes expiration field from the XML form.
func (Expiration) Validate ¶
func (e Expiration) Validate() error
Validate - validates the "Expiration" element
type ExpirationDate ¶
ExpirationDate is a embedded type containing time.Time to unmarshal Date in Expiration
func (ExpirationDate) MarshalXML ¶
func (eDate ExpirationDate) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes expiration date if it is non-zero and encodes empty string otherwise
func (*ExpirationDate) UnmarshalXML ¶
func (eDate *ExpirationDate) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML parses date from Expiration and validates date format
type ExpirationDays ¶
type ExpirationDays int
ExpirationDays is a type alias to unmarshal Days in Expiration
func (ExpirationDays) MarshalXML ¶
func (eDays ExpirationDays) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes number of days to expire if it is non-zero and encodes empty string otherwise
func (*ExpirationDays) UnmarshalXML ¶
func (eDays *ExpirationDays) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML parses number of days from Expiration and validates if greater than zero
type ExpireDeleteMarker ¶
type ExpireDeleteMarker struct {
// contains filtered or unexported fields
}
ExpireDeleteMarker represents value of ExpiredObjectDeleteMarker field in Expiration XML element.
func (ExpireDeleteMarker) MarshalXML ¶
func (b ExpireDeleteMarker) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes delete marker boolean into an XML form.
func (*ExpireDeleteMarker) UnmarshalXML ¶
func (b *ExpireDeleteMarker) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML decodes delete marker boolean from the XML form.
type Filter ¶
type Filter struct { XMLName xml.Name `xml:"Filter"` Prefix Prefix And And Tag Tag // contains filtered or unexported fields }
Filter - a filter for a lifecycle configuration Rule.
func (Filter) MarshalXML ¶
MarshalXML - produces the xml representation of the Filter struct only one of Prefix, And and Tag should be present in the output.
func (Filter) TestTags ¶
TestTags tests if the object tags satisfy the Filter tags requirement, it returns true if there is no tags in the underlying Filter.
func (*Filter) UnmarshalXML ¶
UnmarshalXML - decodes XML data.
type Lifecycle ¶
Lifecycle - Configuration for bucket lifecycle.
func ParseLifecycleConfig ¶
ParseLifecycleConfig - parses data in given reader to Lifecycle.
func ParseLifecycleConfigWithID ¶
ParseLifecycleConfigWithID - parses for a Lifecycle config and assigns unique id to rules with empty ID.
func (Lifecycle) ComputeAction ¶
func (lc Lifecycle) ComputeAction(obj ObjectOpts) Action
ComputeAction returns the action to perform by evaluating all lifecycle rules against the object name and its modification time.
func (Lifecycle) Eval ¶
func (lc Lifecycle) Eval(obj ObjectOpts, now time.Time) Event
Eval returns the lifecycle event applicable at now. If now is the zero value of time.Time, it returns the upcoming lifecycle event.
func (Lifecycle) FilterRules ¶
func (lc Lifecycle) FilterRules(obj ObjectOpts) []Rule
FilterRules returns the rules filtered by the status, prefix and tags
func (Lifecycle) HasActiveRules ¶
HasActiveRules - returns whether policy has active rules for. Optionally a prefix can be supplied. If recursive is specified the function will also return true if any level below the prefix has active rules. If no prefix is specified recursive is effectively true.
func (Lifecycle) HasTransition ¶
HasTransition returns 'true' if lifecycle document has Transition enabled.
func (Lifecycle) NoncurrentVersionsExpirationLimit ¶
func (lc Lifecycle) NoncurrentVersionsExpirationLimit(obj ObjectOpts) (string, int, int)
NoncurrentVersionsExpirationLimit returns the number of noncurrent versions to be retained from the first applicable rule per S3 behavior.
func (Lifecycle) SetPredictionHeaders ¶
func (lc Lifecycle) SetPredictionHeaders(w http.ResponseWriter, obj ObjectOpts)
SetPredictionHeaders sets time to expiry and transition headers on w for a given obj.
func (*Lifecycle) UnmarshalXML ¶
UnmarshalXML - decodes XML data.
type NoncurrentVersionExpiration ¶
type NoncurrentVersionExpiration struct { XMLName xml.Name `xml:"NoncurrentVersionExpiration"` NoncurrentDays ExpirationDays `xml:"NoncurrentDays,omitempty"` NewerNoncurrentVersions int `xml:"NewerNoncurrentVersions,omitempty"` // contains filtered or unexported fields }
NoncurrentVersionExpiration - an action for lifecycle configuration rule.
func (NoncurrentVersionExpiration) IsDaysNull ¶
func (n NoncurrentVersionExpiration) IsDaysNull() bool
IsDaysNull returns true if days field is null
func (NoncurrentVersionExpiration) IsNull ¶
func (n NoncurrentVersionExpiration) IsNull() bool
IsNull returns if both NoncurrentDays and NoncurrentVersions are empty
func (NoncurrentVersionExpiration) MarshalXML ¶
func (n NoncurrentVersionExpiration) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML if non-current days not set to non zero value
func (*NoncurrentVersionExpiration) UnmarshalXML ¶
func (n *NoncurrentVersionExpiration) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML decodes NoncurrentVersionExpiration
func (NoncurrentVersionExpiration) Validate ¶
func (n NoncurrentVersionExpiration) Validate() error
Validate returns an error with wrong value
type NoncurrentVersionTransition ¶
type NoncurrentVersionTransition struct { NoncurrentDays TransitionDays `xml:"NoncurrentDays"` StorageClass string `xml:"StorageClass"` // contains filtered or unexported fields }
NoncurrentVersionTransition - an action for lifecycle configuration rule.
func (NoncurrentVersionTransition) IsNull ¶
func (n NoncurrentVersionTransition) IsNull() bool
IsNull returns true if NoncurrentTransition doesn't refer to any storage-class. Note: It supports immediate transition, i.e zero noncurrent days.
func (NoncurrentVersionTransition) MarshalXML ¶
func (n NoncurrentVersionTransition) MarshalXML(e *xml.Encoder, start xml.StartElement) error
MarshalXML is extended to leave out <NoncurrentVersionTransition></NoncurrentVersionTransition> tags
func (NoncurrentVersionTransition) NextDue ¶
func (n NoncurrentVersionTransition) NextDue(obj ObjectOpts) (time.Time, bool)
NextDue returns upcoming NoncurrentVersionTransition date for obj if applicable, returns false otherwise.
func (*NoncurrentVersionTransition) UnmarshalXML ¶
func (n *NoncurrentVersionTransition) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML decodes NoncurrentVersionExpiration
func (NoncurrentVersionTransition) Validate ¶
func (n NoncurrentVersionTransition) Validate() error
Validate returns an error with wrong value
type ObjectOpts ¶
type ObjectOpts struct { Name string UserTags string ModTime time.Time VersionID string IsLatest bool DeleteMarker bool NumVersions int SuccessorModTime time.Time TransitionStatus string RestoreOngoing bool RestoreExpires time.Time }
ObjectOpts provides information to deduce the lifecycle actions which can be triggered on the resultant object.
func (ObjectOpts) ExpiredObjectDeleteMarker ¶
func (o ObjectOpts) ExpiredObjectDeleteMarker() bool
ExpiredObjectDeleteMarker returns true if an object version referred to by o is the only version remaining and is a delete marker. It returns false otherwise.
type Prefix ¶
type Prefix struct {
// contains filtered or unexported fields
}
Prefix holds the prefix xml tag in <Rule> and <Filter>
func (Prefix) MarshalXML ¶
MarshalXML - decodes XML data.
func (*Prefix) UnmarshalXML ¶
UnmarshalXML - decodes XML data.
type Rule ¶
type Rule struct { XMLName xml.Name `xml:"Rule"` ID string `xml:"ID,omitempty"` Status Status `xml:"Status"` Filter Filter `xml:"Filter,omitempty"` Prefix Prefix `xml:"Prefix,omitempty"` Expiration Expiration `xml:"Expiration,omitempty"` Transition Transition `xml:"Transition,omitempty"` // FIXME: add a type to catch unsupported AbortIncompleteMultipartUpload AbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"` NoncurrentVersionExpiration NoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"` NoncurrentVersionTransition NoncurrentVersionTransition `xml:"NoncurrentVersionTransition,omitempty"` }
Rule - a rule for lifecycle configuration.
func (Rule) GetPrefix ¶
GetPrefix - a rule can either have prefix under <rule></rule>, <filter></filter> or under <filter><and></and></filter>. This method returns the prefix from the location where it is available.
type Tag ¶
type Tag struct { XMLName xml.Name `xml:"Tag"` Key string `xml:"Key,omitempty"` Value string `xml:"Value,omitempty"` }
Tag - a tag for a lifecycle configuration Rule filter.
func (*Tag) UnmarshalXML ¶
UnmarshalXML - decodes XML data.
type Transition ¶
type Transition struct { XMLName xml.Name `xml:"Transition"` Days TransitionDays `xml:"Days,omitempty"` Date TransitionDate `xml:"Date,omitempty"` StorageClass string `xml:"StorageClass,omitempty"` // contains filtered or unexported fields }
Transition - transition actions for a rule in lifecycle configuration.
func (Transition) IsDateNull ¶
func (t Transition) IsDateNull() bool
IsDateNull returns true if date field is null
func (Transition) IsEnabled ¶
func (t Transition) IsEnabled() bool
IsEnabled returns if transition is enabled.
func (Transition) IsNull ¶
func (t Transition) IsNull() bool
IsNull returns true if both date and days fields are null
func (Transition) MarshalXML ¶
func (t Transition) MarshalXML(enc *xml.Encoder, start xml.StartElement) error
MarshalXML encodes transition field into an XML form.
func (Transition) NextDue ¶
func (t Transition) NextDue(obj ObjectOpts) (time.Time, bool)
NextDue returns upcoming transition date for obj and true if applicable, returns false otherwise.
func (*Transition) UnmarshalXML ¶
func (t *Transition) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML decodes transition field from the XML form.
func (Transition) Validate ¶
func (t Transition) Validate() error
Validate - validates the "Transition" element
type TransitionDate ¶
TransitionDate is a embedded type containing time.Time to unmarshal Date in Transition
func (TransitionDate) MarshalXML ¶
func (tDate TransitionDate) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes expiration date if it is non-zero and encodes empty string otherwise
func (*TransitionDate) UnmarshalXML ¶
func (tDate *TransitionDate) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML parses date from Transition and validates date format
type TransitionDays ¶
type TransitionDays int
TransitionDays is a type alias to unmarshal Days in Transition
func (TransitionDays) MarshalXML ¶
func (tDays TransitionDays) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error
MarshalXML encodes number of days to expire if it is non-zero and encodes empty string otherwise
func (*TransitionDays) UnmarshalXML ¶
func (tDays *TransitionDays) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error
UnmarshalXML parses number of days from Transition and validates if >= 0