feat: Support configuration file for hmsecrets.
This commit is contained in:
1 parent
3b29c2cb1d
commit
03247415b2
12 files changed
+106
-48
No files matched your search
@@ -7,44 +7,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var apiBase string
|
||||
var caFile string
|
||||
var clientCert string
|
||||
var clientKey string
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().StringVar(
|
||||
&apiBase,
|
||||
"api-base",
|
||||
"",
|
||||
"base url for the service",
|
||||
)
|
||||
rootCmd.MarkPersistentFlagRequired("api-base")
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(
|
||||
&caFile,
|
||||
"ca-file",
|
||||
"",
|
||||
"CA cert file",
|
||||
)
|
||||
rootCmd.MarkPersistentFlagRequired("ca-file")
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(
|
||||
&clientCert,
|
||||
"client-cert",
|
||||
"",
|
||||
"certificate to be used for client mTLS auth",
|
||||
)
|
||||
rootCmd.MarkPersistentFlagRequired("client-cert")
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(
|
||||
&clientKey,
|
||||
"client-key",
|
||||
"",
|
||||
"private key for the certificate to be used for client mTLS auth",
|
||||
)
|
||||
rootCmd.MarkPersistentFlagRequired("client-key")
|
||||
}
|
||||
var conf config
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "hmsecrets",
|
||||
@@ -52,6 +15,15 @@ var rootCmd = &cobra.Command{
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
fmt.Printf("%+v\n", r)
|
||||
os.Exit(1)
|
||||
}
|
||||
}()
|
||||
|
||||
conf = mustLoadConfig()
|
||||
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
os.Exit(1)
|
||||
|
||||
Reference in new issue
Block a user