fix: Accept the CN through a flag

This commit is contained in:
jmug committed 2026-10-22 22:06:32 -07:00
1 parent 3c83ac6e7f
commit 068db76488
2 files changed
+13 -3

No files matched your search

+4 -1
View File
@@ -8,6 +8,9 @@ import (
var Name string
var OutDir string
// Needed by all subcommands that generate certificates.
var CommonName string
func init() {
rootCmd.AddCommand(generateCmd)
@@ -17,7 +20,7 @@ func init() {
"name",
"n",
"",
"name of the artifact being benerated",
"name of the artifact being generated",
)
generateCmd.MarkPersistentFlagRequired("name")
+9 -2
View File
@@ -17,6 +17,14 @@ import (
func init() {
generateCmd.AddCommand(generateCACmd)
generateCACmd.Flags().StringVar(
&CommonName,
"common-name",
"",
"Common Name for the CA",
)
generateCACmd.MarkFlagRequired("common-name")
}
var generateCACmd = &cobra.Command{
@@ -35,7 +43,7 @@ var generateCACmd = &cobra.Command{
SerialNumber: sn,
Subject: pkix.Name{
// TODO: Accept common name as a flag.
CommonName: "Some Common Name",
CommonName: CommonName,
},
// Valid starting now and for 10 years.
NotBefore: time.Now(),
@@ -77,7 +85,6 @@ var generateCACmd = &cobra.Command{
return err
}
// Write ca.crt to Output
return nil
},
}