Skip to content

Commit

Permalink
Move creation of default data into separate function
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Kosegi <[email protected]>
  • Loading branch information
rkosegi committed Mar 3, 2024
1 parent 350484c commit beb3095
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pkg/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,22 @@ func validateCa(d *createCaData) error {
return nil
}

func defData(w io.Writer, isCA bool) commonCreateData {
d := commonCreateData{
w: w,
bits: 4096,
dir: ".",
validYears: 1,
}
if isCA {
d.validYears = 2
}
return d
}

func newCaSubCommand(w io.Writer) *cobra.Command {
d := &createCaData{
commonCreateData: commonCreateData{
w: w,
bits: 4096,
dir: ".",
validYears: 2,
},
commonCreateData: defData(w, true),
}
cmd := &cobra.Command{
Use: "ca",
Expand All @@ -140,12 +148,7 @@ func newCaSubCommand(w io.Writer) *cobra.Command {

func newLeafSubCommand(w io.Writer) *cobra.Command {
d := &createLeafData{
commonCreateData: commonCreateData{
w: w,
bits: 4096,
dir: ".",
validYears: 2,
},
commonCreateData: defData(w, false),
}
cmd := &cobra.Command{
Use: "leaf",
Expand Down

0 comments on commit beb3095

Please sign in to comment.