33 lines
659 B
Go
33 lines
659 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"log"
|
|
|
|
openbao "github.com/openbao/openbao/api/v2"
|
|
)
|
|
|
|
func main(){
|
|
fmt.Println("Connecting...")
|
|
config := openbao.DefaultConfig()
|
|
config.Address = "http://127.0.0.1:8200"
|
|
|
|
client, err := openbao.NewClient(config)
|
|
if err != nil {
|
|
log.Fatalf("unable to initialize OpenBao client: %v", err)
|
|
}
|
|
|
|
client.SetToken("dev-only-token")
|
|
|
|
secretData := map[string]interface{}{
|
|
"password": "OpenBao123",
|
|
}
|
|
|
|
_, err = client.KVv2("secret").Put(context.Background(), "my-secret-password", secretData)
|
|
if err != nil {
|
|
log.Fatalf("unable to write secret: %v", err)
|
|
}
|
|
|
|
fmt.Println("Secret written successfully.")
|
|
}
|