mirror of
https://github.com/minio/minio.git
synced 2025-11-27 12:53:45 -05:00
lifcycle: Add more validation to the config (#11382)
This commit is contained in:
50
pkg/bucket/lifecycle/prefix.go
Normal file
50
pkg/bucket/lifecycle/prefix.go
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* MinIO Cloud Storage, (C) 2020 MinIO, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package lifecycle
|
||||
|
||||
import (
|
||||
"encoding/xml"
|
||||
)
|
||||
|
||||
// Prefix holds the prefix xml tag in <Rule> and <Filter>
|
||||
type Prefix struct {
|
||||
string
|
||||
set bool
|
||||
}
|
||||
|
||||
// UnmarshalXML - decodes XML data.
|
||||
func (p *Prefix) UnmarshalXML(d *xml.Decoder, start xml.StartElement) (err error) {
|
||||
var s string
|
||||
if err = d.DecodeElement(&s, &start); err != nil {
|
||||
return err
|
||||
}
|
||||
*p = Prefix{string: s, set: true}
|
||||
return nil
|
||||
}
|
||||
|
||||
// MarshalXML - decodes XML data.
|
||||
func (p Prefix) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error {
|
||||
if !p.set {
|
||||
return nil
|
||||
}
|
||||
return e.EncodeElement(p.string, startElement)
|
||||
}
|
||||
|
||||
// String returns the prefix string
|
||||
func (p Prefix) String() string {
|
||||
return p.string
|
||||
}
|
||||
Reference in New Issue
Block a user