mirror of
https://github.com/minio/minio.git
synced 2025-11-21 02:09:08 -05:00
lifecycle: Assign unique id to rules with empty id (#15731)
This commit is contained in:
committed by
GitHub
parent
6e84283c66
commit
6f56ba80b3
@@ -25,6 +25,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/google/uuid"
|
||||
xhttp "github.com/minio/minio/internal/http"
|
||||
)
|
||||
|
||||
@@ -176,6 +177,22 @@ func (lc Lifecycle) HasActiveRules(prefix string, recursive bool) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// ParseLifecycleConfigWithID - parses for a Lifecycle config and assigns
|
||||
// unique id to rules with empty ID.
|
||||
func ParseLifecycleConfigWithID(r io.Reader) (*Lifecycle, error) {
|
||||
var lc Lifecycle
|
||||
if err := xml.NewDecoder(r).Decode(&lc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// assign a unique id for rules with empty ID
|
||||
for i := range lc.Rules {
|
||||
if lc.Rules[i].ID == "" {
|
||||
lc.Rules[i].ID = uuid.New().String()
|
||||
}
|
||||
}
|
||||
return &lc, nil
|
||||
}
|
||||
|
||||
// ParseLifecycleConfig - parses data in given reader to Lifecycle.
|
||||
func ParseLifecycleConfig(reader io.Reader) (*Lifecycle, error) {
|
||||
var lc Lifecycle
|
||||
|
||||
Reference in New Issue
Block a user