1
0
Fork 0
mirror of https://github.com/Luzifer/vault-unseal.git synced 2024-10-18 08:04:20 +00:00

improve token parameter

This commit is contained in:
Knut Ahlers 2016-07-20 08:41:15 +02:00
parent 9031b6d204
commit 5d1ae10bae
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E

11
main.go
View file

@ -6,7 +6,6 @@ import (
"log"
"net/http"
"os"
"strings"
"time"
"github.com/Luzifer/rconfig"
@ -14,8 +13,7 @@ import (
var config = struct {
OneShot bool `flag:"oneshot,1" default:"false" description:"Only try once and exit after"`
SealTokensRaw string `flag:"tokens" default:"" description:"Tokens to try for unsealing the vault instance"`
SealTokens []string
SealTokens []string `flag:"tokens" default:"" description:"Tokens to try for unsealing the vault instance"`
VaultInstance string `flag:"instance" env:"VAULT_ADDR" default:"http://127.0.0.1:8200" description:"Vault instance to unlock"`
Sleep int `flag:"sleep" default:"30" description:"How long to wait between sealed-state checks"`
}{}
@ -26,12 +24,13 @@ func init() {
os.Exit(1)
}
if len(config.SealTokensRaw) == 0 {
if len(config.SealTokens) == 1 && config.SealTokens[0] == "" {
if len(rconfig.Args()) <= 1 {
log.Println("You must provide at least one token.")
os.Exit(1)
}
config.SealTokens = strings.Split(config.SealTokensRaw, ",")
config.SealTokens = rconfig.Args()[1:]
}
}
func main() {