storj.io/minio@v0.0.0-20230509071714-0cbc90f649b1/pkg/madmin/examples/heal-bucket.go (about)

     1  //go:build ignore
     2  // +build ignore
     3  
     4  /*
     5   * MinIO Cloud Storage, (C) 2017 MinIO, Inc.
     6   *
     7   * Licensed under the Apache License, Version 2.0 (the "License");
     8   * you may not use this file except in compliance with the License.
     9   * You may obtain a copy of the License at
    10   *
    11   *     http://www.apache.org/licenses/LICENSE-2.0
    12   *
    13   * Unless required by applicable law or agreed to in writing, software
    14   * distributed under the License is distributed on an "AS IS" BASIS,
    15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    16   * See the License for the specific language governing permissions and
    17   * limitations under the License.
    18   *
    19   */
    20  
    21  package main
    22  
    23  import (
    24  	"context"
    25  	"log"
    26  
    27  	"storj.io/minio/pkg/madmin"
    28  )
    29  
    30  func main() {
    31  	// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY are
    32  	// dummy values, please replace them with original values.
    33  
    34  	// API requests are secure (HTTPS) if secure=true and insecure (HTTP) otherwise.
    35  	// New returns an MinIO Admin client object.
    36  	madmClnt, err := madmin.New("your-minio.example.com:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
    37  	if err != nil {
    38  		log.Fatalln(err)
    39  	}
    40  
    41  	// Heal bucket mybucket - dry run
    42  	isDryRun := true
    43  	err = madmClnt.HealBucket(context.Background(), "mybucket", isDryRun)
    44  	if err != nil {
    45  		log.Fatalln(err)
    46  
    47  	}
    48  
    49  	// Heal bucket mybucket - for real this time.
    50  	isDryRun := false
    51  	err = madmClnt.HealBucket(context.Background(), "mybucket", isDryRun)
    52  	if err != nil {
    53  		log.Fatalln(err)
    54  	}
    55  
    56  	log.Println("successfully healed mybucket")
    57  }