forked from forgejo/forgejo
[Vendor] Update Batch 2020-11 (#13746)
* github.com/alecthomas/chroma v0.8.1 -> v0.8.2 Changelog: https://github.com/alecthomas/chroma/releases/tag/v0.8.2 * github.com/blevesearch/bleve v1.0.12 -> v1.0.13 Changelog: https://github.com/blevesearch/bleve/releases/tag/v1.0.13 * github.com/editorconfig/editorconfig-core-go v2.3.8 -> v2.3.9 Changelog: https://github.com/editorconfig/editorconfig-core-go/releases/tag/v2.3.9 * github.com/klauspost/compress v1.11.2 -> v1.11.3 Changelog: https://github.com/klauspost/compress/releases/tag/v1.11.3 * github.com/minio/minio-go v7.0.5 -> v7.0.6 Changelog: https://github.com/minio/minio-go/releases/tag/v7.0.6 Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
e8a6c425ec
commit
c4deb97ed1
68 changed files with 1315 additions and 525 deletions
109
vendor/github.com/minio/minio-go/v7/pkg/replication/replication.go
generated
vendored
109
vendor/github.com/minio/minio-go/v7/pkg/replication/replication.go
generated
vendored
|
@ -46,21 +46,23 @@ const (
|
|||
|
||||
// Options represents options to set a replication configuration rule
|
||||
type Options struct {
|
||||
Op OptionType
|
||||
ID string
|
||||
Prefix string
|
||||
RuleStatus string
|
||||
Priority string
|
||||
TagString string
|
||||
StorageClass string
|
||||
RoleArn string
|
||||
DestBucket string
|
||||
IsTagSet bool
|
||||
IsSCSet bool
|
||||
Op OptionType
|
||||
ID string
|
||||
Prefix string
|
||||
RuleStatus string
|
||||
Priority string
|
||||
TagString string
|
||||
StorageClass string
|
||||
RoleArn string
|
||||
DestBucket string
|
||||
IsTagSet bool
|
||||
IsSCSet bool
|
||||
ReplicateDeletes string // replicate versioned deletes
|
||||
ReplicateDeleteMarkers string // replicate soft deletes
|
||||
}
|
||||
|
||||
// Tags returns a slice of tags for a rule
|
||||
func (opts Options) Tags() []Tag {
|
||||
func (opts Options) Tags() ([]Tag, error) {
|
||||
var tagList []Tag
|
||||
tagTokens := strings.Split(opts.TagString, "&")
|
||||
for _, tok := range tagTokens {
|
||||
|
@ -68,12 +70,15 @@ func (opts Options) Tags() []Tag {
|
|||
break
|
||||
}
|
||||
kv := strings.SplitN(tok, "=", 2)
|
||||
if len(kv) != 2 {
|
||||
return []Tag{}, fmt.Errorf("Tags should be entered as comma separated k=v pairs")
|
||||
}
|
||||
tagList = append(tagList, Tag{
|
||||
Key: kv[0],
|
||||
Value: kv[1],
|
||||
})
|
||||
}
|
||||
return tagList
|
||||
return tagList, nil
|
||||
}
|
||||
|
||||
// Config - replication configuration specified in
|
||||
|
@ -110,9 +115,12 @@ func (c *Config) AddRule(opts Options) error {
|
|||
return fmt.Errorf("Rule state should be either [enable|disable]")
|
||||
}
|
||||
|
||||
tags := opts.Tags()
|
||||
tags, err := opts.Tags()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
andVal := And{
|
||||
Tags: opts.Tags(),
|
||||
Tags: tags,
|
||||
}
|
||||
filter := Filter{Prefix: opts.Prefix}
|
||||
// only a single tag is set.
|
||||
|
@ -152,6 +160,30 @@ func (c *Config) AddRule(opts Options) error {
|
|||
return fmt.Errorf("destination bucket needs to be in Arn format")
|
||||
}
|
||||
}
|
||||
dmStatus := Disabled
|
||||
if opts.ReplicateDeleteMarkers != "" {
|
||||
switch opts.ReplicateDeleteMarkers {
|
||||
case "enable":
|
||||
dmStatus = Enabled
|
||||
case "disable":
|
||||
dmStatus = Disabled
|
||||
default:
|
||||
return fmt.Errorf("ReplicateDeleteMarkers should be either enable|disable")
|
||||
}
|
||||
}
|
||||
|
||||
vDeleteStatus := Disabled
|
||||
if opts.ReplicateDeletes != "" {
|
||||
switch opts.ReplicateDeletes {
|
||||
case "enable":
|
||||
vDeleteStatus = Enabled
|
||||
case "disable":
|
||||
vDeleteStatus = Disabled
|
||||
default:
|
||||
return fmt.Errorf("ReplicateDeletes should be either enable|disable")
|
||||
}
|
||||
}
|
||||
|
||||
newRule := Rule{
|
||||
ID: opts.ID,
|
||||
Priority: priority,
|
||||
|
@ -161,7 +193,8 @@ func (c *Config) AddRule(opts Options) error {
|
|||
Bucket: destBucket,
|
||||
StorageClass: opts.StorageClass,
|
||||
},
|
||||
DeleteMarkerReplication: DeleteMarkerReplication{Status: Disabled},
|
||||
DeleteMarkerReplication: DeleteMarkerReplication{Status: dmStatus},
|
||||
DeleteReplication: DeleteReplication{Status: vDeleteStatus},
|
||||
}
|
||||
|
||||
// validate rule after overlaying priority for pre-existing rule being disabled.
|
||||
|
@ -211,8 +244,12 @@ func (c *Config) EditRule(opts Options) error {
|
|||
if len(newRule.Filter.And.Tags) != 0 {
|
||||
tags = newRule.Filter.And.Tags
|
||||
}
|
||||
var err error
|
||||
if opts.IsTagSet {
|
||||
tags = opts.Tags()
|
||||
tags, err = opts.Tags()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
andVal := And{
|
||||
Tags: tags,
|
||||
|
@ -244,6 +281,30 @@ func (c *Config) EditRule(opts Options) error {
|
|||
return fmt.Errorf("Rule state should be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
// set DeleteMarkerReplication rule status for edit option
|
||||
if opts.ReplicateDeleteMarkers != "" {
|
||||
switch opts.ReplicateDeleteMarkers {
|
||||
case "enable":
|
||||
newRule.DeleteMarkerReplication.Status = Enabled
|
||||
case "disable":
|
||||
newRule.DeleteMarkerReplication.Status = Disabled
|
||||
default:
|
||||
return fmt.Errorf("ReplicateDeleteMarkers state should be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
|
||||
// set DeleteReplication rule status for edit option. This is a MinIO specific
|
||||
// option to replicate versioned deletes
|
||||
if opts.ReplicateDeletes != "" {
|
||||
switch opts.ReplicateDeletes {
|
||||
case "enable":
|
||||
newRule.DeleteReplication.Status = Enabled
|
||||
case "disable":
|
||||
newRule.DeleteReplication.Status = Disabled
|
||||
default:
|
||||
return fmt.Errorf("ReplicateDeletes state should be either [enable|disable]")
|
||||
}
|
||||
}
|
||||
|
||||
if opts.IsSCSet {
|
||||
newRule.Destination.StorageClass = opts.StorageClass
|
||||
|
@ -314,6 +375,7 @@ type Rule struct {
|
|||
Status Status `xml:"Status"`
|
||||
Priority int `xml:"Priority"`
|
||||
DeleteMarkerReplication DeleteMarkerReplication `xml:"DeleteMarkerReplication"`
|
||||
DeleteReplication DeleteReplication `xml:"DeleteReplication"`
|
||||
Destination Destination `xml:"Destination"`
|
||||
Filter Filter `xml:"Filter" json:"Filter"`
|
||||
}
|
||||
|
@ -470,7 +532,7 @@ type Destination struct {
|
|||
type And struct {
|
||||
XMLName xml.Name `xml:"And,omitempty" json:"-"`
|
||||
Prefix string `xml:"Prefix,omitempty" json:"Prefix,omitempty"`
|
||||
Tags []Tag `xml:"Tags,omitempty" json:"Tags,omitempty"`
|
||||
Tags []Tag `xml:"Tag,omitempty" json:"Tag,omitempty"`
|
||||
}
|
||||
|
||||
// isEmpty returns true if Tags field is null
|
||||
|
@ -496,3 +558,14 @@ type DeleteMarkerReplication struct {
|
|||
func (d DeleteMarkerReplication) IsEmpty() bool {
|
||||
return len(d.Status) == 0
|
||||
}
|
||||
|
||||
// DeleteReplication - whether versioned deletes are replicated - this
|
||||
// is a MinIO specific extension
|
||||
type DeleteReplication struct {
|
||||
Status Status `xml:"Status" json:"Status"` // should be set to "Disabled" by default
|
||||
}
|
||||
|
||||
// IsEmpty returns true if DeleteReplication is not set
|
||||
func (d DeleteReplication) IsEmpty() bool {
|
||||
return len(d.Status) == 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue