replication

package
v0.0.0-...-1ed3a2a Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DestinationARNPrefix = "arn:aws:s3:::"

DestinationARNPrefix - destination ARN prefix as per AWS S3 specification.

Variables

This section is empty.

Functions

func Errorf

func Errorf(format string, a ...interface{}) error

Errorf - formats according to a format specifier and returns the string as a value that satisfies error of type tagging.Error

Types

type And

type And struct {
	XMLName xml.Name `xml:"And" json:"And"`
	Prefix  string   `xml:"Prefix,omitempty" json:"Prefix,omitempty"`
	Tags    []Tag    `xml:"Tag,omitempty" json:"Tag,omitempty"`
}

And - a tag to combine a prefix and multiple tags for replication configuration rule.

func (And) ContainsDuplicateTag

func (a And) ContainsDuplicateTag() bool

ContainsDuplicateTag - returns true if duplicate keys are present in And

func (And) Validate

func (a And) Validate() error

Validate - validates the And field

type Config

type Config struct {
	XMLName xml.Name `xml:"ReplicationConfiguration" json:"-"`
	Rules   []Rule   `xml:"Rule" json:"Rules"`
	// RoleArn is being reused for MinIO replication ARN
	RoleArn string `xml:"Role" json:"Role"`
}

Config - replication configuration specified in https://docs.aws.amazon.com/AmazonS3/latest/dev/replication-add-config.html

func ParseConfig

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

ParseConfig parses ReplicationConfiguration from xml

func (Config) FilterActionableRules

func (c Config) FilterActionableRules(obj ObjectOpts) []Rule

FilterActionableRules returns the rules actions that need to be executed after evaluating prefix/tag filtering

func (Config) GetDestination

func (c Config) GetDestination() Destination

GetDestination returns destination bucket and storage class.

func (Config) HasActiveRules

func (c Config) HasActiveRules(prefix string, recursive bool) bool

HasActiveRules - returns whether replication policy has active rules 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 (Config) Replicate

func (c Config) Replicate(obj ObjectOpts) bool

Replicate returns true if the object should be replicated.

func (Config) Validate

func (c Config) Validate(bucket string, sameTarget bool) error

Validate - validates the replication configuration

type DeleteMarkerReplication

type DeleteMarkerReplication struct {
	Status Status `xml:"Status"` // should be set to "Disabled" by default
}

DeleteMarkerReplication - whether delete markers are replicated - https://docs.aws.amazon.com/AmazonS3/latest/dev/replication-add-config.html

func (DeleteMarkerReplication) IsEmpty

func (d DeleteMarkerReplication) IsEmpty() bool

IsEmpty returns true if DeleteMarkerReplication is not set

func (DeleteMarkerReplication) Validate

func (d DeleteMarkerReplication) Validate() error

Validate validates whether the status is disabled.

type DeleteReplication

type DeleteReplication struct {
	Status Status `xml:"Status"` // should be set to "Disabled" by default
}

DeleteReplication - whether versioned deletes are replicated - this is a MinIO only extension.

func (DeleteReplication) IsEmpty

func (d DeleteReplication) IsEmpty() bool

IsEmpty returns true if DeleteReplication is not set

func (*DeleteReplication) UnmarshalXML

func (d *DeleteReplication) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML - decodes XML data.

func (DeleteReplication) Validate

func (d DeleteReplication) Validate() error

Validate validates whether the status is disabled.

type Destination

type Destination struct {
	XMLName      xml.Name `xml:"Destination" json:"Destination"`
	Bucket       string   `xml:"Bucket" json:"Bucket"`
	StorageClass string   `xml:"StorageClass" json:"StorageClass"`
}

Destination - destination in ReplicationConfiguration.

func (Destination) IsValid

func (d Destination) IsValid() bool

IsValid - checks whether Destination is valid or not.

func (Destination) MarshalXML

func (d Destination) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - encodes to XML data.

func (Destination) String

func (d Destination) String() string

func (*Destination) UnmarshalXML

