From cd622112a8904a8019749a32d39c149e8eaf7a80 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Wed, 20 Feb 2019 20:22:22 +0100 Subject: [PATCH] feat: error when cert and key extension are identical without --domain-subdir. --- main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.go b/main.go index 0afcfae..ce5bb28 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,15 @@ func main() { Use: "dump", Short: "Dump Let's Encrypt certificates from Traefik", Long: `Dump the content of the "acme.json" file from Traefik to certificates.`, + PreRunE: func(cmd *cobra.Command, args []string) error { + crtExt := cmd.Flag("crt-ext").Value.String() + keyExt := cmd.Flag("key-ext").Value.String() + subDir, _ := strconv.ParseBool(cmd.Flag("domain-subdir").Value.String()) + if crtExt == keyExt && !subDir { + return fmt.Errorf("--crt-ext (%q) and --key-ext (%q) are identical, in this case --domain-subdir is required", crtExt, keyExt) + } + return nil + }, Run: func(cmd *cobra.Command, _ []string) { acmeFile := cmd.Flag("source").Value.String() dumpPath := cmd.Flag("dest").Value.String()