Clean up show and add safe copy

Signed-off-by: jcsiadal <jeremy.c.siadal@intel.com>
This commit is contained in:
jcsiadal
2022-02-16 16:26:15 +00:00
parent 67b8018d69
commit bfc48f7c72
7 changed files with 197 additions and 193 deletions

View File

@@ -6,27 +6,39 @@ import (
"github.com/pkg/errors"
)
func Configure(s string, v bool) error {
if !v {
func Configure(serv string, show bool) error {
if !show {
fmt.Printf("################################################################################\n")
fmt.Printf("Configuring: %s\n", s)
fmt.Printf("Configuring: %s\n", serv)
}
var err error
switch s {
switch serv {
case "DHCP":
err = configureDHCP(v)
err = configureDHCP(show)
case "hosts":
err = configureHosts(v)
err = configureHosts(show)
case "NFS":
err = configureNFS(v)
if !show {
err = configureNFS()
} else {
showNFS()
}
case "SSH":
err = configureSSH(v)
if !show {
err = configureSSH()
} else {
fmt.Printf("'ssh -s' is not yet implemented.\n")
}
case "TFTP":
err = configureTFTP(v)
if !show {
err = configureTFTP()
} else {
fmt.Printf("'tftp -s' is not yet implemented.\n")
}
}
if err != nil {
return errors.Wrap(err, "Failed to configure "+s)
return errors.Wrap(err, "Failed to execute configure on "+serv)
}
return nil
}