package main import ( "flag" "github.com/pborman/uuid" ) // nolint:gochecknoglobals var ( createKeyCmd = false getPublicKeyCmd = false createTokenCmd = false debug = false keyFile string tokenIssuer string tokenPeerID = uuid.New() keySize = 2048 ) // nolint:gochecknoinits func init() { flag.BoolVar( &createKeyCmd, "create-key", createKeyCmd, "Create a new encrypted PEM private key to sign authentication tokens", ) flag.BoolVar( &createTokenCmd, "create-token", createTokenCmd, "Create a new signed authentication token", ) flag.BoolVar( &getPublicKeyCmd, "get-public-key", getPublicKeyCmd, "Get the PEM encoded public key associated with the private key", ) flag.BoolVar(&debug, "debug", debug, "Debug mode") flag.StringVar(&keyFile, "key", keyFile, "Path to the encrypted PEM encoded key") flag.StringVar(&tokenIssuer, "token-issuer", tokenIssuer, "Token issuer") flag.StringVar(&tokenPeerID, "token-peer-id", tokenPeerID, "Token peer ID") flag.IntVar(&keySize, "key-size", keySize, "Size of the private key") } func main() { flag.Parse() switch { case createKeyCmd: createKey() case getPublicKeyCmd: getPublicKey() case createTokenCmd: createToken() default: flag.Usage() } }