Skip to content

Commit

Permalink
Add option to prefix output files
Browse files Browse the repository at this point in the history
  • Loading branch information
tomdoherty committed Oct 20, 2020
1 parent cd75e7e commit 49b138f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
/adssl
/dist
5 changes: 3 additions & 2 deletions adssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ type Request struct {
Country, Province, Locality string
DNSNames string
IPAddresses string
Prefix string
CsrOnly bool
}

Expand Down Expand Up @@ -279,8 +280,8 @@ func New(s Server, r Request) (Certificate, error) {
return c, fmt.Errorf("fatal: %v", err)
}
if r.CsrOnly {
WriteFile("tls.csr", c.CertificateRequest)
WriteFile("tls.key", c.PrivateKeyString)
WriteFile(r.Prefix+"tls.csr", c.CertificateRequest)
WriteFile(r.Prefix+"tls.key", c.PrivateKeyString)
return c, nil
}
if s.Endpoint == "" || s.Username == "" || s.Password == "" {
Expand Down
15 changes: 11 additions & 4 deletions cmd/adssl.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func main() {
&cli.StringFlag{
Name: "endpoint",
Aliases: []string{"e"},
Usage: "endpoint to use",
Usage: "endpoint url to use",
EnvVars: []string{"ENDPOINT"},
Destination: &s.Endpoint,
},
Expand Down Expand Up @@ -83,6 +83,13 @@ func main() {
EnvVars: []string{"IPADDRS"},
Destination: &r.IPAddresses,
},
&cli.StringFlag{
Name: "prefix",
Aliases: []string{"f"},
Usage: "prefix output files",
EnvVars: []string{"PREFIX"},
Destination: &r.Prefix,
},
&cli.BoolFlag{
Name: "csronly",
Aliases: []string{"O"},
Expand All @@ -107,9 +114,9 @@ func main() {
adssl.PrintKubeSecret(os.Stdout, res)
} else {
if !r.CsrOnly {
adssl.WriteFile("ca.crt", res.CaCert)
adssl.WriteFile("tls.key", res.PrivateKeyString)
adssl.WriteFile("tls.crt", res.Result)
adssl.WriteFile(r.Prefix+"ca.crt", res.CaCert)
adssl.WriteFile(r.Prefix+"tls.key", res.PrivateKeyString)
adssl.WriteFile(r.Prefix+"tls.crt", res.Result)
}
}

Expand Down

0 comments on commit 49b138f

Please sign in to comment.