mirror of
https://github.com/davidallendj/configurator.git
synced 2025-12-20 03:27:02 -07:00
Fixed minor issues
This commit is contained in:
parent
80c9eb29a6
commit
ce553d5cc0
2 changed files with 5 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ var (
|
|||
configPath string
|
||||
config configurator.Config
|
||||
targets []string
|
||||
output string
|
||||
outputPath string
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue