Added replication bulk modal to buckets list (#665)
* Added replication bulk modal to buckets list * Disabled buttons & inputs in loading state Co-authored-by: Benjamin Perez <benjamin@bexsoft.net>
This commit is contained in:
@@ -26,7 +26,6 @@ import (
|
||||
|
||||
"github.com/minio/mc/pkg/probe"
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/replication"
|
||||
"github.com/minio/minio-go/v7/pkg/sse"
|
||||
|
||||
"errors"
|
||||
@@ -105,14 +104,6 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
|
||||
}
|
||||
return user_api.NewGetBucketReplicationOK().WithPayload(getBucketReplication)
|
||||
})
|
||||
// get bucket replication
|
||||
api.UserAPIAddBucketReplicationHandler = user_api.AddBucketReplicationHandlerFunc(func(params user_api.AddBucketReplicationParams, session *models.Principal) middleware.Responder {
|
||||
err := getAddBucketReplicationdResponse(session, params.BucketName, ¶ms)
|
||||
if err != nil {
|
||||
return user_api.NewAddBucketReplicationDefault(500).WithPayload(&models.Error{Code: 500, Message: swag.String(err.Error())})
|
||||
}
|
||||
return user_api.NewAddBucketReplicationCreated()
|
||||
})
|
||||
// enable bucket encryption
|
||||
api.UserAPIEnableBucketEncryptionHandler = user_api.EnableBucketEncryptionHandlerFunc(func(params user_api.EnableBucketEncryptionParams, session *models.Principal) middleware.Responder {
|
||||
if err := enableBucketEncryptionResponse(session, params); err != nil {
|
||||
@@ -160,61 +151,6 @@ func registerBucketsHandlers(api *operations.ConsoleAPI) {
|
||||
})
|
||||
}
|
||||
|
||||
func getAddBucketReplicationdResponse(session *models.Principal, bucketName string, params *user_api.AddBucketReplicationParams) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*20)
|
||||
defer cancel()
|
||||
|
||||
mClient, err := newMinioClient(session)
|
||||
if err != nil {
|
||||
log.Println("error creating MinIO Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a minioClient interface implementation
|
||||
// defining the client to be used
|
||||
minioClient := minioClient{client: mClient}
|
||||
|
||||
// we will tolerate this call failing
|
||||
cfg, err := minioClient.getBucketReplication(ctx, bucketName)
|
||||
if err != nil {
|
||||
log.Println("error versioning bucket:", err)
|
||||
}
|
||||
|
||||
// add rule
|
||||
|
||||
maxPrio := 0
|
||||
for _, r := range cfg.Rules {
|
||||
if r.Priority > maxPrio {
|
||||
maxPrio = r.Priority
|
||||
}
|
||||
}
|
||||
maxPrio++
|
||||
|
||||
s3Client, err := newS3BucketClient(session, bucketName, "")
|
||||
if err != nil {
|
||||
log.Println("error creating S3Client:", err)
|
||||
return err
|
||||
}
|
||||
// create a mc S3Client interface implementation
|
||||
// defining the client to be used
|
||||
mcClient := mcClient{client: s3Client}
|
||||
|
||||
opts := replication.Options{
|
||||
RoleArn: params.Body.Arn,
|
||||
Priority: fmt.Sprintf("%d", maxPrio),
|
||||
RuleStatus: "enable",
|
||||
//ID: cliCtx.String("id"),
|
||||
DestBucket: params.Body.DestinationBucket,
|
||||
Op: replication.AddOption,
|
||||
}
|
||||
|
||||
err2 := mcClient.setReplication(ctx, &cfg, opts)
|
||||
if err2 != nil {
|
||||
log.Println("error creating replication for bucket:", err2.Cause)
|
||||
return err2.Cause
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type VersionState string
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user