returnfmt.Errorf("Unable to interprete log level: %s",err)
}
returnnil
},
}
// Execute adds all child commands to the root command sets flags appropriately.
// This is called by main.main(). It only needs to happen once to the rootCmd.
funcExecute(verstring){
version=ver
iferr:=RootCmd.Execute();err!=nil{
fmt.Println(err)
os.Exit(-1)
}
}
funcinit(){
cobra.OnInitialize(initConfig)
RootCmd.PersistentFlags().StringVar(&cfg.ConfigFile,"config","","config file (default is $HOME/.config/vault-openvpn.yaml)")
RootCmd.PersistentFlags().StringVar(&cfg.VaultAddress,"vault-addr","https://127.0.0.1:8200","Vault API address")
RootCmd.PersistentFlags().StringVar(&cfg.VaultToken,"vault-token","","Specify a token to use (~/.vault-token file is taken into account)")
RootCmd.PersistentFlags().StringVar(&cfg.PKIMountPoint,"pki-mountpoint","/pki","Path the PKI provider is mounted to")
RootCmd.PersistentFlags().StringVar(&cfg.PKIRole,"pki-role","openvpn","Role defined in the PKI usable by the token and able to write the specified FQDN")
RootCmd.PersistentFlags().StringVar(&cfg.LogLevel,"log-level","info","Log level to use (debug, info, warning, error)")