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:
parent
9031b6d204
commit
5d1ae10bae
1 changed files with 10 additions and 11 deletions
11
main.go
11
main.go
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue