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
|
// NOTE: we probably don't want to hardcode the types, but should do for now
|
||||||
ext := ""
|
ext := ""
|
||||||
|
contents := []byte{}
|
||||||
if g.Type == "dhcp" {
|
if g.Type == "dhcp" {
|
||||||
// fetch eths from SMD
|
// fetch eths from SMD
|
||||||
eths, err := client.FetchEthernetInterfaces()
|
eths, err := client.FetchEthernetInterfaces()
|
||||||
|
|
@ -92,7 +93,7 @@ var generateCmd = &cobra.Command{
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// generate a new config from that data
|
// generate a new config from that data
|
||||||
b, err := g.GenerateDHCP(&config, eths)
|
contents, err = g.GenerateDHCP(&config, eths)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failed to generate DHCP config file: %v\n", err)
|
logrus.Errorf("failed to generate DHCP config file: %v\n", err)
|
||||||
continue
|
continue
|
||||||
|
|
@ -117,14 +118,14 @@ var generateCmd = &cobra.Command{
|
||||||
fmt.Printf("%s\n", "")
|
fmt.Printf("%s\n", "")
|
||||||
} else if outputPath != "" && targetCount == 1 {
|
} else if outputPath != "" && targetCount == 1 {
|
||||||
// write just a single file using template name
|
// write just a single file using template name
|
||||||
err := os.WriteFile(outputPath)
|
err := os.WriteFile(outputPath, contents, 0o644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Errorf("failed to write config to file: %v", err)
|
logrus.Errorf("failed to write config to file: %v", err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
} else if outputPath != "" && targetCount > 1 {
|
} else if outputPath != "" && targetCount > 1 {
|
||||||
// write multiple files in directory using template name
|
// 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 {
|
if err != nil {
|
||||||
logrus.Errorf("failed to write config to file: %v", err)
|
logrus.Errorf("failed to write config to file: %v", err)
|
||||||
continue
|
continue
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ var (
|
||||||
configPath string
|
configPath string
|
||||||
config configurator.Config
|
config configurator.Config
|
||||||
targets []string
|
targets []string
|
||||||
output string
|
outputPath string
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
var rootCmd = &cobra.Command{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue