1
0
Fork 0
mirror of https://github.com/Luzifer/vault-openvpn.git synced 2024-11-09 00:30:05 +00:00
vault-openvpn/cmd/client.go
Knut Ahlers 0c61a521c1
Switch to cobra as a CLI framework
Signed-off-by: Knut Ahlers <knut@ahlers.me>
2018-05-27 12:02:56 +02:00

33 lines
1 KiB
Go

package cmd
import (
"errors"
"time"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// clientCmd represents the client command
var clientCmd = &cobra.Command{
Use: "client",
Short: "Generate certificate and output client config",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) != 1 || !validateFQDN(args[0]) {
return errors.New("You need to provide a valid FQDN")
}
return generateCertificateConfig("client.conf", args[0])
},
}
func init() {
RootCmd.AddCommand(clientCmd)
clientCmd.Flags().BoolVar(&cfg.AutoRevoke, "auto-revoke", true, "Automatically revoke older certificates for this FQDN")
clientCmd.Flags().DurationVar(&cfg.CertTTL, "ttl", 8760*time.Hour, "Set the TTL for this certificate")
clientCmd.Flags().StringVar(&cfg.OVPNKey, "ovpn-key", "", "Specify a secret name that holds an OpenVPN shared key")
clientCmd.Flags().StringVar(&cfg.TemplatePath, "template-path", ".", "Path to read the client.conf / server.conf template from")
viper.BindPFlags(clientCmd.Flags())
}