From ce553d5cc0df004db5df75c8b4678a5fe5f1f680 Mon Sep 17 00:00:00 2001 From: "David J. Allen" Date: Thu, 11 Apr 2024 13:06:00 -0600 Subject: [PATCH] Fixed minor issues --- cmd/generate.go | 7 ++++--- cmd/root.go | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/generate.go b/cmd/generate.go index b109814..8040aaa 100644 --- a/cmd/generate.go +++ b/cmd/generate.go @@ -81,6 +81,7 @@ var generateCmd = &cobra.Command{ // NOTE: we probably don't want to hardcode the types, but should do for now ext := "" + contents := []byte{} if g.Type == "dhcp" { // fetch eths from SMD eths, err := client.FetchEthernetInterfaces() @@ -92,7 +93,7 @@ var generateCmd = &cobra.Command{ continue } // generate a new config from that data - b, err := g.GenerateDHCP(&config, eths) + contents, err = g.GenerateDHCP(&config, eths) if err != nil { logrus.Errorf("failed to generate DHCP config file: %v\n", err) continue @@ -117,14 +118,14 @@ var generateCmd = &cobra.Command{ fmt.Printf("%s\n", "") } else if outputPath != "" && targetCount == 1 { // write just a single file using template name - err := os.WriteFile(outputPath) + err := os.WriteFile(outputPath, contents, 0o644) if err != nil { logrus.Errorf("failed to write config to file: %v", err) continue } } else if outputPath != "" && targetCount > 1 { // write multiple files in directory using template name - err := os.WriteFile(fmt.Sprintf("%s/%s.%s", filepath.Clean(outputPath), g.Template, ext)) + err := os.WriteFile(fmt.Sprintf("%s/%s.%s", filepath.Clean(outputPath), g.Template, ext), contents, 0o644) if err != nil { logrus.Errorf("failed to write config to file: %v", err) continue diff --git a/cmd/root.go b/cmd/root.go index b36bfd2..89f92c8 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,7 +13,7 @@ var ( configPath string config configurator.Config targets []string - output string + outputPath string ) var rootCmd = &cobra.Command{