lock

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AmzObjectLockBypassRetGovernance = "X-Amz-Bypass-Governance-Retention"
	AmzObjectLockRetainUntilDate     = "X-Amz-Object-Lock-Retain-Until-Date"
	AmzObjectLockMode                = "X-Amz-Object-Lock-Mode"
	AmzObjectLockLegalHold           = "X-Amz-Object-Lock-Legal-Hold"
)

Bypass retention governance header.

Variables

View Source
var (
	// ErrMalformedBucketObjectConfig -indicates that the bucket object lock config is malformed
	ErrMalformedBucketObjectConfig = errors.New("invalid bucket object lock config")
	// ErrInvalidRetentionDate - indicates that retention date needs to be in ISO 8601 format
	ErrInvalidRetentionDate = errors.New("date must be provided in ISO 8601 format")
	// ErrPastObjectLockRetainDate - indicates that retention date must be in the future
	ErrPastObjectLockRetainDate = errors.New("the retain until date must be in the future")
	// ErrUnknownWORMModeDirective - indicates that the retention mode is invalid
	ErrUnknownWORMModeDirective = errors.New("unknown WORM mode directive")
	// ErrObjectLockMissingContentMD5 - indicates missing Content-MD5 header for put object requests with locking
	ErrObjectLockMissingContentMD5 = errors.New("content-MD5 HTTP header is required for Put Object requests with Object Lock parameters")
	// ErrObjectLockInvalidHeaders indicates that object lock headers are missing
	ErrObjectLockInvalidHeaders = errors.New("x-amz-object-lock-retain-until-date and x-amz-object-lock-mode must both be supplied")
	// ErrMalformedXML - generic error indicating malformed XML
	ErrMalformedXML = errors.New("the XML you provided was not well-formed or did not validate against our published schema")
)

Functions

func FilterObjectLockMetadata

func FilterObjectLockMetadata(metadata map[string]string, filterRetention, filterLegalHold bool) map[string]string

FilterObjectLockMetadata filters object lock metadata if s3:GetObjectRetention permission is denied or if isCopy flag set.

func IsObjectLockGovernanceBypassSet

func IsObjectLockGovernanceBypassSet(h http.Header) bool

IsObjectLockGovernanceBypassSet returns true if object lock governance bypass header is set.

func IsObjectLockLegalHoldRequested

func IsObjectLockLegalHoldRequested(h http.Header) bool

IsObjectLockLegalHoldRequested returns true if object lock legal hold header is set.

func IsObjectLockRequested

func IsObjectLockRequested(h http.Header) bool

IsObjectLockRequested returns true if legal hold or object lock retention headers are requested.

func IsObjectLockRetentionRequested

func IsObjectLockRetentionRequested(h http.Header) bool

IsObjectLockRetentionRequested returns true if object lock retention headers are set.

func ParseObjectLockRetentionHeaders

func ParseObjectLockRetentionHeaders(h http.Header) (rmode RetMode, r RetentionDate, err error)

ParseObjectLockRetentionHeaders parses http headers to extract retention mode and retention date

func UTCNowNTP

func UTCNowNTP() (time.Time, error)

UTCNowNTP - is similar in functionality to UTCNow() but only used when we do not wish to rely on system time.

Types

type Config

type Config struct {
	XMLNS             string   `xml:"xmlns,attr,omitempty"`
	XMLName           xml.Name `xml:"ObjectLockConfiguration"`
	ObjectLockEnabled string   `xml:"ObjectLockEnabled"`
	Rule              *struct {
		DefaultRetention DefaultRetention `xml:"DefaultRetention"`
	} `xml:"Rule,omitempty"`
}

Config - object lock configuration specified in https://docs.aws.amazon.com/AmazonS3/latest/API/Type_API_ObjectLockConfiguration.html

func NewObjectLockConfig

func NewObjectLockConfig() *Config

NewObjectLockConfig returns a initialized lock.Config struct

func ParseObjectLockConfig

func ParseObjectLockConfig(reader io.Reader) (*Config, error)

ParseObjectLockConfig parses ObjectLockConfig from xml

func (*Config) ToRetention

func (config *Config) ToRetention() Retention

