replication

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DestinationARNMinIOPrefix = "arn:minio:replication:"

DestinationARNMinIOPrefix - destination ARN prefix for MinIO.

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

func (c Config) FilterTargetArns(obj ObjectOpts) []string

FilterTargetArns returns a slice of distinct target arns in the config

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"`
	ARN          string
}

Destination - destination in ReplicationConfiguration.

func (Destination) IsValid

func (d Destination) IsValid() bool

IsValid - checks whether Destination is valid or not.

func (Destination) LegacyArn

func (d Destination) LegacyArn() bool

LegacyArn returns true if arn format has prefix "arn:aws:s3:::" which was used prior to multi-destination

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

func (d Destination) TargetArn() bool

TargetArn returns true if arn format has prefix "arn:minio:replication:::" used for multi-destination targets

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 ExistingObjectReplication

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

ExistingObjectReplication - whether existing object replication is enabled

func (ExistingObjectReplication) IsEmpty

func (e ExistingObjectReplication) IsEmpty() bool

IsEmpty returns true if ExistingObjectReplication is not set

func (*ExistingObjectReplication) UnmarshalXML

func (e *ExistingObjectReplication) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML - decodes XML data. Default to Disabled unless specified

func (ExistingObjectReplication) Validate

func (e ExistingObjectReplication) Validate() error

Validate validates whether the status is disabled.

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
	DeleteMarker   bool
	SSEC           bool
	OpType         Type
	Replica        bool
	ExistingObject bool
	TargetArn      string
}

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

type ReplicaModifications

type ReplicaModifications struct {
	Status Status `xml:"Status" json:"Status"`
}

ReplicaModifications specifies if replica modification sync is enabled

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"`
	SourceSelectionCriteria   SourceSelectionCriteria   `xml:"SourceSelectionCriteria" json:"SourceSelectionCriteria"`
	Filter                    Filter                    `xml:"Filter" json:"Filter"`
	ExistingObjectReplication ExistingObjectReplication `xml:"ExistingObjectReplication,omitempty" json:"ExistingObjectReplication,omitempty"`
}

Rule - a rule for replication configuration.

func (Rule) MetadataReplicate

func (r Rule) MetadataReplicate(obj ObjectOpts) bool

MetadataReplicate returns true if object is not a replica or in the case of replicas, replica modification sync is enabled.

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 SourceSelectionCriteria

type SourceSelectionCriteria struct {
	ReplicaModifications ReplicaModifications `xml:"ReplicaModifications" json:"ReplicaModifications"`
}

SourceSelectionCriteria - specifies additional source selection criteria in ReplicationConfiguration.

func (SourceSelectionCriteria) IsValid

func (s SourceSelectionCriteria) IsValid() bool

IsValid - checks whether SourceSelectionCriteria is valid or not.

func (SourceSelectionCriteria) MarshalXML

func (s SourceSelectionCriteria) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML - encodes to XML data.

func (*SourceSelectionCriteria) UnmarshalXML

func (s *SourceSelectionCriteria) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) (err error)

UnmarshalXML - decodes XML data.

func (SourceSelectionCriteria) Validate

func (s SourceSelectionCriteria) Validate() error

Validate source selection criteria

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"

	// Completed - replication completed ok.
	Completed StatusType = "COMPLETED"

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

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

func (*StatusType) DecodeMsg

func (z *StatusType) DecodeMsg(dc *msgp.Reader) (err error)

DecodeMsg implements msgp.Decodable

func (StatusType) Empty

func (s StatusType) Empty() bool

Empty returns true if this status is not set

func (StatusType) EncodeMsg

func (z StatusType) EncodeMsg(en *msgp.Writer) (err error)

EncodeMsg implements msgp.Encodable

func (StatusType) MarshalMsg

func (z StatusType) MarshalMsg(b []byte) (o []byte, err error)

MarshalMsg implements msgp.Marshaler

func (StatusType) Msgsize

func (z StatusType) Msgsize() (s int)

Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message

func (StatusType) String

func (s StatusType) String() string

String returns string representation of status

func (*StatusType) UnmarshalMsg

func (z *StatusType) UnmarshalMsg(bts []byte) (o []byte, err error)

UnmarshalMsg implements msgp.Unmarshaler

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.

type Type

type Type int

Type - replication type enum

const (
	UnsetReplicationType Type = 0 + iota
	ObjectReplicationType
	DeleteReplicationType
	MetadataReplicationType
	HealReplicationType
	ExistingObjectReplicationType
	ResyncReplicationType
)

Types of replication

func (Type) Valid

func (t Type) Valid() bool

Valid returns true if replication type is set

Jump to

Keyboard shortcuts

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