ziti unwrap now defaults the output file names

This commit is contained in:
Andrew Martinez
2021-08-20 10:09:52 -04:00
parent ac047f3cae
commit b2ca9127a3
2 changed files with 28 additions and 6 deletions
+1
View File
@@ -5,6 +5,7 @@
* Bug fix: Fabric v0.16.93 fixes `xgress.GetCircuit` to provide a `ctrl not ready` error response when requests arrive before the router is fully online.
* Bug fix: Ziti CLI will no longer truncate paths on logins with explicit URLs
* Bug fix: Ziti CLI will now correctly check the proper lengths of sha512 hashes in hex format
* Feature: Ziti CLI `unwrap` command for identity json files will now default the output file names
* Feature: Ziti CLI improvements
* New interactive tutorial covering creating your first service. Run using: `ziti edge tutorial first-service`
* You can now delete multiple entities at once, by providing multiple ids. Ex: `ziti edge delete services one two` or `ziti edge delete service one two` will both work.
+27 -6
View File
@@ -18,15 +18,30 @@ type IdentityConfigFile struct {
}
func NewUnwrapIdentityFileCommand(f cmdutil.Factory, out io.Writer, errOut io.Writer) *cobra.Command {
return &cobra.Command{
Use: "unwrap <identity_file> <out_cert> <out_private_key> <out_ca>",
outCertFile := ""
outKeyFile := ""
outCaFile := ""
cmd := &cobra.Command{
Use: "unwrap <identity_file>",
Short: "unwrap a Ziti Identity file into its separate pieces (supports PEM only)",
Args: cobra.ExactArgs(4),
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
identityFile := args[0]
outCertFile := args[1]
outKeyFile := args[2]
outCaFile := args[3]
rootFileName := strings.TrimSuffix(identityFile, ".json")
if outCertFile == "" {
outCertFile = rootFileName + ".cert"
}
if outKeyFile == "" {
outKeyFile = rootFileName + ".key"
}
if outCaFile == "" {
outCaFile = rootFileName + ".ca"
}
identityJson, err := ioutil.ReadFile(identityFile)
@@ -72,4 +87,10 @@ func NewUnwrapIdentityFileCommand(f cmdutil.Factory, out io.Writer, errOut io.Wr
}
},
}
cmd.Flags().StringVarP(&outCertFile, "cert", "", "", "output certificate file, defaults to ./<root>.cert")
cmd.Flags().StringVarP(&outKeyFile, "key", "", "", "output private key file, defaults to ./<root>.key")
cmd.Flags().StringVarP(&outCaFile, "ca", "", "", "output ca bundle file, defaults to ./<root>.ca")
return cmd
}