ToRetention - convert to Retention type.

func (*Config) UnmarshalXML

func (config *Config) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type DefaultRetention

type DefaultRetention struct {
	XMLName xml.Name `xml:"DefaultRetention"`
	Mode    RetMode  `xml:"Mode"`
	Days    *uint64  `xml:"Days"`
	Years   *uint64  `xml:"Years"`
}

DefaultRetention - default retention configuration.

func (*DefaultRetention) UnmarshalXML

func (dr *DefaultRetention) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML - decodes XML data.

type LegalHoldStatus

type LegalHoldStatus string

LegalHoldStatus - object legal hold status.

const (
	// LegalHoldOn - legal hold is on.
	LegalHoldOn LegalHoldStatus = "ON"

	// LegalHoldOff - legal hold is off.
	LegalHoldOff LegalHoldStatus = "OFF"
)

func (LegalHoldStatus) Valid

func (l LegalHoldStatus) Valid() bool

Valid - returns true if legal hold status has valid values

type ObjectLegalHold

type ObjectLegalHold struct {
	XMLNS   string          `xml:"xmlns,attr,omitempty"`
	XMLName xml.Name        `xml:"LegalHold"`
	Status  LegalHoldStatus `xml:"Status,omitempty"`
}

ObjectLegalHold specified in https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectLegalHold.html

func GetObjectLegalHoldMeta

func GetObjectLegalHoldMeta(meta map[string]string) ObjectLegalHold

GetObjectLegalHoldMeta constructs ObjectLegalHold from metadata

func ParseObjectLegalHold

func ParseObjectLegalHold(reader io.Reader) (hold *ObjectLegalHold, err error)

ParseObjectLegalHold decodes the XML into ObjectLegalHold

func ParseObjectLockLegalHoldHeaders

func ParseObjectLockLegalHoldHeaders(h http.Header) (lhold ObjectLegalHold, err error)

ParseObjectLockLegalHoldHeaders parses request headers to construct ObjectLegalHold

func (*ObjectLegalHold) IsEmpty

func (l *ObjectLegalHold) IsEmpty() bool

IsEmpty returns true if struct is empty

type ObjectRetention

type ObjectRetention struct {
	XMLNS           string        `xml:"xmlns,attr,omitempty"`
	XMLName         xml.Name      `xml:"Retention"`
	Mode            RetMode       `xml:"Mode,omitempty"`
	RetainUntilDate RetentionDate `xml:"RetainUntilDate,omitempty"`
}

ObjectRetention specified in https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutObjectRetention.html

func GetObjectRetentionMeta

func GetObjectRetentionMeta(meta map[string]string) ObjectRetention

GetObjectRetentionMeta constructs ObjectRetention from metadata

func ParseObjectRetention

func ParseObjectRetention(reader io.Reader) (*ObjectRetention, error)

ParseObjectRetention constructs ObjectRetention struct from xml input

type RetMode

type RetMode string

RetMode - object retention mode.

const (
	// RetGovernance - governance mode.
	RetGovernance RetMode = "GOVERNANCE"

	// RetCompliance - compliance mode.
	RetCompliance RetMode = "COMPLIANCE"
)

func (RetMode) Valid

func (r RetMode) Valid() bool

Valid - returns if retention mode is valid

type Retention

type Retention struct {
	Mode        RetMode
	Validity    time.Duration
	LockEnabled bool
}

Retention - bucket level retention configuration.

func (Retention) Retain

func (r Retention) Retain(created time.Time) bool

Retain - check whether given date is retainable by validity time.

type RetentionDate

type RetentionDate struct {
	time.Time
}

RetentionDate is a embedded type containing time.Time to unmarshal Date in Retention

func (*RetentionDate) MarshalXML

func (rDate *RetentionDate) MarshalXML(e *xml.Encoder, startElement xml.StartElement) error

MarshalXML encodes expiration date if it is non-zero and encodes empty string otherwise

func (*RetentionDate) UnmarshalXML

func (rDate *RetentionDate) UnmarshalXML(d *xml.Decoder, startElement xml.StartElement) error

UnmarshalXML parses date from Retention and validates date format

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL