29 lines
585 B
Go
29 lines
585 B
Go
package main
|
|
|
|
import (
|
|
"log"
|
|
"log/slog"
|
|
"time"
|
|
|
|
"github.com/hashicorp/vault-client-go"
|
|
)
|
|
|
|
// vault cmd args: >vault server -dev -dev-root-token-id="my-token"
|
|
|
|
func main() {
|
|
slog.Info("run tests in tests/ with >go test")
|
|
// prepare a client with the given base address
|
|
client, err := vault.New(
|
|
vault.WithAddress("http://localhost:8200"),
|
|
vault.WithRequestTimeout(30*time.Second),
|
|
)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
log.Println("client prepared")
|
|
|
|
// authenticate with a root token (insecure)
|
|
if err := client.SetToken("my-token"); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|