github.com/minio/madmin-go@v1.7.5/examples/kms-status.go (about)

     1  //go:build ignore
     2  // +build ignore
     3  
     4  //
     5  // MinIO Object Storage (c) 2021 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  package main
    21  
    22  import (
    23  	"context"
    24  	"log"
    25  
    26  	"github.com/minio/madmin-go"
    27  )
    28  
    29  func main() {
    30  	// Note: YOUR-ACCESSKEYID, YOUR-SECRETACCESSKEY and my-bucketname are
    31  	// dummy values, please replace them with original values.
    32  
    33  	// API requests are secure (HTTPS) if secure=true and insecure (HTTP) otherwise.
    34  	// New returns an MinIO Admin client object.
    35  	madmClnt, err := madmin.New("your-minio.example.com:9000", "YOUR-ACCESSKEYID", "YOUR-SECRETACCESSKEY", true)
    36  	if err != nil {
    37  		log.Fatalln(err)
    38  	}
    39  
    40  	status, err := madmClnt.GetKeyStatus(context.Background(), "") // empty string refers to the default master key
    41  	if err != nil {
    42  		log.Fatalln(err)
    43  	}
    44  
    45  	log.Printf("Key: %s\n", status.KeyID)
    46  	if status.EncryptionErr == "" {
    47  		log.Println("\t • Encryption ✔")
    48  	} else {
    49  		log.Printf("\t • Encryption failed: %s\n", status.EncryptionErr)
    50  	}
    51  	if status.UpdateErr == "" {
    52  		log.Println("\t • Re-wrap ✔")
    53  	} else {
    54  		log.Printf("\t • Re-wrap failed: %s\n", status.UpdateErr)
    55  	}
    56  	if status.DecryptionErr == "" {
    57  		log.Println("\t • Decryption ✔")
    58  	} else {
    59  		log.Printf("\t •  Decryption failed: %s\n", status.DecryptionErr)
    60  	}
    61  }