mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Rename DelMarkerExpiration to DeletedObjectExpiration
This commit is contained in:
parent
4afb59e63f
commit
da71597e00
@ -1322,7 +1322,7 @@ func applyExpiryOnNonTransitionedObjects(ctx context.Context, objLayer ObjectLay
|
|||||||
case lifecycle.DeleteAllVersionsAction:
|
case lifecycle.DeleteAllVersionsAction:
|
||||||
eventName = event.ObjectRemovedDeleteAllVersions
|
eventName = event.ObjectRemovedDeleteAllVersions
|
||||||
case lifecycle.DelMarkerDeleteAllVersionsAction:
|
case lifecycle.DelMarkerDeleteAllVersionsAction:
|
||||||
eventName = event.ILMDelMarkerExpirationDelete
|
eventName = event.ILMDelObjExpirationDelete
|
||||||
}
|
}
|
||||||
// Notify object deleted event.
|
// Notify object deleted event.
|
||||||
sendEvent(eventArgs{
|
sendEvent(eventArgs{
|
||||||
|
@ -146,7 +146,7 @@ func TestApplyNewerNoncurrentVersionsLimit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEvalActionFromLifecycle(t *testing.T) {
|
func TestEvalActionFromLifecycle(t *testing.T) {
|
||||||
// Tests cover only ExpiredObjectDeleteAllVersions and DelMarkerExpiration actions
|
// Tests cover only ExpiredObjectDeleteAllVersions and DeletedObjectExpiration actions
|
||||||
obj := ObjectInfo{
|
obj := ObjectInfo{
|
||||||
Name: "foo",
|
Name: "foo",
|
||||||
ModTime: time.Now().Add(-31 * 24 * time.Hour),
|
ModTime: time.Now().Add(-31 * 24 * time.Hour),
|
||||||
@ -177,12 +177,12 @@ func TestEvalActionFromLifecycle(t *testing.T) {
|
|||||||
</LifecycleConfiguration>`
|
</LifecycleConfiguration>`
|
||||||
delMarkerILM := `<LifecycleConfiguration>
|
delMarkerILM := `<LifecycleConfiguration>
|
||||||
<Rule>
|
<Rule>
|
||||||
<ID>DelMarkerExpiration</ID>
|
<ID>DeletedObjectExpiration</ID>
|
||||||
<Filter></Filter>
|
<Filter></Filter>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>60</Days>
|
<Days>60</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
</Rule>
|
</Rule>
|
||||||
</LifecycleConfiguration>`
|
</LifecycleConfiguration>`
|
||||||
deleteAllLc, err := lifecycle.ParseLifecycleConfig(strings.NewReader(deleteAllILM))
|
deleteAllLc, err := lifecycle.ParseLifecycleConfig(strings.NewReader(deleteAllILM))
|
||||||
|
@ -22,23 +22,23 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errInvalidDaysDelMarkerExpiration = Errorf("Days must be a positive integer with DelMarkerExpiration")
|
var errInvalidDaysDeletedObjExpiration = Errorf("Days must be a positive integer with DeletedObjectExpiration")
|
||||||
|
|
||||||
// DelMarkerExpiration used to xml encode/decode ILM action by the same name
|
// DeletedObjectExpiration used to xml encode/decode ILM action by the same name
|
||||||
type DelMarkerExpiration struct {
|
type DeletedObjectExpiration struct {
|
||||||
XMLName xml.Name `xml:"DelMarkerExpiration"`
|
XMLName xml.Name `xml:"DeletedObjectExpiration"`
|
||||||
Days int `xml:"Days,omitempty"`
|
Days int `xml:"Days,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Empty returns if a DelMarkerExpiration XML element is empty.
|
// Empty returns if a DeletedObjectExpiration XML element is empty.
|
||||||
// Used to detect if lifecycle.Rule contained a DelMarkerExpiration element.
|
// Used to detect if lifecycle.Rule contained a DeletedObjectExpiration element.
|
||||||
func (de DelMarkerExpiration) Empty() bool {
|
func (de DeletedObjectExpiration) Empty() bool {
|
||||||
return de.Days == 0
|
return de.Days == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// UnmarshalXML decodes a single XML element into a DelMarkerExpiration value
|
// UnmarshalXML decodes a single XML element into a DeletedObjectExpiration value
|
||||||
func (de *DelMarkerExpiration) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error {
|
func (de *DeletedObjectExpiration) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error {
|
||||||
type delMarkerExpiration DelMarkerExpiration
|
type delMarkerExpiration DeletedObjectExpiration
|
||||||
var dexp delMarkerExpiration
|
var dexp delMarkerExpiration
|
||||||
err := dec.DecodeElement(&dexp, &start)
|
err := dec.DecodeElement(&dexp, &start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -46,26 +46,26 @@ func (de *DelMarkerExpiration) UnmarshalXML(dec *xml.Decoder, start xml.StartEle
|
|||||||
}
|
}
|
||||||
|
|
||||||
if dexp.Days <= 0 {
|
if dexp.Days <= 0 {
|
||||||
return errInvalidDaysDelMarkerExpiration
|
return errInvalidDaysDeletedObjExpiration
|
||||||
}
|
}
|
||||||
|
|
||||||
*de = DelMarkerExpiration(dexp)
|
*de = DeletedObjectExpiration(dexp)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalXML encodes a DelMarkerExpiration value into an XML element
|
// MarshalXML encodes a DeletedObjectExpiration value into an XML element
|
||||||
func (de DelMarkerExpiration) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
|
func (de DeletedObjectExpiration) MarshalXML(enc *xml.Encoder, start xml.StartElement) error {
|
||||||
if de.Empty() {
|
if de.Empty() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type delMarkerExpiration DelMarkerExpiration
|
type delMarkerExpiration DeletedObjectExpiration
|
||||||
return enc.EncodeElement(delMarkerExpiration(de), start)
|
return enc.EncodeElement(delMarkerExpiration(de), start)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NextDue returns upcoming DelMarkerExpiration date for obj if
|
// NextDue returns upcoming DeletedObjectExpiration date for obj if
|
||||||
// applicable, returns false otherwise.
|
// applicable, returns false otherwise.
|
||||||
func (de DelMarkerExpiration) NextDue(obj ObjectOpts) (time.Time, bool) {
|
func (de DeletedObjectExpiration) NextDue(obj ObjectOpts) (time.Time, bool) {
|
||||||
if !obj.IsLatest || !obj.DeleteMarker {
|
if !obj.IsLatest || !obj.DeleteMarker {
|
||||||
return time.Time{}, false
|
return time.Time{}, false
|
||||||
}
|
}
|
||||||
|
@ -23,24 +23,24 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDelMarkerExpParseAndValidate(t *testing.T) {
|
func TestDelObjExpParseAndValidate(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
xml string
|
xml string
|
||||||
err error
|
err error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
xml: `<DelMarkerExpiration> <Days> 1 </Days> </DelMarkerExpiration>`,
|
xml: `<DeletedObjectExpiration> <Days> 1 </Days> </DeletedObjectExpiration>`,
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
xml: `<DelMarkerExpiration> <Days> -1 </Days> </DelMarkerExpiration>`,
|
xml: `<DeletedObjectExpiration> <Days> -1 </Days> </DeletedObjectExpiration>`,
|
||||||
err: errInvalidDaysDelMarkerExpiration,
|
err: errInvalidDaysDeletedObjExpiration,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
t.Run(fmt.Sprintf("TestDelMarker-%d", i), func(t *testing.T) {
|
t.Run(fmt.Sprintf("TestDelMarker-%d", i), func(t *testing.T) {
|
||||||
var dexp DelMarkerExpiration
|
var dexp DeletedObjectExpiration
|
||||||
var fail bool
|
var fail bool
|
||||||
err := xml.Unmarshal([]byte(test.xml), &dexp)
|
err := xml.Unmarshal([]byte(test.xml), &dexp)
|
||||||
if test.err == nil {
|
if test.err == nil {
|
||||||
|
@ -385,9 +385,9 @@ func (lc Lifecycle) eval(obj ObjectOpts, now time.Time) Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DelMarkerExpiration
|
// DeletedObjectExpiration
|
||||||
if obj.IsLatest && obj.DeleteMarker && !rule.DelMarkerExpiration.Empty() {
|
if obj.IsLatest && obj.DeleteMarker && !rule.DeletedObjectExpiration.Empty() {
|
||||||
if due, ok := rule.DelMarkerExpiration.NextDue(obj); ok && (now.IsZero() || now.After(due)) {
|
if due, ok := rule.DeletedObjectExpiration.NextDue(obj); ok && (now.IsZero() || now.After(due)) {
|
||||||
events = append(events, Event{
|
events = append(events, Event{
|
||||||
Action: DelMarkerDeleteAllVersionsAction,
|
Action: DelMarkerDeleteAllVersionsAction,
|
||||||
RuleID: rule.ID,
|
RuleID: rule.ID,
|
||||||
@ -396,7 +396,7 @@ func (lc Lifecycle) eval(obj ObjectOpts, now time.Time) Event {
|
|||||||
}
|
}
|
||||||
// No other conflicting actions in this rule can apply to an object with current version as DEL marker
|
// No other conflicting actions in this rule can apply to an object with current version as DEL marker
|
||||||
// Note: There could be other rules with earlier expiration which need to be considered.
|
// Note: There could be other rules with earlier expiration which need to be considered.
|
||||||
// See TestDelMarkerExpiration
|
// See TestDeletedObjectExpiration
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ func TestParseAndValidateLifecycleConfig(t *testing.T) {
|
|||||||
},
|
},
|
||||||
// Lifecycle with delmarker expiration
|
// Lifecycle with delmarker expiration
|
||||||
{
|
{
|
||||||
inputConfig: `<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>rule</ID><Status>Enabled</Status><Filter></Filter><DelMarkerExpiration><Days>5</Days></DelMarkerExpiration></Rule></LifecycleConfiguration>`,
|
inputConfig: `<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>rule</ID><Status>Enabled</Status><Filter></Filter><DeletedObjectExpiration><Days>5</Days></DeletedObjectExpiration></Rule></LifecycleConfiguration>`,
|
||||||
expectedParsingErr: nil,
|
expectedParsingErr: nil,
|
||||||
expectedValidationErr: nil,
|
expectedValidationErr: nil,
|
||||||
},
|
},
|
||||||
// Lifecycle with empty delmarker expiration
|
// Lifecycle with empty delmarker expiration
|
||||||
{
|
{
|
||||||
inputConfig: `<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>rule</ID><Status>Enabled</Status><Filter></Filter><DelMarkerExpiration><Days></Days></DelMarkerExpiration></Rule></LifecycleConfiguration>`,
|
inputConfig: `<LifecycleConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Rule><ID>rule</ID><Status>Enabled</Status><Filter></Filter><DeletedObjectExpiration><Days></Days></DeletedObjectExpiration></Rule></LifecycleConfiguration>`,
|
||||||
expectedParsingErr: errInvalidDaysDelMarkerExpiration,
|
expectedParsingErr: errInvalidDaysDeletedObjExpiration,
|
||||||
expectedValidationErr: nil,
|
expectedValidationErr: nil,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@ -609,15 +609,15 @@ func TestEval(t *testing.T) {
|
|||||||
expectedAction: DeleteVersionAction,
|
expectedAction: DeleteVersionAction,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// DelMarkerExpiration is preferred since object age is past both transition and expiration days.
|
// DeletedObjectExpiration is preferred since object age is past both transition and expiration days.
|
||||||
inputConfig: `<LifecycleConfiguration>
|
inputConfig: `<LifecycleConfiguration>
|
||||||
<Rule>
|
<Rule>
|
||||||
<ID>DelMarkerExpiration with Transition</ID>
|
<ID>DeletedObjectExpiration with Transition</ID>
|
||||||
<Filter></Filter>
|
<Filter></Filter>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>60</Days>
|
<Days>60</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
<Transition>
|
<Transition>
|
||||||
<StorageClass>WARM-1</StorageClass>
|
<StorageClass>WARM-1</StorageClass>
|
||||||
<Days>30</Days>
|
<Days>30</Days>
|
||||||
@ -630,16 +630,16 @@ func TestEval(t *testing.T) {
|
|||||||
expectedAction: DelMarkerDeleteAllVersionsAction,
|
expectedAction: DelMarkerDeleteAllVersionsAction,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// NoneAction since object doesn't qualify for DelMarkerExpiration yet.
|
// NoneAction since object doesn't qualify for DeletedObjectExpiration yet.
|
||||||
// Note: TransitionAction doesn't apply to DEL marker
|
// Note: TransitionAction doesn't apply to DEL marker
|
||||||
inputConfig: `<LifecycleConfiguration>
|
inputConfig: `<LifecycleConfiguration>
|
||||||
<Rule>
|
<Rule>
|
||||||
<ID>DelMarkerExpiration with Transition</ID>
|
<ID>DeletedObjectExpiration with Transition</ID>
|
||||||
<Filter></Filter>
|
<Filter></Filter>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>60</Days>
|
<Days>60</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
<Transition>
|
<Transition>
|
||||||
<StorageClass>WARM-1</StorageClass>
|
<StorageClass>WARM-1</StorageClass>
|
||||||
<Days>30</Days>
|
<Days>30</Days>
|
||||||
@ -654,12 +654,12 @@ func TestEval(t *testing.T) {
|
|||||||
{
|
{
|
||||||
inputConfig: `<LifecycleConfiguration>
|
inputConfig: `<LifecycleConfiguration>
|
||||||
<Rule>
|
<Rule>
|
||||||
<ID>DelMarkerExpiration with non DEL-marker object</ID>
|
<ID>DeletedObjectExpiration with non DEL-marker object</ID>
|
||||||
<Filter></Filter>
|
<Filter></Filter>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>60</Days>
|
<Days>60</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
</Rule>
|
</Rule>
|
||||||
</LifecycleConfiguration>`,
|
</LifecycleConfiguration>`,
|
||||||
objectName: "obj-1",
|
objectName: "obj-1",
|
||||||
@ -669,12 +669,12 @@ func TestEval(t *testing.T) {
|
|||||||
{
|
{
|
||||||
inputConfig: `<LifecycleConfiguration>
|
inputConfig: `<LifecycleConfiguration>
|
||||||
<Rule>
|
<Rule>
|
||||||
<ID>DelMarkerExpiration with noncurrent DEL-marker</ID>
|
<ID>DeletedObjectExpiration with noncurrent DEL-marker</ID>
|
||||||
<Filter></Filter>
|
<Filter></Filter>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>60</Days>
|
<Days>60</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
</Rule>
|
</Rule>
|
||||||
</LifecycleConfiguration>`,
|
</LifecycleConfiguration>`,
|
||||||
objectName: "obj-1",
|
objectName: "obj-1",
|
||||||
@ -1381,7 +1381,7 @@ func TestFilterRules(t *testing.T) {
|
|||||||
|
|
||||||
// TestDeleteAllVersions tests ordering among events, especially ones which
|
// TestDeleteAllVersions tests ordering among events, especially ones which
|
||||||
// expire all versions like ExpiredObjectDeleteAllVersions and
|
// expire all versions like ExpiredObjectDeleteAllVersions and
|
||||||
// DelMarkerExpiration
|
// DeletedObjectExpiration
|
||||||
func TestDeleteAllVersions(t *testing.T) {
|
func TestDeleteAllVersions(t *testing.T) {
|
||||||
// ExpiredObjectDeleteAllVersions
|
// ExpiredObjectDeleteAllVersions
|
||||||
lc := Lifecycle{
|
lc := Lifecycle{
|
||||||
@ -1424,20 +1424,20 @@ func TestDeleteAllVersions(t *testing.T) {
|
|||||||
t.Fatalf("Expected due %v but got %v, ruleID=%v", exp, event.Due, event.RuleID)
|
t.Fatalf("Expected due %v but got %v, ruleID=%v", exp, event.Due, event.RuleID)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DelMarkerExpiration
|
// DeletedObjectExpiration
|
||||||
lc = Lifecycle{
|
lc = Lifecycle{
|
||||||
Rules: []Rule{
|
Rules: []Rule{
|
||||||
{
|
{
|
||||||
ID: "delmarker-exp-20",
|
ID: "delmarker-exp-20",
|
||||||
Status: "Enabled",
|
Status: "Enabled",
|
||||||
DelMarkerExpiration: DelMarkerExpiration{
|
DeletedObjectExpiration: DeletedObjectExpiration{
|
||||||
Days: 20,
|
Days: 20,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
ID: "delmarker-exp-10",
|
ID: "delmarker-exp-10",
|
||||||
Status: "Enabled",
|
Status: "Enabled",
|
||||||
DelMarkerExpiration: DelMarkerExpiration{
|
DeletedObjectExpiration: DeletedObjectExpiration{
|
||||||
Days: 10,
|
Days: 10,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -33,24 +33,24 @@ const (
|
|||||||
|
|
||||||
// Rule - a rule for lifecycle configuration.
|
// Rule - a rule for lifecycle configuration.
|
||||||
type Rule struct {
|
type Rule struct {
|
||||||
XMLName xml.Name `xml:"Rule"`
|
XMLName xml.Name `xml:"Rule"`
|
||||||
ID string `xml:"ID,omitempty"`
|
ID string `xml:"ID,omitempty"`
|
||||||
Status Status `xml:"Status"`
|
Status Status `xml:"Status"`
|
||||||
Filter Filter `xml:"Filter,omitempty"`
|
Filter Filter `xml:"Filter,omitempty"`
|
||||||
Prefix Prefix `xml:"Prefix,omitempty"`
|
Prefix Prefix `xml:"Prefix,omitempty"`
|
||||||
Expiration Expiration `xml:"Expiration,omitempty"`
|
Expiration Expiration `xml:"Expiration,omitempty"`
|
||||||
Transition Transition `xml:"Transition,omitempty"`
|
Transition Transition `xml:"Transition,omitempty"`
|
||||||
DelMarkerExpiration DelMarkerExpiration `xml:"DelMarkerExpiration,omitempty"`
|
DeletedObjectExpiration DeletedObjectExpiration `xml:"DeletedObjectExpiration,omitempty"`
|
||||||
// FIXME: add a type to catch unsupported AbortIncompleteMultipartUpload AbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
|
// FIXME: add a type to catch unsupported AbortIncompleteMultipartUpload AbortIncompleteMultipartUpload `xml:"AbortIncompleteMultipartUpload,omitempty"`
|
||||||
NoncurrentVersionExpiration NoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"`
|
NoncurrentVersionExpiration NoncurrentVersionExpiration `xml:"NoncurrentVersionExpiration,omitempty"`
|
||||||
NoncurrentVersionTransition NoncurrentVersionTransition `xml:"NoncurrentVersionTransition,omitempty"`
|
NoncurrentVersionTransition NoncurrentVersionTransition `xml:"NoncurrentVersionTransition,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
errInvalidRuleID = Errorf("ID length is limited to 255 characters")
|
errInvalidRuleID = Errorf("ID length is limited to 255 characters")
|
||||||
errEmptyRuleStatus = Errorf("Status should not be empty")
|
errEmptyRuleStatus = Errorf("Status should not be empty")
|
||||||
errInvalidRuleStatus = Errorf("Status must be set to either Enabled or Disabled")
|
errInvalidRuleStatus = Errorf("Status must be set to either Enabled or Disabled")
|
||||||
errInvalidRuleDelMarkerExpiration = Errorf("Rule with DelMarkerExpiration cannot have tags based filtering")
|
errInvalidRuleDelObjExpiration = Errorf("Rule with DeletedObjectExpiration cannot have tags based filtering")
|
||||||
)
|
)
|
||||||
|
|
||||||
// validateID - checks if ID is valid or not.
|
// validateID - checks if ID is valid or not.
|
||||||
@ -160,10 +160,10 @@ func (r Rule) Validate() error {
|
|||||||
if err := r.validateNoncurrentTransition(); err != nil {
|
if err := r.validateNoncurrentTransition(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if (!r.Filter.Tag.IsEmpty() || len(r.Filter.And.Tags) != 0) && !r.DelMarkerExpiration.Empty() {
|
if (!r.Filter.Tag.IsEmpty() || len(r.Filter.And.Tags) != 0) && !r.DeletedObjectExpiration.Empty() {
|
||||||
return errInvalidRuleDelMarkerExpiration
|
return errInvalidRuleDelObjExpiration
|
||||||
}
|
}
|
||||||
if !r.Expiration.set && !r.Transition.set && !r.NoncurrentVersionExpiration.set && !r.NoncurrentVersionTransition.set && r.DelMarkerExpiration.Empty() {
|
if !r.Expiration.set && !r.Transition.set && !r.NoncurrentVersionExpiration.set && !r.NoncurrentVersionTransition.set && r.DeletedObjectExpiration.Empty() {
|
||||||
return errXMLNotWellFormed
|
return errXMLNotWellFormed
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -107,28 +107,28 @@ func TestInvalidRules(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
inputXML: `<Rule>
|
inputXML: `<Rule>
|
||||||
<ID>Rule with a tag and DelMarkerExpiration</ID>
|
<ID>Rule with a tag and DeletedObjectExpiration</ID>
|
||||||
<Filter><Tag><Key>k1</Key><Value>v1</Value></Tag></Filter>
|
<Filter><Tag><Key>k1</Key><Value>v1</Value></Tag></Filter>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>365</Days>
|
<Days>365</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
</Rule>`,
|
</Rule>`,
|
||||||
expectedErr: errInvalidRuleDelMarkerExpiration,
|
expectedErr: errInvalidRuleDelObjExpiration,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
inputXML: `<Rule>
|
inputXML: `<Rule>
|
||||||
<ID>Rule with multiple tags and DelMarkerExpiration</ID>
|
<ID>Rule with multiple tags and DeletedObjectExpiration</ID>
|
||||||
<Filter><And>
|
<Filter><And>
|
||||||
<Tag><Key>k1</Key><Value>v1</Value></Tag>
|
<Tag><Key>k1</Key><Value>v1</Value></Tag>
|
||||||
<Tag><Key>k2</Key><Value>v2</Value></Tag>
|
<Tag><Key>k2</Key><Value>v2</Value></Tag>
|
||||||
</And></Filter>
|
</And></Filter>
|
||||||
<DelMarkerExpiration>
|
<DeletedObjectExpiration>
|
||||||
<Days>365</Days>
|
<Days>365</Days>
|
||||||
</DelMarkerExpiration>
|
</DeletedObjectExpiration>
|
||||||
<Status>Enabled</Status>
|
<Status>Enabled</Status>
|
||||||
</Rule>`,
|
</Rule>`,
|
||||||
expectedErr: errInvalidRuleDelMarkerExpiration,
|
expectedErr: errInvalidRuleDelObjExpiration,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ const (
|
|||||||
ObjectManyVersions
|
ObjectManyVersions
|
||||||
ObjectLargeVersions
|
ObjectLargeVersions
|
||||||
PrefixManyFolders
|
PrefixManyFolders
|
||||||
ILMDelMarkerExpirationDelete
|
ILMDelObjExpirationDelete
|
||||||
|
|
||||||
objectSingleTypesEnd
|
objectSingleTypesEnd
|
||||||
// Start Compound types that require expansion:
|
// Start Compound types that require expansion:
|
||||||
@ -200,8 +200,8 @@ func (name Name) String() string {
|
|||||||
return "s3:ObjectRemoved:NoOP"
|
return "s3:ObjectRemoved:NoOP"
|
||||||
case ObjectRemovedDeleteAllVersions:
|
case ObjectRemovedDeleteAllVersions:
|
||||||
return "s3:ObjectRemoved:DeleteAllVersions"
|
return "s3:ObjectRemoved:DeleteAllVersions"
|
||||||
case ILMDelMarkerExpirationDelete:
|
case ILMDelObjExpirationDelete:
|
||||||
return "s3:LifecycleDelMarkerExpiration:Delete"
|
return "s3:LifecycleDeletedObjectExpiration:Delete"
|
||||||
case ObjectReplicationAll:
|
case ObjectReplicationAll:
|
||||||
return "s3:Replication:*"
|
return "s3:Replication:*"
|
||||||
case ObjectReplicationFailed:
|
case ObjectReplicationFailed:
|
||||||
@ -327,8 +327,8 @@ func ParseName(s string) (Name, error) {
|
|||||||
return ObjectRemovedNoOP, nil
|
return ObjectRemovedNoOP, nil
|
||||||
case "s3:ObjectRemoved:DeleteAllVersions":
|
case "s3:ObjectRemoved:DeleteAllVersions":
|
||||||
return ObjectRemovedDeleteAllVersions, nil
|
return ObjectRemovedDeleteAllVersions, nil
|
||||||
case "s3:LifecycleDelMarkerExpiration:Delete":
|
case "s3:LifecycleDeletedObjectExpiration:Delete":
|
||||||
return ILMDelMarkerExpirationDelete, nil
|
return ILMDelObjExpirationDelete, nil
|
||||||
case "s3:Replication:*":
|
case "s3:Replication:*":
|
||||||
return ObjectReplicationAll, nil
|
return ObjectReplicationAll, nil
|
||||||
case "s3:Replication:OperationFailedReplication":
|
case "s3:Replication:OperationFailedReplication":
|
||||||
|
@ -69,7 +69,7 @@ func TestNameString(t *testing.T) {
|
|||||||
{ObjectRemovedAll, "s3:ObjectRemoved:*"},
|
{ObjectRemovedAll, "s3:ObjectRemoved:*"},
|
||||||
{ObjectRemovedDelete, "s3:ObjectRemoved:Delete"},
|
{ObjectRemovedDelete, "s3:ObjectRemoved:Delete"},
|
||||||
{ObjectRemovedDeleteAllVersions, "s3:ObjectRemoved:DeleteAllVersions"},
|
{ObjectRemovedDeleteAllVersions, "s3:ObjectRemoved:DeleteAllVersions"},
|
||||||
{ILMDelMarkerExpirationDelete, "s3:LifecycleDelMarkerExpiration:Delete"},
|
{ILMDelObjExpirationDelete, "s3:LifecycleDeletedObjectExpiration:Delete"},
|
||||||
{ObjectRemovedNoOP, "s3:ObjectRemoved:NoOP"},
|
{ObjectRemovedNoOP, "s3:ObjectRemoved:NoOP"},
|
||||||
{ObjectCreatedPutRetention, "s3:ObjectCreated:PutRetention"},
|
{ObjectCreatedPutRetention, "s3:ObjectCreated:PutRetention"},
|
||||||
{ObjectCreatedPutLegalHold, "s3:ObjectCreated:PutLegalHold"},
|
{ObjectCreatedPutLegalHold, "s3:ObjectCreated:PutLegalHold"},
|
||||||
@ -221,7 +221,7 @@ func TestParseName(t *testing.T) {
|
|||||||
{"s3:ObjectAccessed:*", ObjectAccessedAll, false},
|
{"s3:ObjectAccessed:*", ObjectAccessedAll, false},
|
||||||
{"s3:ObjectRemoved:Delete", ObjectRemovedDelete, false},
|
{"s3:ObjectRemoved:Delete", ObjectRemovedDelete, false},
|
||||||
{"s3:ObjectRemoved:NoOP", ObjectRemovedNoOP, false},
|
{"s3:ObjectRemoved:NoOP", ObjectRemovedNoOP, false},
|
||||||
{"s3:LifecycleDelMarkerExpiration:Delete", ILMDelMarkerExpirationDelete, false},
|
{"s3:LifecycleDeletedObjectExpiration:Delete", ILMDelObjExpirationDelete, false},
|
||||||
{"", blankName, true},
|
{"", blankName, true},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user