Add enroll subcommand to ziti-probe

This commit is contained in:
Paul Lorenz
2020-09-29 14:10:21 -04:00
parent c9c2b34d90
commit 2bf0f96ea4
3 changed files with 18 additions and 6 deletions
+3 -2
View File
@@ -1,10 +1,10 @@
# Release 0.16.3
## Breaking CLI Change
* The `ziti edge enroll` and `ziti-tunnel enroll` subcommands no longer require a --jwt argument. Instead the JWT must be supplied as the first argument. So `ziti edge enroll --jwt /path/to/my.jwt` would become `ziti edge enroll /path/to/my.jwt`
* The `ziti edge enroll` and `ziti-tunnel enroll` subcommands no longer require a --jwt argument. Instead the JWT can be supplied as the first argument. So `ziti edge enroll --jwt /path/to/my.jwt` would become `ziti edge enroll /path/to/my.jwt`. For now the --jwt flag is still accepted as well.
## Deprecations
* The `ziti-enroller` command is deprecated and will removed in a future release. It will now display a DEPRECATION warning when it is run
* The `ziti-enroller` command is deprecated and will be removed in a future release. It will now display a DEPRECATION warning when it is run
## What's New
* [ziti#192 CAs default to 10yr expiration](https://github.com/openziti/ziti/issues/192)
@@ -14,6 +14,7 @@
* [ziti#151 enroll subcommand w/out args should print help](https://github.com/openziti/ziti/issues/192)
* Fix processing of `--configTypes all` in `ziti edge list services`
* Addressable Terminators and the eXtensible Terminator Validation framework
* GO Edge SDK now respects Service.EncryptionRequired setting
# Config File Changes
The following should be added to controller configuration files when using the Edge components:
+12 -4
View File
@@ -32,7 +32,7 @@ import (
// global state used by all subcommands are located here for easy discovery
var verbose bool
var outpath, keyPath, certPath, idname, caOverride string
var jwtpath, outpath, keyPath, certPath, idname, caOverride string
const verboseDesc = "Enable verbose logging."
const outpathDesc = "Output configuration file."
@@ -48,7 +48,7 @@ func NewEnrollCommand() *cobra.Command {
SilenceUsage: false,
Use: "enroll path/to/jwt",
Short: "enroll an identity",
Args: cobra.ExactArgs(1),
Args: cobra.MaximumNArgs(1),
PersistentPreRun: func(cmd *cobra.Command, args []string) {
if verbose {
logrus.SetLevel(logrus.DebugLevel)
@@ -63,11 +63,19 @@ func NewEnrollCommand() *cobra.Command {
PadLevelText: true,
})
logrus.SetReportCaller(false) // for enrolling don't bother with this
return processEnrollment(args[0])
if len(args) > 0 {
jwtpath = args[0]
}
if jwtpath == "" {
defer fmt.Printf("\nERROR: no jwt provided\n")
return cmd.Help()
}
return processEnrollment()
},
}
enrollSubCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, verboseDesc)
enrollSubCmd.Flags().StringVarP(&jwtpath, "jwt", "j", "", jwtpathDesc)
enrollSubCmd.Flags().StringVarP(&outpath, outFlag, "o", "", outpathDesc)
enrollSubCmd.Flags().StringVarP(&idname, "idname", "n", "", idnameDesc)
enrollSubCmd.Flags().StringVarP(&certPath, "cert", "c", "", certDesc)
@@ -85,7 +93,7 @@ func NewEnrollCommand() *cobra.Command {
return enrollSubCmd
}
func processEnrollment(jwtpath string) error {
func processEnrollment() error {
if strings.TrimSpace(outpath) == "" {
out, outErr := outPathFromJwt(jwtpath)
if outErr != nil {
+3
View File
@@ -19,6 +19,7 @@ package subcmd
import (
"fmt"
"github.com/michaelquigley/pfxlog"
"github.com/openziti/ziti/common/enrollment"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -26,6 +27,8 @@ import (
func init() {
root.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose logging")
root.PersistentFlags().StringVar(&logFormatter, "log-formatter", "", "Specify log formatter [json|pfxlog|text]")
root.AddCommand(enrollment.NewEnrollCommand())
}
var root = &cobra.Command{