Remove trailing newline from wwlog

I noticed that some wwlog calls included a trailing newline, but others
did not. I tested both in isolation and discovered that the behavior was
consistent regardless of whether a trailing newline was included. I
further confirmed in code that wwlog appends a trailing newline
automatically if it is not present; so a trailing newline is unnecessary
in individual calls.

This commit removes trailing newlines from all calls to make them
consistent. It also replaces two calls to wwlog.Printf. (see #534)

Signed-off-by: Jonathon Anderson <janderson@ciq.co>
This commit is contained in:
Jonathon Anderson
2022-09-15 12:38:03 -06:00
parent fc39209fbb
commit 0b3e862bea
58 changed files with 327 additions and 327 deletions

View File

@@ -19,28 +19,28 @@ func Dhcp() error {
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
if !controller.Dhcp.Enabled {
wwlog.Info("This system is not configured as a Warewulf DHCP controller\n")
wwlog.Info("This system is not configured as a Warewulf DHCP controller")
os.Exit(1)
}
if controller.Dhcp.RangeStart == "" {
wwlog.Error("Configuration is not defined: `dhcpd range start`\n")
wwlog.Error("Configuration is not defined: `dhcpd range start`")
os.Exit(1)
}
if controller.Dhcp.RangeEnd == "" {
wwlog.Error("Configuration is not defined: `dhcpd range end`\n")
wwlog.Error("Configuration is not defined: `dhcpd range end`")
os.Exit(1)
}
if controller.Warewulf.EnableHostOverlay {
err = overlay.BuildHostOverlay()
if err != nil {
wwlog.Warn("host overlay could not be built: %s\n", err)
wwlog.Warn("host overlay could not be built: %s", err)
}
} else {
wwlog.Info("host overlays are disabled, did not modify/create dhcpd configuration")

View File

@@ -16,7 +16,7 @@ Creates '/etc/hosts' from the host template.
*/
func Hostfile() error {
if !(util.IsFile(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))) {
wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay\n")
wwlog.Error("'the overlay template '/etc/hosts.ww' does not exists in 'host' overlay")
os.Exit(1)
}
var nodeInfo node.NodeInfo
@@ -27,12 +27,12 @@ func Hostfile() error {
path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"),
tstruct)
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
info, err := os.Stat(path.Join(overlay.OverlaySourceDir("host"), "/host/etc/hosts.ww"))
if err != nil {
wwlog.Printf(wwlog.ERROR, "%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}

View File

@@ -19,7 +19,7 @@ func NFS() error {
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
os.Exit(1)
}
@@ -30,7 +30,7 @@ func NFS() error {
if controller.Warewulf.EnableHostOverlay {
err = overlay.BuildHostOverlay()
if err != nil {
wwlog.Warn("host overlay could not be built: %s\n", err)
wwlog.Warn("host overlay could not be built: %s", err)
}
} else {
wwlog.Info("host overlays are disabled, did not modify exports")

View File

@@ -19,7 +19,7 @@ func SSH() error {
err := os.MkdirAll(path.Join(buildconfig.SYSCONFDIR(), "warewulf/keys"), 0755)
if err != nil {
wwlog.Error("Could not create base directory: %s\n", err)
wwlog.Error("Could not create base directory: %s", err)
os.Exit(1)
}
@@ -27,10 +27,10 @@ func SSH() error {
keytype := "ssh_host_" + k + "_key"
if !util.IsFile(path.Join(wwkeydir, keytype)) {
fmt.Printf("Setting up key: %s\n", keytype)
wwlog.Debug("Creating new %s key\n", keytype)
wwlog.Debug("Creating new %s key", keytype)
err = util.ExecInteractive("ssh-keygen", "-q", "-t", k, "-f", path.Join(wwkeydir, keytype), "-C", "", "-N", "")
if err != nil {
wwlog.Error("Failed to exec ssh-keygen: %s\n", err)
wwlog.Error("Failed to exec ssh-keygen: %s", err)
return errors.Wrap(err, "failed to exec ssh-keygen command")
}
} else {
@@ -43,7 +43,7 @@ func SSH() error {
homeDir, err := os.UserHomeDir()
if err != nil {
wwlog.Error("Could not obtain the user's home directory: %s\n", err)
wwlog.Error("Could not obtain the user's home directory: %s", err)
os.Exit(1)
}

View File

@@ -16,13 +16,13 @@ var tftpdir string = path.Join(buildconfig.TFTPDIR(), "warewulf")
func TFTP() error {
controller, err := warewulfconf.New()
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
return err
}
err = os.MkdirAll(tftpdir, 0755)
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
return err
}
@@ -30,20 +30,20 @@ func TFTP() error {
for _, f := range [4]string{"x86_64.efi", "x86_64.kpxe", "arm64.efi"} {
err = util.SafeCopyFile(path.Join(buildconfig.DATADIR(), "warewulf", "ipxe", f), path.Join(tftpdir, f))
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
return err
}
}
if !controller.Tftp.Enabled {
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf\n")
wwlog.Info("Warewulf does not auto start TFTP services due to disable by warewulf.conf")
os.Exit(0)
}
fmt.Printf("Enabling and restarting the TFTP services\n")
err = util.SystemdStart(controller.Tftp.SystemdName)
if err != nil {
wwlog.Error("%s\n", err)
wwlog.Error("%s", err)
return err
}