From ce085dc4cd11c2ca650ff373afa599417c77bdad Mon Sep 17 00:00:00 2001 From: mmetc <92726601+mmetc@users.noreply.github.com> Date: Tue, 17 Sep 2024 13:19:14 +0200 Subject: [PATCH] logs and user messages: use "parse" and "serialize" instead of marshal/unmarshal (#3240) --- cmd/crowdsec-cli/clialert/alerts.go | 4 ++-- cmd/crowdsec-cli/clibouncer/bouncers.go | 6 +++--- cmd/crowdsec-cli/clicapi/capi.go | 2 +- cmd/crowdsec-cli/cliconsole/console.go | 6 +++--- cmd/crowdsec-cli/clihub/items.go | 4 ++-- cmd/crowdsec-cli/clihubtest/create.go | 2 +- cmd/crowdsec-cli/cliitem/appsec.go | 2 +- cmd/crowdsec-cli/clilapi/lapi.go | 2 +- cmd/crowdsec-cli/climachine/machines.go | 8 ++++---- cmd/crowdsec-cli/climetrics/list.go | 2 +- cmd/crowdsec-cli/climetrics/store.go | 2 +- cmd/crowdsec-cli/clinotifications/notifications.go | 8 ++++---- cmd/crowdsec-cli/clisetup/setup.go | 2 +- cmd/crowdsec-cli/clisimulation/simulation.go | 4 ++-- cmd/crowdsec-cli/config_backup.go | 2 +- cmd/crowdsec-cli/config_restore.go | 2 +- cmd/crowdsec-cli/config_show.go | 6 +++--- cmd/crowdsec/pour.go | 4 ++-- cmd/notification-file/main.go | 2 +- pkg/acquisition/acquisition.go | 2 +- pkg/acquisition/modules/appsec/appsec.go | 2 +- pkg/acquisition/modules/kafka/kafka.go | 2 +- pkg/acquisition/modules/kubernetesaudit/k8s_audit.go | 2 +- .../modules/wineventlog/wineventlog_windows.go | 2 +- pkg/alertcontext/config.go | 2 +- pkg/apiserver/apic_metrics.go | 4 ++-- pkg/apiserver/controllers/v1/alerts.go | 2 +- pkg/apiserver/controllers/v1/usagemetrics.go | 2 +- pkg/apiserver/papi.go | 6 +++--- pkg/appsec/loader.go | 2 +- pkg/csconfig/api.go | 4 ++-- pkg/csconfig/api_test.go | 2 +- pkg/csconfig/config_test.go | 2 +- pkg/csconfig/console.go | 2 +- pkg/csconfig/crowdsec_service.go | 2 +- pkg/csconfig/simulation.go | 2 +- pkg/csconfig/simulation_test.go | 4 ++-- pkg/csplugin/broker_test.go | 4 ++-- pkg/cwhub/hub.go | 2 +- pkg/cwhub/sync.go | 2 +- pkg/database/ent/machine.go | 4 ++-- pkg/database/errors.go | 4 ++-- pkg/hubtest/coverage.go | 4 ++-- pkg/hubtest/hubtest_item.go | 4 ++-- pkg/leakybucket/buckets_test.go | 4 ++-- pkg/leakybucket/manager_load.go | 2 +- pkg/leakybucket/manager_run.go | 4 ++-- pkg/leakybucket/overflows.go | 6 +++--- pkg/leakybucket/timemachine.go | 2 +- pkg/leakybucket/trigger.go | 2 +- pkg/parser/enrich_date.go | 4 ++-- pkg/parser/enrich_unmarshal.go | 2 +- pkg/parser/parsing_test.go | 2 +- pkg/setup/detect.go | 2 +- pkg/setup/install.go | 2 +- test/bats/07_setup.bats | 2 +- 56 files changed, 87 insertions(+), 87 deletions(-) diff --git a/cmd/crowdsec-cli/clialert/alerts.go b/cmd/crowdsec-cli/clialert/alerts.go index 757a84927e5..006d7ac7d8c 100644 --- a/cmd/crowdsec-cli/clialert/alerts.go +++ b/cmd/crowdsec-cli/clialert/alerts.go @@ -521,14 +521,14 @@ func (cli *cliAlerts) inspect(details bool, alertIDs ...string) error { case "json": data, err := json.MarshalIndent(alert, "", " ") if err != nil { - return fmt.Errorf("unable to marshal alert with id %s: %w", alertID, err) + return fmt.Errorf("unable to serialize alert with id %s: %w", alertID, err) } fmt.Printf("%s\n", string(data)) case "raw": data, err := yaml.Marshal(alert) if err != nil { - return fmt.Errorf("unable to marshal alert with id %s: %w", alertID, err) + return fmt.Errorf("unable to serialize alert with id %s: %w", alertID, err) } fmt.Println(string(data)) diff --git a/cmd/crowdsec-cli/clibouncer/bouncers.go b/cmd/crowdsec-cli/clibouncer/bouncers.go index 0d1484bcc6b..25c80d16404 100644 --- a/cmd/crowdsec-cli/clibouncer/bouncers.go +++ b/cmd/crowdsec-cli/clibouncer/bouncers.go @@ -181,7 +181,7 @@ func (cli *cliBouncers) List(out io.Writer, db *database.Client) error { enc.SetIndent("", " ") if err := enc.Encode(info); err != nil { - return errors.New("failed to marshal") + return errors.New("failed to serialize") } return nil @@ -234,7 +234,7 @@ func (cli *cliBouncers) add(bouncerName string, key string) error { case "json": j, err := json.Marshal(key) if err != nil { - return errors.New("unable to marshal api key") + return errors.New("unable to serialize api key") } fmt.Print(string(j)) @@ -458,7 +458,7 @@ func (cli *cliBouncers) inspect(bouncer *ent.Bouncer) error { enc.SetIndent("", " ") if err := enc.Encode(newBouncerInfo(bouncer)); err != nil { - return errors.New("failed to marshal") + return errors.New("failed to serialize") } return nil diff --git a/cmd/crowdsec-cli/clicapi/capi.go b/cmd/crowdsec-cli/clicapi/capi.go index fbc50066287..24c3ba054a9 100644 --- a/cmd/crowdsec-cli/clicapi/capi.go +++ b/cmd/crowdsec-cli/clicapi/capi.go @@ -104,7 +104,7 @@ func (cli *cliCapi) register(ctx context.Context, capiUserPrefix string, outputF apiConfigDump, err := yaml.Marshal(apiCfg) if err != nil { - return fmt.Errorf("unable to marshal api credentials: %w", err) + return fmt.Errorf("unable to serialize api credentials: %w", err) } if dumpFile != "" { diff --git a/cmd/crowdsec-cli/cliconsole/console.go b/cmd/crowdsec-cli/cliconsole/console.go index e4b4039bdd2..af1ba316c2d 100644 --- a/cmd/crowdsec-cli/cliconsole/console.go +++ b/cmd/crowdsec-cli/cliconsole/console.go @@ -280,7 +280,7 @@ func (cli *cliConsole) newStatusCmd() *cobra.Command { } data, err := json.MarshalIndent(out, "", " ") if err != nil { - return fmt.Errorf("failed to marshal configuration: %w", err) + return fmt.Errorf("failed to serialize configuration: %w", err) } fmt.Println(string(data)) case "raw": @@ -318,7 +318,7 @@ func (cli *cliConsole) dumpConfig() error { out, err := yaml.Marshal(serverCfg.ConsoleConfig) if err != nil { - return fmt.Errorf("while marshaling ConsoleConfig (for %s): %w", serverCfg.ConsoleConfigPath, err) + return fmt.Errorf("while serializing ConsoleConfig (for %s): %w", serverCfg.ConsoleConfigPath, err) } if serverCfg.ConsoleConfigPath == "" { @@ -361,7 +361,7 @@ func (cli *cliConsole) setConsoleOpts(args []string, wanted bool) error { if changed { fileContent, err := yaml.Marshal(cfg.API.Server.OnlineClient.Credentials) if err != nil { - return fmt.Errorf("cannot marshal credentials: %w", err) + return fmt.Errorf("cannot serialize credentials: %w", err) } log.Infof("Updating credentials file: %s", cfg.API.Server.OnlineClient.CredentialsFilePath) diff --git a/cmd/crowdsec-cli/clihub/items.go b/cmd/crowdsec-cli/clihub/items.go index 0ab89654dac..f86fe65a2a1 100644 --- a/cmd/crowdsec-cli/clihub/items.go +++ b/cmd/crowdsec-cli/clihub/items.go @@ -106,7 +106,7 @@ func ListItems(out io.Writer, wantColor string, itemTypes []string, items map[st x, err := json.MarshalIndent(hubStatus, "", " ") if err != nil { - return fmt.Errorf("failed to unmarshal: %w", err) + return fmt.Errorf("failed to parse: %w", err) } out.Write(x) @@ -158,7 +158,7 @@ func InspectItem(item *cwhub.Item, wantMetrics bool, output string, prometheusUR case "json": b, err := json.MarshalIndent(*item, "", " ") if err != nil { - return fmt.Errorf("unable to marshal item: %w", err) + return fmt.Errorf("unable to serialize item: %w", err) } fmt.Print(string(b)) diff --git a/cmd/crowdsec-cli/clihubtest/create.go b/cmd/crowdsec-cli/clihubtest/create.go index e0834f7e569..3822bed8903 100644 --- a/cmd/crowdsec-cli/clihubtest/create.go +++ b/cmd/crowdsec-cli/clihubtest/create.go @@ -134,7 +134,7 @@ cscli hubtest create my-scenario-test --parsers crowdsecurity/nginx --scenarios } data, err := yaml.Marshal(configFileData) if err != nil { - return fmt.Errorf("marshal: %w", err) + return fmt.Errorf("serialize: %w", err) } _, err = fd.Write(data) if err != nil { diff --git a/cmd/crowdsec-cli/cliitem/appsec.go b/cmd/crowdsec-cli/cliitem/appsec.go index db567f86a32..44afa2133bd 100644 --- a/cmd/crowdsec-cli/cliitem/appsec.go +++ b/cmd/crowdsec-cli/cliitem/appsec.go @@ -62,7 +62,7 @@ func NewAppsecRule(cfg configGetter) *cliItem { } if err := yaml.Unmarshal(yamlContent, &appsecRule); err != nil { - return fmt.Errorf("unable to unmarshal yaml file %s: %w", item.State.LocalPath, err) + return fmt.Errorf("unable to parse yaml file %s: %w", item.State.LocalPath, err) } for _, ruleType := range appsec_rule.SupportedTypes() { diff --git a/cmd/crowdsec-cli/clilapi/lapi.go b/cmd/crowdsec-cli/clilapi/lapi.go index eff7ae64476..75fdc5c239d 100644 --- a/cmd/crowdsec-cli/clilapi/lapi.go +++ b/cmd/crowdsec-cli/clilapi/lapi.go @@ -147,7 +147,7 @@ func (cli *cliLapi) register(ctx context.Context, apiURL string, outputFile stri apiConfigDump, err := yaml.Marshal(apiCfg) if err != nil { - return fmt.Errorf("unable to marshal api credentials: %w", err) + return fmt.Errorf("unable to serialize api credentials: %w", err) } if dumpFile != "" { diff --git a/cmd/crowdsec-cli/climachine/machines.go b/cmd/crowdsec-cli/climachine/machines.go index bf8656105aa..3df176d786d 100644 --- a/cmd/crowdsec-cli/climachine/machines.go +++ b/cmd/crowdsec-cli/climachine/machines.go @@ -232,7 +232,7 @@ func (cli *cliMachines) List(out io.Writer, db *database.Client) error { enc.SetIndent("", " ") if err := enc.Encode(info); err != nil { - return errors.New("failed to marshal") + return errors.New("failed to serialize") } return nil @@ -378,7 +378,7 @@ func (cli *cliMachines) add(args []string, machinePassword string, dumpFile stri apiConfigDump, err := yaml.Marshal(apiCfg) if err != nil { - return fmt.Errorf("unable to marshal api credentials: %w", err) + return fmt.Errorf("unable to serialize api credentials: %w", err) } if dumpFile != "" && dumpFile != "-" { @@ -626,7 +626,7 @@ func (cli *cliMachines) inspect(machine *ent.Machine) error { enc.SetIndent("", " ") if err := enc.Encode(newMachineInfo(machine)); err != nil { - return errors.New("failed to marshal") + return errors.New("failed to serialize") } return nil @@ -648,7 +648,7 @@ func (cli *cliMachines) inspectHub(machine *ent.Machine) error { enc.SetIndent("", " ") if err := enc.Encode(machine.Hubstate); err != nil { - return errors.New("failed to marshal") + return errors.New("failed to serialize") } return nil diff --git a/cmd/crowdsec-cli/climetrics/list.go b/cmd/crowdsec-cli/climetrics/list.go index d3afbef0669..ba827634052 100644 --- a/cmd/crowdsec-cli/climetrics/list.go +++ b/cmd/crowdsec-cli/climetrics/list.go @@ -68,7 +68,7 @@ func (cli *cliMetrics) list() error { case "json": x, err := json.MarshalIndent(allMetrics, "", " ") if err != nil { - return fmt.Errorf("failed to marshal metric types: %w", err) + return fmt.Errorf("failed to serialize metric types: %w", err) } fmt.Println(string(x)) diff --git a/cmd/crowdsec-cli/climetrics/store.go b/cmd/crowdsec-cli/climetrics/store.go index 5de50558e89..55fab5dbd7f 100644 --- a/cmd/crowdsec-cli/climetrics/store.go +++ b/cmd/crowdsec-cli/climetrics/store.go @@ -260,7 +260,7 @@ func (ms metricStore) Format(out io.Writer, wantColor string, sections []string, case "json": x, err := json.MarshalIndent(want, "", " ") if err != nil { - return fmt.Errorf("failed to marshal metrics: %w", err) + return fmt.Errorf("failed to serialize metrics: %w", err) } out.Write(x) default: diff --git a/cmd/crowdsec-cli/clinotifications/notifications.go b/cmd/crowdsec-cli/clinotifications/notifications.go index eb568ca5fa6..314f97db23e 100644 --- a/cmd/crowdsec-cli/clinotifications/notifications.go +++ b/cmd/crowdsec-cli/clinotifications/notifications.go @@ -172,7 +172,7 @@ func (cli *cliNotifications) newListCmd() *cobra.Command { } else if cfg.Cscli.Output == "json" { x, err := json.MarshalIndent(ncfgs, "", " ") if err != nil { - return fmt.Errorf("failed to marshal notification configuration: %w", err) + return fmt.Errorf("failed to serialize notification configuration: %w", err) } fmt.Printf("%s", string(x)) } else if cfg.Cscli.Output == "raw" { @@ -231,7 +231,7 @@ func (cli *cliNotifications) newInspectCmd() *cobra.Command { } else if cfg.Cscli.Output == "json" { x, err := json.MarshalIndent(cfg, "", " ") if err != nil { - return fmt.Errorf("failed to marshal notification configuration: %w", err) + return fmt.Errorf("failed to serialize notification configuration: %w", err) } fmt.Printf("%s", string(x)) } @@ -331,7 +331,7 @@ func (cli cliNotifications) newTestCmd() *cobra.Command { CreatedAt: time.Now().UTC().Format(time.RFC3339), } if err := yaml.Unmarshal([]byte(alertOverride), alert); err != nil { - return fmt.Errorf("failed to unmarshal alert override: %w", err) + return fmt.Errorf("failed to parse alert override: %w", err) } pluginBroker.PluginChannel <- csplugin.ProfileAlert{ @@ -387,7 +387,7 @@ cscli notifications reinject -a '{"remediation": true,"scenario":"not if alertOverride != "" { if err := json.Unmarshal([]byte(alertOverride), alert); err != nil { - return fmt.Errorf("can't unmarshal data in the alert flag: %w", err) + return fmt.Errorf("can't parse data in the alert flag: %w", err) } } diff --git a/cmd/crowdsec-cli/clisetup/setup.go b/cmd/crowdsec-cli/clisetup/setup.go index 8aee45b4287..269cdfb78e9 100644 --- a/cmd/crowdsec-cli/clisetup/setup.go +++ b/cmd/crowdsec-cli/clisetup/setup.go @@ -227,7 +227,7 @@ func setupAsString(cs setup.Setup, outYaml bool) (string, error) { ) wrap := func(err error) error { - return fmt.Errorf("while marshaling setup: %w", err) + return fmt.Errorf("while serializing setup: %w", err) } indentLevel := 2 diff --git a/cmd/crowdsec-cli/clisimulation/simulation.go b/cmd/crowdsec-cli/clisimulation/simulation.go index 9d9defd78e7..8136aa213c3 100644 --- a/cmd/crowdsec-cli/clisimulation/simulation.go +++ b/cmd/crowdsec-cli/clisimulation/simulation.go @@ -220,7 +220,7 @@ func (cli *cliSimulation) dumpSimulationFile() error { newConfigSim, err := yaml.Marshal(cfg.Cscli.SimulationConfig) if err != nil { - return fmt.Errorf("unable to marshal simulation configuration: %w", err) + return fmt.Errorf("unable to serialize simulation configuration: %w", err) } err = os.WriteFile(cfg.ConfigPaths.SimulationFilePath, newConfigSim, 0o644) @@ -242,7 +242,7 @@ func (cli *cliSimulation) disableGlobalSimulation() error { newConfigSim, err := yaml.Marshal(cfg.Cscli.SimulationConfig) if err != nil { - return fmt.Errorf("unable to marshal new simulation configuration: %w", err) + return fmt.Errorf("unable to serialize new simulation configuration: %w", err) } err = os.WriteFile(cfg.ConfigPaths.SimulationFilePath, newConfigSim, 0o644) diff --git a/cmd/crowdsec-cli/config_backup.go b/cmd/crowdsec-cli/config_backup.go index e8ac6213530..d23aff80a78 100644 --- a/cmd/crowdsec-cli/config_backup.go +++ b/cmd/crowdsec-cli/config_backup.go @@ -74,7 +74,7 @@ func (cli *cliConfig) backupHub(dirPath string) error { upstreamParsersContent, err := json.MarshalIndent(upstreamParsers, "", " ") if err != nil { - return fmt.Errorf("failed marshaling upstream parsers: %w", err) + return fmt.Errorf("failed to serialize upstream parsers: %w", err) } err = os.WriteFile(upstreamParsersFname, upstreamParsersContent, 0o644) diff --git a/cmd/crowdsec-cli/config_restore.go b/cmd/crowdsec-cli/config_restore.go index fc3670165f8..c32328485ec 100644 --- a/cmd/crowdsec-cli/config_restore.go +++ b/cmd/crowdsec-cli/config_restore.go @@ -40,7 +40,7 @@ func (cli *cliConfig) restoreHub(ctx context.Context, dirPath string) error { err = json.Unmarshal(file, &upstreamList) if err != nil { - return fmt.Errorf("error unmarshaling %s: %w", upstreamListFN, err) + return fmt.Errorf("error parsing %s: %w", upstreamListFN, err) } for _, toinstall := range upstreamList { diff --git a/cmd/crowdsec-cli/config_show.go b/cmd/crowdsec-cli/config_show.go index e411f5a322b..2d3ac488ba2 100644 --- a/cmd/crowdsec-cli/config_show.go +++ b/cmd/crowdsec-cli/config_show.go @@ -50,7 +50,7 @@ func (cli *cliConfig) showKey(key string) error { case "json": data, err := json.MarshalIndent(output, "", " ") if err != nil { - return fmt.Errorf("failed to marshal configuration: %w", err) + return fmt.Errorf("failed to serialize configuration: %w", err) } fmt.Println(string(data)) @@ -212,14 +212,14 @@ func (cli *cliConfig) show() error { case "json": data, err := json.MarshalIndent(cfg, "", " ") if err != nil { - return fmt.Errorf("failed to marshal configuration: %w", err) + return fmt.Errorf("failed to serialize configuration: %w", err) } fmt.Println(string(data)) case "raw": data, err := yaml.Marshal(cfg) if err != nil { - return fmt.Errorf("failed to marshal configuration: %w", err) + return fmt.Errorf("failed to serialize configuration: %w", err) } fmt.Println(string(data)) diff --git a/cmd/crowdsec/pour.go b/cmd/crowdsec/pour.go index 388c7a6c1b3..1382a909ab3 100644 --- a/cmd/crowdsec/pour.go +++ b/cmd/crowdsec/pour.go @@ -32,7 +32,7 @@ func runPour(input chan types.Event, holders []leaky.BucketFactory, buckets *lea if parsed.MarshaledTime != "" { z := &time.Time{} if err := z.UnmarshalText([]byte(parsed.MarshaledTime)); err != nil { - log.Warningf("Failed to unmarshal time from event '%s' : %s", parsed.MarshaledTime, err) + log.Warningf("Failed to parse time from event '%s' : %s", parsed.MarshaledTime, err) } else { log.Warning("Starting buckets garbage collection ...") @@ -61,7 +61,7 @@ func runPour(input chan types.Event, holders []leaky.BucketFactory, buckets *lea if len(parsed.MarshaledTime) != 0 { if err := lastProcessedItem.UnmarshalText([]byte(parsed.MarshaledTime)); err != nil { - log.Warningf("failed to unmarshal time from event : %s", err) + log.Warningf("failed to parse time from event : %s", err) } } } diff --git a/cmd/notification-file/main.go b/cmd/notification-file/main.go index 7fc529cff41..f6649b1f395 100644 --- a/cmd/notification-file/main.go +++ b/cmd/notification-file/main.go @@ -210,7 +210,7 @@ func (s *FilePlugin) Configure(ctx context.Context, config *protobufs.Config) (* d := PluginConfig{} err := yaml.Unmarshal(config.Config, &d) if err != nil { - logger.Error("Failed to unmarshal config", "error", err) + logger.Error("Failed to parse config", "error", err) return &protobufs.Empty{}, err } FileWriteMutex = &sync.Mutex{} diff --git a/pkg/acquisition/acquisition.go b/pkg/acquisition/acquisition.go index 38bf228abbc..a737881dd4d 100644 --- a/pkg/acquisition/acquisition.go +++ b/pkg/acquisition/acquisition.go @@ -129,7 +129,7 @@ func DataSourceConfigure(commonConfig configuration.DataSourceCommonCfg, metrics // once to DataSourceCommonCfg, and then later to the dedicated type of the datasource yamlConfig, err := yaml.Marshal(commonConfig) if err != nil { - return nil, fmt.Errorf("unable to marshal back interface: %w", err) + return nil, fmt.Errorf("unable to serialize back interface: %w", err) } dataSrc, err := GetDataSourceIface(commonConfig.Source) diff --git a/pkg/acquisition/modules/appsec/appsec.go b/pkg/acquisition/modules/appsec/appsec.go index 5b0661a21b7..8a93326c7e3 100644 --- a/pkg/acquisition/modules/appsec/appsec.go +++ b/pkg/acquisition/modules/appsec/appsec.go @@ -393,7 +393,7 @@ func (w *AppsecSource) appsecHandler(rw http.ResponseWriter, r *http.Request) { rw.WriteHeader(statusCode) body, err := json.Marshal(appsecResponse) if err != nil { - logger.Errorf("unable to marshal response: %s", err) + logger.Errorf("unable to serialize response: %s", err) rw.WriteHeader(http.StatusInternalServerError) } else { rw.Write(body) diff --git a/pkg/acquisition/modules/kafka/kafka.go b/pkg/acquisition/modules/kafka/kafka.go index ca0a7556fca..a0d7fc39bcc 100644 --- a/pkg/acquisition/modules/kafka/kafka.go +++ b/pkg/acquisition/modules/kafka/kafka.go @@ -82,7 +82,7 @@ func (k *KafkaSource) UnmarshalConfig(yamlConfig []byte) error { k.Config.Mode = configuration.TAIL_MODE } - k.logger.Debugf("successfully unmarshaled kafka configuration : %+v", k.Config) + k.logger.Debugf("successfully parsed kafka configuration : %+v", k.Config) return err } diff --git a/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go b/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go index e48a074b764..8ba5b2d06e0 100644 --- a/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go +++ b/pkg/acquisition/modules/kubernetesaudit/k8s_audit.go @@ -196,7 +196,7 @@ func (ka *KubernetesAuditSource) webhookHandler(w http.ResponseWriter, r *http.R } bytesEvent, err := json.Marshal(auditEvent) if err != nil { - ka.logger.Errorf("Error marshaling audit event: %s", err) + ka.logger.Errorf("Error serializing audit event: %s", err) continue } ka.logger.Tracef("Got audit event: %s", string(bytesEvent)) diff --git a/pkg/acquisition/modules/wineventlog/wineventlog_windows.go b/pkg/acquisition/modules/wineventlog/wineventlog_windows.go index c6b10b7c38c..4f2384d71db 100644 --- a/pkg/acquisition/modules/wineventlog/wineventlog_windows.go +++ b/pkg/acquisition/modules/wineventlog/wineventlog_windows.go @@ -149,7 +149,7 @@ func (w *WinEventLogSource) buildXpathQuery() (string, error) { queryList := QueryList{Select: Select{Path: w.config.EventChannel, Query: query}} xpathQuery, err := xml.Marshal(queryList) if err != nil { - w.logger.Errorf("Marshal failed: %v", err) + w.logger.Errorf("Serialize failed: %v", err) return "", err } w.logger.Debugf("xpathQuery: %s", xpathQuery) diff --git a/pkg/alertcontext/config.go b/pkg/alertcontext/config.go index da05c937b18..6ef877619e4 100644 --- a/pkg/alertcontext/config.go +++ b/pkg/alertcontext/config.go @@ -133,7 +133,7 @@ func LoadConsoleContext(c *csconfig.Config, hub *cwhub.Hub) error { feedback, err := json.Marshal(c.Crowdsec.ContextToSend) if err != nil { - return fmt.Errorf("marshaling console context: %s", err) + return fmt.Errorf("serializing console context: %s", err) } log.Debugf("console context to send: %s", feedback) diff --git a/pkg/apiserver/apic_metrics.go b/pkg/apiserver/apic_metrics.go index 176984f1ad6..5c6a550a6a0 100644 --- a/pkg/apiserver/apic_metrics.go +++ b/pkg/apiserver/apic_metrics.go @@ -70,7 +70,7 @@ func (a *apic) GetUsageMetrics() (*models.AllMetrics, []int, error) { err := json.Unmarshal([]byte(dbMetric.Payload), dbPayload) if err != nil { - log.Errorf("unable to unmarshal bouncer metric (%s)", err) + log.Errorf("unable to parse bouncer metric (%s)", err) continue } @@ -132,7 +132,7 @@ func (a *apic) GetUsageMetrics() (*models.AllMetrics, []int, error) { err := json.Unmarshal([]byte(dbMetric.Payload), dbPayload) if err != nil { - log.Errorf("unable to unmarshal log processor metric (%s)", err) + log.Errorf("unable to parse log processor metric (%s)", err) continue } diff --git a/pkg/apiserver/controllers/v1/alerts.go b/pkg/apiserver/controllers/v1/alerts.go index 3d4309b1347..84b3094865c 100644 --- a/pkg/apiserver/controllers/v1/alerts.go +++ b/pkg/apiserver/controllers/v1/alerts.go @@ -63,7 +63,7 @@ func FormatOneAlert(alert *ent.Alert) *models.Alert { var Metas models.Meta if err := json.Unmarshal([]byte(eventItem.Serialized), &Metas); err != nil { - log.Errorf("unable to unmarshall events meta '%s' : %s", eventItem.Serialized, err) + log.Errorf("unable to parse events meta '%s' : %s", eventItem.Serialized, err) } outputAlert.Events = append(outputAlert.Events, &models.Event{ diff --git a/pkg/apiserver/controllers/v1/usagemetrics.go b/pkg/apiserver/controllers/v1/usagemetrics.go index 27b1b819a54..5b2c3e3b1a9 100644 --- a/pkg/apiserver/controllers/v1/usagemetrics.go +++ b/pkg/apiserver/controllers/v1/usagemetrics.go @@ -183,7 +183,7 @@ func (c *Controller) UsageMetrics(gctx *gin.Context) { jsonPayload, err := json.Marshal(payload) if err != nil { - logger.Errorf("Failed to marshal usage metrics: %s", err) + logger.Errorf("Failed to serialize usage metrics: %s", err) c.HandleDBErrors(gctx, err) return diff --git a/pkg/apiserver/papi.go b/pkg/apiserver/papi.go index 0a69f086a7f..89ad93930a1 100644 --- a/pkg/apiserver/papi.go +++ b/pkg/apiserver/papi.go @@ -245,7 +245,7 @@ func (p *Papi) Pull() error { if lastTimestampStr == nil { binTime, err := lastTimestamp.MarshalText() if err != nil { - return fmt.Errorf("failed to marshal last timestamp: %w", err) + return fmt.Errorf("failed to serialize last timestamp: %w", err) } if err := p.DBClient.SetConfigItem(PapiPullKey, string(binTime)); err != nil { @@ -255,7 +255,7 @@ func (p *Papi) Pull() error { } } else { if err := lastTimestamp.UnmarshalText([]byte(*lastTimestampStr)); err != nil { - return fmt.Errorf("failed to unmarshal last timestamp: %w", err) + return fmt.Errorf("failed to parse last timestamp: %w", err) } } @@ -268,7 +268,7 @@ func (p *Papi) Pull() error { binTime, err := newTime.MarshalText() if err != nil { - return fmt.Errorf("failed to marshal last timestamp: %w", err) + return fmt.Errorf("failed to serialize last timestamp: %w", err) } err = p.handleEvent(event, false) diff --git a/pkg/appsec/loader.go b/pkg/appsec/loader.go index 9a3bfb6b668..c724010cec2 100644 --- a/pkg/appsec/loader.go +++ b/pkg/appsec/loader.go @@ -28,7 +28,7 @@ func LoadAppsecRules(hubInstance *cwhub.Hub) error { err = yaml.UnmarshalStrict(content, &rule) if err != nil { - log.Warnf("unable to unmarshal file %s : %s", hubAppsecRuleItem.State.LocalPath, err) + log.Warnf("unable to parse file %s : %s", hubAppsecRuleItem.State.LocalPath, err) continue } diff --git a/pkg/csconfig/api.go b/pkg/csconfig/api.go index 4a28b590e80..3014b729a9e 100644 --- a/pkg/csconfig/api.go +++ b/pkg/csconfig/api.go @@ -99,7 +99,7 @@ func (o *OnlineApiClientCfg) Load() error { err = dec.Decode(o.Credentials) if err != nil { if !errors.Is(err, io.EOF) { - return fmt.Errorf("failed unmarshaling api server credentials configuration file '%s': %w", o.CredentialsFilePath, err) + return fmt.Errorf("failed to parse api server credentials configuration file '%s': %w", o.CredentialsFilePath, err) } } @@ -134,7 +134,7 @@ func (l *LocalApiClientCfg) Load() error { err = dec.Decode(&l.Credentials) if err != nil { if !errors.Is(err, io.EOF) { - return fmt.Errorf("failed unmarshaling api client credential configuration file '%s': %w", l.CredentialsFilePath, err) + return fmt.Errorf("failed to parse api client credential configuration file '%s': %w", l.CredentialsFilePath, err) } } diff --git a/pkg/csconfig/api_test.go b/pkg/csconfig/api_test.go index 96945202aa8..dff3c3afc8c 100644 --- a/pkg/csconfig/api_test.go +++ b/pkg/csconfig/api_test.go @@ -101,7 +101,7 @@ func TestLoadOnlineApiClientCfg(t *testing.T) { CredentialsFilePath: "./testdata/bad_lapi-secrets.yaml", }, expected: &ApiCredentialsCfg{}, - expectedErr: "failed unmarshaling api server credentials", + expectedErr: "failed to parse api server credentials", }, { name: "missing field configuration", diff --git a/pkg/csconfig/config_test.go b/pkg/csconfig/config_test.go index 11f1f0cf68d..b69954de178 100644 --- a/pkg/csconfig/config_test.go +++ b/pkg/csconfig/config_test.go @@ -42,5 +42,5 @@ func TestNewCrowdSecConfig(t *testing.T) { func TestDefaultConfig(t *testing.T) { x := NewDefaultConfig() _, err := yaml.Marshal(x) - require.NoError(t, err, "failed marshaling config: %s", err) + require.NoError(t, err, "failed to serialize config: %s", err) } diff --git a/pkg/csconfig/console.go b/pkg/csconfig/console.go index 4c14f5f7d49..21ecbf3d736 100644 --- a/pkg/csconfig/console.go +++ b/pkg/csconfig/console.go @@ -95,7 +95,7 @@ func (c *LocalApiServerCfg) LoadConsoleConfig() error { err = yaml.Unmarshal(yamlFile, c.ConsoleConfig) if err != nil { - return fmt.Errorf("unmarshaling console config file '%s': %w", c.ConsoleConfigPath, err) + return fmt.Errorf("parsing console config file '%s': %w", c.ConsoleConfigPath, err) } if c.ConsoleConfig.ShareCustomScenarios == nil { diff --git a/pkg/csconfig/crowdsec_service.go b/pkg/csconfig/crowdsec_service.go index 7820595b46f..7a611a856ee 100644 --- a/pkg/csconfig/crowdsec_service.go +++ b/pkg/csconfig/crowdsec_service.go @@ -143,7 +143,7 @@ func (c *CrowdsecServiceCfg) DumpContextConfigFile() error { // XXX: MakeDirs out, err := yaml.Marshal(c.ContextToSend) if err != nil { - return fmt.Errorf("while marshaling ConsoleConfig (for %s): %w", c.ConsoleContextPath, err) + return fmt.Errorf("while serializing ConsoleConfig (for %s): %w", c.ConsoleContextPath, err) } if err = os.MkdirAll(filepath.Dir(c.ConsoleContextPath), 0700); err != nil { diff --git a/pkg/csconfig/simulation.go b/pkg/csconfig/simulation.go index 947b47e3c1e..afc4ea4f044 100644 --- a/pkg/csconfig/simulation.go +++ b/pkg/csconfig/simulation.go @@ -52,7 +52,7 @@ func (c *Config) LoadSimulation() error { if err := dec.Decode(&simCfg); err != nil { if !errors.Is(err, io.EOF) { - return fmt.Errorf("while unmarshaling simulation file '%s': %w", c.ConfigPaths.SimulationFilePath, err) + return fmt.Errorf("while parsing simulation file '%s': %w", c.ConfigPaths.SimulationFilePath, err) } } diff --git a/pkg/csconfig/simulation_test.go b/pkg/csconfig/simulation_test.go index a678d7edd49..a1e5f0a5b02 100644 --- a/pkg/csconfig/simulation_test.go +++ b/pkg/csconfig/simulation_test.go @@ -60,7 +60,7 @@ func TestSimulationLoading(t *testing.T) { }, Crowdsec: &CrowdsecServiceCfg{}, }, - expectedErr: "while unmarshaling simulation file './testdata/config.yaml': yaml: unmarshal errors", + expectedErr: "while parsing simulation file './testdata/config.yaml': yaml: unmarshal errors", }, { name: "basic bad file content", @@ -71,7 +71,7 @@ func TestSimulationLoading(t *testing.T) { }, Crowdsec: &CrowdsecServiceCfg{}, }, - expectedErr: "while unmarshaling simulation file './testdata/config.yaml': yaml: unmarshal errors", + expectedErr: "while parsing simulation file './testdata/config.yaml': yaml: unmarshal errors", }, } diff --git a/pkg/csplugin/broker_test.go b/pkg/csplugin/broker_test.go index f2179acb2c1..48f5a71f773 100644 --- a/pkg/csplugin/broker_test.go +++ b/pkg/csplugin/broker_test.go @@ -38,7 +38,7 @@ func (s *PluginSuite) readconfig() PluginConfig { require.NoError(t, err, "unable to read config file %s", s.pluginConfig) err = yaml.Unmarshal(orig, &config) - require.NoError(t, err, "unable to unmarshal config file") + require.NoError(t, err, "unable to parse config file") return config } @@ -46,7 +46,7 @@ func (s *PluginSuite) readconfig() PluginConfig { func (s *PluginSuite) writeconfig(config PluginConfig) { t := s.T() data, err := yaml.Marshal(&config) - require.NoError(t, err, "unable to marshal config file") + require.NoError(t, err, "unable to serialize config file") err = os.WriteFile(s.pluginConfig, data, 0o644) require.NoError(t, err, "unable to write config file %s", s.pluginConfig) diff --git a/pkg/cwhub/hub.go b/pkg/cwhub/hub.go index a4e81e2c3e2..f74a794a512 100644 --- a/pkg/cwhub/hub.go +++ b/pkg/cwhub/hub.go @@ -79,7 +79,7 @@ func (h *Hub) parseIndex() error { } if err := json.Unmarshal(bidx, &h.items); err != nil { - return fmt.Errorf("failed to unmarshal index: %w", err) + return fmt.Errorf("failed to parse index: %w", err) } h.logger.Debugf("%d item types in hub index", len(ItemTypes)) diff --git a/pkg/cwhub/sync.go b/pkg/cwhub/sync.go index 81d41d55971..7ed14086adf 100644 --- a/pkg/cwhub/sync.go +++ b/pkg/cwhub/sync.go @@ -210,7 +210,7 @@ func newLocalItem(h *Hub, path string, info *itemFileInfo) (*Item, error) { err = yaml.Unmarshal(itemContent, &itemName) if err != nil { - return nil, fmt.Errorf("failed to unmarshal %s: %w", path, err) + return nil, fmt.Errorf("failed to parse %s: %w", path, err) } if itemName.Name != "" { diff --git a/pkg/database/ent/machine.go b/pkg/database/ent/machine.go index 76127065791..1b8122060d1 100644 --- a/pkg/database/ent/machine.go +++ b/pkg/database/ent/machine.go @@ -202,7 +202,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field hubstate", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Hubstate); err != nil { - return fmt.Errorf("unmarshal field hubstate: %w", err) + return fmt.Errorf("parsing field hubstate: %w", err) } } case machine.FieldDatasources: @@ -210,7 +210,7 @@ func (m *Machine) assignValues(columns []string, values []any) error { return fmt.Errorf("unexpected type %T for field datasources", values[i]) } else if value != nil && len(*value) > 0 { if err := json.Unmarshal(*value, &m.Datasources); err != nil { - return fmt.Errorf("unmarshal field datasources: %w", err) + return fmt.Errorf("parsing field datasources: %w", err) } } default: diff --git a/pkg/database/errors.go b/pkg/database/errors.go index 8e96f52d7ce..77f92707e51 100644 --- a/pkg/database/errors.go +++ b/pkg/database/errors.go @@ -13,8 +13,8 @@ var ( ItemNotFound = errors.New("object not found") ParseTimeFail = errors.New("unable to parse time") ParseDurationFail = errors.New("unable to parse duration") - MarshalFail = errors.New("unable to marshal") - UnmarshalFail = errors.New("unable to unmarshal") + MarshalFail = errors.New("unable to serialize") + UnmarshalFail = errors.New("unable to parse") BulkError = errors.New("unable to insert bulk") ParseType = errors.New("unable to parse type") InvalidIPOrRange = errors.New("invalid ip address / range") diff --git a/pkg/hubtest/coverage.go b/pkg/hubtest/coverage.go index 4156def06d7..e42c1e23455 100644 --- a/pkg/hubtest/coverage.go +++ b/pkg/hubtest/coverage.go @@ -57,7 +57,7 @@ func (h *HubTest) GetAppsecCoverage() ([]Coverage, error) { err = yaml.Unmarshal(yamlFile, configFileData) if err != nil { - return nil, fmt.Errorf("unmarshal: %v", err) + return nil, fmt.Errorf("parsing: %v", err) } for _, appsecRulesFile := range configFileData.AppsecRules { @@ -70,7 +70,7 @@ func (h *HubTest) GetAppsecCoverage() ([]Coverage, error) { err = yaml.Unmarshal(yamlFile, appsecRuleData) if err != nil { - return nil, fmt.Errorf("unmarshal: %v", err) + return nil, fmt.Errorf("parsing: %v", err) } appsecRuleName := appsecRuleData.Name diff --git a/pkg/hubtest/hubtest_item.go b/pkg/hubtest/hubtest_item.go index 42792413b5d..bc9c8955d0d 100644 --- a/pkg/hubtest/hubtest_item.go +++ b/pkg/hubtest/hubtest_item.go @@ -111,7 +111,7 @@ func NewTest(name string, hubTest *HubTest) (*HubTestItem, error) { err = yaml.Unmarshal(yamlFile, configFileData) if err != nil { - return nil, fmt.Errorf("unmarshal: %w", err) + return nil, fmt.Errorf("parsing: %w", err) } parserAssertFilePath := filepath.Join(testPath, ParserAssertFileName) @@ -201,7 +201,7 @@ func (t *HubTestItem) InstallHub() error { b, err := yaml.Marshal(n) if err != nil { - return fmt.Errorf("unable to marshal overrides: %w", err) + return fmt.Errorf("unable to serialize overrides: %w", err) } tgtFilename := fmt.Sprintf("%s/parsers/s00-raw/00_overrides.yaml", t.RuntimePath) diff --git a/pkg/leakybucket/buckets_test.go b/pkg/leakybucket/buckets_test.go index 989e03944c3..1da906cb555 100644 --- a/pkg/leakybucket/buckets_test.go +++ b/pkg/leakybucket/buckets_test.go @@ -136,7 +136,7 @@ func testOneBucket(t *testing.T, hub *cwhub.Hub, dir string, tomb *tomb.Tomb) er } if err := yaml.UnmarshalStrict(out.Bytes(), &stages); err != nil { - t.Fatalf("failed unmarshaling %s : %s", stagecfg, err) + t.Fatalf("failed to parse %s : %s", stagecfg, err) } files := []string{} @@ -201,7 +201,7 @@ func testFile(t *testing.T, file string, bs string, holders []BucketFactory, res var ts time.Time if err := ts.UnmarshalText([]byte(in.MarshaledTime)); err != nil { - t.Fatalf("Failed to unmarshal time from input event : %s", err) + t.Fatalf("Failed to parse time from input event : %s", err) } if latest_ts.IsZero() { diff --git a/pkg/leakybucket/manager_load.go b/pkg/leakybucket/manager_load.go index 1ae70fbfab3..1b62b29dc3c 100644 --- a/pkg/leakybucket/manager_load.go +++ b/pkg/leakybucket/manager_load.go @@ -493,7 +493,7 @@ func LoadBucketsState(file string, buckets *Buckets, bucketFactories []BucketFac } if err := json.Unmarshal(body, &state); err != nil { - return fmt.Errorf("can't unmarshal state file %s: %w", file, err) + return fmt.Errorf("can't parse state file %s: %w", file, err) } for k, v := range state { diff --git a/pkg/leakybucket/manager_run.go b/pkg/leakybucket/manager_run.go index 673b372d81e..053f9be05da 100644 --- a/pkg/leakybucket/manager_run.go +++ b/pkg/leakybucket/manager_run.go @@ -132,7 +132,7 @@ func DumpBucketsStateAt(deadline time.Time, outputdir string, buckets *Buckets) }) bbuckets, err := json.MarshalIndent(serialized, "", " ") if err != nil { - return "", fmt.Errorf("failed to unmarshal buckets: %s", err) + return "", fmt.Errorf("failed to parse buckets: %s", err) } size, err := tmpFd.Write(bbuckets) if err != nil { @@ -203,7 +203,7 @@ func PourItemToBucket(bucket *Leaky, holder BucketFactory, buckets *Buckets, par var d time.Time err = d.UnmarshalText([]byte(parsed.MarshaledTime)) if err != nil { - holder.logger.Warningf("Failed unmarshaling event time (%s) : %v", parsed.MarshaledTime, err) + holder.logger.Warningf("Failed to parse event time (%s) : %v", parsed.MarshaledTime, err) } if d.After(lastTs.Add(bucket.Duration)) { bucket.logger.Tracef("bucket is expired (curr event: %s, bucket deadline: %s), kill", d, lastTs.Add(bucket.Duration)) diff --git a/pkg/leakybucket/overflows.go b/pkg/leakybucket/overflows.go index e67698e8473..39b0e6a0ec4 100644 --- a/pkg/leakybucket/overflows.go +++ b/pkg/leakybucket/overflows.go @@ -231,7 +231,7 @@ func EventsFromQueue(queue *types.Queue) []*models.Event { raw, err := evt.Time.MarshalText() if err != nil { - log.Warningf("while marshaling time '%s' : %s", evt.Time.String(), err) + log.Warningf("while serializing time '%s' : %s", evt.Time.String(), err) } else { *ovflwEvent.Timestamp = string(raw) } @@ -286,12 +286,12 @@ func NewAlert(leaky *Leaky, queue *types.Queue) (types.RuntimeAlert, error) { */ start_at, err := leaky.First_ts.MarshalText() if err != nil { - log.Warningf("failed to marshal start ts %s : %s", leaky.First_ts.String(), err) + log.Warningf("failed to serialize start ts %s : %s", leaky.First_ts.String(), err) } stop_at, err := leaky.Ovflw_ts.MarshalText() if err != nil { - log.Warningf("failed to marshal ovflw ts %s : %s", leaky.First_ts.String(), err) + log.Warningf("failed to serialize ovflw ts %s : %s", leaky.First_ts.String(), err) } capacity := int32(leaky.Capacity) diff --git a/pkg/leakybucket/timemachine.go b/pkg/leakybucket/timemachine.go index e72bb1a464c..34073d1cc5c 100644 --- a/pkg/leakybucket/timemachine.go +++ b/pkg/leakybucket/timemachine.go @@ -24,7 +24,7 @@ func TimeMachinePour(l *Leaky, msg types.Event) { err = d.UnmarshalText([]byte(msg.MarshaledTime)) if err != nil { - log.Warningf("Failed unmarshaling event time (%s) : %v", msg.MarshaledTime, err) + log.Warningf("Failed to parse event time (%s) : %v", msg.MarshaledTime, err) return } diff --git a/pkg/leakybucket/trigger.go b/pkg/leakybucket/trigger.go index 7558f696dc7..d13e57856f9 100644 --- a/pkg/leakybucket/trigger.go +++ b/pkg/leakybucket/trigger.go @@ -23,7 +23,7 @@ func (t *Trigger) OnBucketPour(b *BucketFactory) func(types.Event, *Leaky) *type err := d.UnmarshalText([]byte(msg.MarshaledTime)) if err != nil { - log.Warningf("Failed unmarshaling event time (%s) : %v", msg.MarshaledTime, err) + log.Warningf("Failed to parse event time (%s) : %v", msg.MarshaledTime, err) d = now } diff --git a/pkg/parser/enrich_date.go b/pkg/parser/enrich_date.go index 748a466d7c3..40c8de39da5 100644 --- a/pkg/parser/enrich_date.go +++ b/pkg/parser/enrich_date.go @@ -18,7 +18,7 @@ func parseDateWithFormat(date, format string) (string, time.Time) { } retstr, err := t.MarshalText() if err != nil { - log.Warningf("Failed marshaling '%v'", t) + log.Warningf("Failed to serialize '%v'", t) return "", time.Time{} } return string(retstr), t @@ -98,7 +98,7 @@ func ParseDate(in string, p *types.Event, plog *log.Entry) (map[string]string, e now := time.Now().UTC() retstr, err := now.MarshalText() if err != nil { - plog.Warning("Failed marshaling current time") + plog.Warning("Failed to serialize current time") return ret, err } ret["MarshaledTime"] = string(retstr) diff --git a/pkg/parser/enrich_unmarshal.go b/pkg/parser/enrich_unmarshal.go index 7ff91b70aea..dbdd9d3f583 100644 --- a/pkg/parser/enrich_unmarshal.go +++ b/pkg/parser/enrich_unmarshal.go @@ -11,7 +11,7 @@ import ( func unmarshalJSON(field string, p *types.Event, plog *log.Entry) (map[string]string, error) { err := json.Unmarshal([]byte(p.Line.Raw), &p.Unmarshaled) if err != nil { - plog.Errorf("could not unmarshal JSON: %s", err) + plog.Errorf("could not parse JSON: %s", err) return nil, err } plog.Tracef("unmarshaled JSON: %+v", p.Unmarshaled) diff --git a/pkg/parser/parsing_test.go b/pkg/parser/parsing_test.go index 0542c69c049..269d51a1ba2 100644 --- a/pkg/parser/parsing_test.go +++ b/pkg/parser/parsing_test.go @@ -132,7 +132,7 @@ func testOneParser(pctx *UnixParserCtx, ectx EnricherCtx, dir string, b *testing } if err = yaml.UnmarshalStrict(out.Bytes(), &parser_configs); err != nil { - return fmt.Errorf("failed unmarshaling %s: %w", parser_cfg_file, err) + return fmt.Errorf("failed to parse %s: %w", parser_cfg_file, err) } pnodes, err = LoadStages(parser_configs, pctx, ectx) diff --git a/pkg/setup/detect.go b/pkg/setup/detect.go index 01368091a6b..073b221b10c 100644 --- a/pkg/setup/detect.go +++ b/pkg/setup/detect.go @@ -545,7 +545,7 @@ func Detect(detectReader io.Reader, opts DetectOptions) (Setup, error) { // } // err = yaml.Unmarshal(svc.AcquisYAML, svc.DataSource) // if err != nil { - // return Setup{}, fmt.Errorf("while unmarshaling datasource for service %s: %w", name, err) + // return Setup{}, fmt.Errorf("while parsing datasource for service %s: %w", name, err) // } // } diff --git a/pkg/setup/install.go b/pkg/setup/install.go index fc5bd380fd9..d63a1ee1775 100644 --- a/pkg/setup/install.go +++ b/pkg/setup/install.go @@ -40,7 +40,7 @@ func decodeSetup(input []byte, fancyErrors bool) (Setup, error) { dec2.KnownFields(true) if err := dec2.Decode(&ret); err != nil { - return ret, fmt.Errorf("while unmarshaling setup file: %w", err) + return ret, fmt.Errorf("while parsing setup file: %w", err) } return ret, nil diff --git a/test/bats/07_setup.bats b/test/bats/07_setup.bats index 2106d3ab6b2..f832ac572d2 100644 --- a/test/bats/07_setup.bats +++ b/test/bats/07_setup.bats @@ -819,6 +819,6 @@ update-notifier-motd.timer enabled enabled setup: alsdk al; sdf EOT - assert_output "while unmarshaling setup file: yaml: line 2: could not find expected ':'" + assert_output "while parsing setup file: yaml: line 2: could not find expected ':'" assert_stderr --partial "invalid setup file" }