func (d *Destination) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML - decodes XML data.

func (Destination) Validate

func (d Destination) Validate(bucketName string) error

Validate - validates Resource is for given bucket or not.

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error is the generic type for any error happening during tag parsing.

func (Error) Error

func (e Error) Error() string

Error 'error' compatible method.

func (Error) Unwrap

func (e Error) Unwrap() error

Unwrap the internal error.

type Filter

type Filter struct {
	XMLName xml.Name `xml:"Filter" json:"Filter"`
	Prefix  string
	And     And
	Tag     Tag
	// contains filtered or unexported fields
}

Filter - a filter for a replication configuration Rule.

func (Filter) IsEmpty

func (f Filter) IsEmpty() bool

IsEmpty returns true if filter is not set

func (Filter) MarshalXML

func (f Filter) MarshalXML(e *xml.Encoder, start xml.StartElement) error

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

func (f *Filter) TestTags(ttags []string) bool

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) Validate

func (f Filter) Validate() error

Validate - validates the filter element

type ObjectOpts

type ObjectOpts struct {
	Name         string
	UserTags     string
	VersionID    string
	IsLatest     bool
	DeleteMarker bool
	SSEC         bool
}

ObjectOpts provides information to deduce whether replication can be triggered on the resultant object.

type Rule

type Rule struct {
	XMLName                 xml.Name                `xml:"Rule" json:"Rule"`
	ID                      string                  `xml:"ID,omitempty" json:"ID,omitempty"`
	Status                  Status                  `xml:"Status" json:"Status"`
	Priority                int                     `xml:"Priority" json:"Priority"`
	DeleteMarkerReplication DeleteMarkerReplication `xml:"DeleteMarkerReplication" json:"DeleteMarkerReplication"`
	// MinIO extension to replicate versioned deletes
	DeleteReplication DeleteReplication `xml:"DeleteReplication" json:"DeleteReplication"`
	Destination       Destination       `xml:"Destination" json:"Destination"`
	Filter            Filter            `xml:"Filter" json:"Filter"`
}

Rule - a rule for replication configuration.

func (Rule) Prefix

func (r Rule) Prefix() string

Prefix - a rule can either have prefix under <filter></filter> or under <filter><and></and></filter>. This method returns the prefix from the location where it is available

func (Rule) Tags

func (r Rule) Tags() string

Tags - a rule can either have tag under <filter></filter> or under <filter><and></and></filter>. This method returns all the tags from the rule in the format tag1=value1&tag2=value2

func (Rule) Validate

func (r Rule) Validate(bucket string, sameTarget bool) error

Validate - validates the rule element

type Status

type Status string

Status represents Enabled/Disabled status

const (
	Enabled  Status = "Enabled"
	Disabled Status = "Disabled"
)

Supported status types

type StatusType

type StatusType string

StatusType of Replication for x-amz-replication-status header

const (
	// Pending - replication is pending.
	Pending StatusType = "PENDING"

	// Complete - replication completed ok.
	Complete StatusType = "COMPLETE"

	// Failed - replication failed.
	Failed StatusType = "FAILED"

	// Replica - this is a replica.
	Replica StatusType = "REPLICA"
)

func (StatusType) Empty

func (s StatusType) Empty() bool

Empty returns true if this status is not set

func (StatusType) String

func (s StatusType) String() string

String returns string representation of status

type Tag

type Tag struct {
	XMLName xml.Name `xml:"Tag" json:"Tag"`
	Key     string   `xml:"Key,omitempty" json:"Key,omitempty"`
	Value   string   `xml:"Value,omitempty" json:"Value,omitempty"`
}

Tag - a tag for a replication configuration Rule filter.

func (Tag) IsEmpty

func (tag Tag) IsEmpty() bool

IsEmpty returns whether this tag is empty or not.

func (Tag) String

func (tag Tag) String() string

func (Tag) Validate

func (tag Tag) Validate() error

Validate checks this tag.

Jump to

Keyboard shortcuts

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