1
0
Fork 0
mirror of https://github.com/Luzifer/vault-unseal.git synced 2024-12-22 22:01: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

21
main.go
View file

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