Add admin API to edit remote bucket target credentials (#10848)

This commit is contained in:
Poorna Krishnamoorthy
2020-11-24 19:09:05 -08:00
committed by GitHub
parent f96ed3769f
commit 3ad41fe89d
6 changed files with 82 additions and 29 deletions

View File

@@ -21,6 +21,7 @@ package main
import (
"context"
"fmt"
"log"
"github.com/minio/minio/pkg/auth"
@@ -44,9 +45,11 @@ func main() {
}
target := madmin.BucketTarget{Endpoint: "site2:9000", Credentials: creds, TargetBucket: "destbucket", IsSSL: false, Type: madmin.ReplicationArn, BandwidthLimit: 2 * 1024 * 1024}
// Set bucket target
if err := madmClnt.SetBucketTarget(ctx, "srcbucket", &target); err != nil {
arn, err := madmClnt.SetBucketTarget(ctx, "srcbucket", &target)
if err != nil {
log.Fatalln(err)
}
fmt.Println("replication target ARN is:", arn)
// List all bucket target(s)
target, err = madmClnt.ListBucketTargets(ctx, "srcbucket", "")
if err != nil {
@@ -57,6 +60,17 @@ func main() {
if err != nil {
log.Fatalln(err)
}
// update credentials for target
creds, err := auth.CreateCredentials("access-key2", "secret-key2")
if err != nil {
log.Fatalln(err)
}
target := madmin.BucketTarget{Endpoint: "site2:9000", Credentials: creds, SourceBucket: "srcbucket", TargetBucket: "destbucket", IsSSL: false, Arn: "arn:minio:ilm:us-east-1:3cbe15b8-82b9-44bc-a737-db9051ab359a:srcbucket"}
// update credentials on bucket target
if _, err := madmClnt.UpdateBucketTarget(ctx, &target); err != nil {
log.Fatalln(err)
}
// Remove bucket target
arn := "arn:minio:replica::ac66b2cf-dd8f-4e7e-a882-9a64132f0d59:dest"
if err := madmClnt.RemoveBucketTarget(ctx, "srcbucket", arn); err != nil {