summaryrefslogtreecommitdiff
path: root/modules/caddypki/command.go
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2023-11-01 17:57:48 +0100
committerTom Barrett <tom@tombarrett.xyz>2023-11-01 18:11:33 +0100
commit240c3d1338415e5d82ef7ca0e52c4284be6441bd (patch)
tree4b0ee5d208c2cdffa78d65f1b0abe0ec85f15652 /modules/caddypki/command.go
parent73e78ab226f21e6c6c68961af88c4ab9c746f4f4 (diff)
parent0e204b730aa2b1fa0835336b1117eff8c420f713 (diff)
vbump to v2.7.5HEADcaddy-cgi
Diffstat (limited to 'modules/caddypki/command.go')
-rw-r--r--modules/caddypki/command.go42
1 files changed, 20 insertions, 22 deletions
diff --git a/modules/caddypki/command.go b/modules/caddypki/command.go
index cb86c93..b7fa1bb 100644
--- a/modules/caddypki/command.go
+++ b/modules/caddypki/command.go
@@ -18,21 +18,22 @@ import (
"crypto/x509"
"encoding/json"
"encoding/pem"
- "flag"
"fmt"
"net/http"
"os"
"path"
- "github.com/caddyserver/caddy/v2"
- caddycmd "github.com/caddyserver/caddy/v2/cmd"
"github.com/smallstep/truststore"
+ "github.com/spf13/cobra"
+
+ caddycmd "github.com/caddyserver/caddy/v2/cmd"
+
+ "github.com/caddyserver/caddy/v2"
)
func init() {
caddycmd.RegisterCommand(caddycmd.Command{
Name: "trust",
- Func: cmdTrust,
Usage: "[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]",
Short: "Installs a CA certificate into local trust stores",
Long: `
@@ -53,19 +54,17 @@ This command will attempt to connect to Caddy's admin API running at
'` + caddy.DefaultAdminListen + `' to fetch the root certificate. You may
explicitly specify the --address, or use the --config flag to load
the admin address from your config, if not using the default.`,
- Flags: func() *flag.FlagSet {
- fs := flag.NewFlagSet("trust", flag.ExitOnError)
- fs.String("ca", "", "The ID of the CA to trust (defaults to 'local')")
- fs.String("address", "", "Address of the administration API listener (if --config is not used)")
- fs.String("config", "", "Configuration file (if --address is not used)")
- fs.String("adapter", "", "Name of config adapter to apply (if --config is used)")
- return fs
- }(),
+ CobraFunc: func(cmd *cobra.Command) {
+ cmd.Flags().StringP("ca", "", "", "The ID of the CA to trust (defaults to 'local')")
+ cmd.Flags().StringP("address", "", "", "Address of the administration API listener (if --config is not used)")
+ cmd.Flags().StringP("config", "c", "", "Configuration file (if --address is not used)")
+ cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (if --config is used)")
+ cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdTrust)
+ },
})
caddycmd.RegisterCommand(caddycmd.Command{
Name: "untrust",
- Func: cmdUntrust,
Usage: "[--cert <path>] | [[--ca <id>] [--address <listen>] [--config <path> [--adapter <name>]]]",
Short: "Untrusts a locally-trusted CA certificate",
Long: `
@@ -89,15 +88,14 @@ will attempt to connect to the Caddy's admin API running at
'` + caddy.DefaultAdminListen + `' to fetch the root certificate.
You may explicitly specify the --address, or use the --config flag
to load the admin address from your config, if not using the default.`,
- Flags: func() *flag.FlagSet {
- fs := flag.NewFlagSet("untrust", flag.ExitOnError)
- fs.String("cert", "", "The path to the CA certificate to untrust")
- fs.String("ca", "", "The ID of the CA to untrust (defaults to 'local')")
- fs.String("address", "", "Address of the administration API listener (if --config is not used)")
- fs.String("config", "", "Configuration file (if --address is not used)")
- fs.String("adapter", "", "Name of config adapter to apply (if --config is used)")
- return fs
- }(),
+ CobraFunc: func(cmd *cobra.Command) {
+ cmd.Flags().StringP("cert", "p", "", "The path to the CA certificate to untrust")
+ cmd.Flags().StringP("ca", "", "", "The ID of the CA to untrust (defaults to 'local')")
+ cmd.Flags().StringP("address", "", "", "Address of the administration API listener (if --config is not used)")
+ cmd.Flags().StringP("config", "c", "", "Configuration file (if --address is not used)")
+ cmd.Flags().StringP("adapter", "a", "", "Name of config adapter to apply (if --config is used)")
+ cmd.RunE = caddycmd.WrapCommandFuncForCobra(cmdUntrust)
+ },
})
}