diff --git a/cmd/config.go b/cmd/config.go index 05e183d..f56c34c 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -1,8 +1,7 @@ package cmd import ( - "fmt" - + "github.com/rs/zerolog/log" "github.com/spf13/cobra" "github.com/OpenCHAMI/configurator/pkg/config" @@ -20,7 +19,7 @@ var configCmd = &cobra.Command{ for _, path := range args { // check and make sure something doesn't exist first if exists, err := util.PathExists(path); exists || err != nil { - fmt.Printf("file or directory exists\n") + log.Error().Err(err).Msg("file or directory exists") continue } config.SaveDefault(path) diff --git a/go.mod b/go.mod index cea28f4..40878bf 100644 --- a/go.mod +++ b/go.mod @@ -41,4 +41,3 @@ require ( golang.org/x/text v0.16.0 // indirect ) -replace github.com/OpenCHAMI/configurator/pkg => ./pkg diff --git a/pkg/client/smd.go b/pkg/client/smd.go index 9a01401..7b001c2 100644 --- a/pkg/client/smd.go +++ b/pkg/client/smd.go @@ -8,6 +8,7 @@ import ( "net/http" configurator "github.com/OpenCHAMI/configurator/pkg" + "github.com/caarlos0/log" ) // An struct that's meant to extend functionality of the base HTTP client by @@ -57,7 +58,7 @@ func (client *SmdClient) FetchEthernetInterfaces(verbose bool) ([]configurator.E // print what we got if verbose is set if verbose { - fmt.Printf("Ethernet Interfaces: %v\n", string(bytes)) + log.Info().Str("ethernet_interfaces", string(bytes)).Msg("found interfaces") } return eths, nil @@ -99,7 +100,7 @@ func (client *SmdClient) FetchComponents(verbose bool) ([]configurator.Component // print what we got if verbose is set if verbose { - fmt.Printf("Components: %v\n", string(bytes)) + log.Info().Str("components", string(bytes)).Msg("found components") } return comps, nil @@ -138,7 +139,7 @@ func (client *SmdClient) FetchRedfishEndpoints(verbose bool) ([]configurator.Red // show the final result if verbose { - fmt.Printf("Redfish endpoints: %v\n", string(b)) + log.Info().Str("redfish_endpoints", string(b)).Msg("found redfish endpoints") } return eps, nil diff --git a/pkg/generator/dhcpd.go b/pkg/generator/dhcpd.go index 7425a57..cc32a48 100644 --- a/pkg/generator/dhcpd.go +++ b/pkg/generator/dhcpd.go @@ -54,10 +54,6 @@ func (g *DHCPd) Generate(config *config.Config, params Params) (FileMap, error) computeNodes += fmt.Sprintf("host %s { hardware ethernet %s; fixed-address %s} ", eth.ComponentId, eth.MacAddress, eth.IpAddresses[0]) } computeNodes += "# =====================================================================" - - if params.Verbose { - fmt.Printf("") - } return ApplyTemplates(Mappings{ "plugin_name": g.GetName(), "plugin_version": g.GetVersion(), diff --git a/pkg/generator/generator.go b/pkg/generator/generator.go index 19fe3fe..b7d5fa8 100644 --- a/pkg/generator/generator.go +++ b/pkg/generator/generator.go @@ -143,7 +143,7 @@ func LoadPlugins(dirpath string, opts ...Option) (map[string]Generator, error) { // show the plugins found if verbose flag is set if params.Verbose { - fmt.Printf("-- found plugin '%s'\n", gen.GetName()) + log.Info().Str("plugin_name", gen.GetName()).Msg("found plugin") } // map each generator plugin by name for lookup diff --git a/tests/generate_test.go b/tests/generate_test.go index f458ebc..21ff978 100644 --- a/tests/generate_test.go +++ b/tests/generate_test.go @@ -23,8 +23,6 @@ var ( err error ) -const () - // A valid test generator that implements the `Generator` interface. type TestGenerator struct{}