Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit 603b1c6

Browse files
committed
Error strings should not be capitalized
1 parent a248420 commit 603b1c6

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

cmd/agent/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ func main() {
2121

2222
globalConfig, err := agent.ParseConfig(configFile)
2323
if err != nil {
24-
log.Fatalf("Error generating the config: %v", err)
24+
log.Fatalf("error generating the config: %v", err)
2525
}
2626

2727
a, err := agent.New(globalConfig)
2828
if err != nil {
29-
log.Fatalf("Error creating the agent: %v", err)
29+
log.Fatalf("error creating the agent: %v", err)
3030
}
3131

3232
go handleTermination()

internal/agent/agent.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func (agent *Agent) configure() error {
6666
agent.namedServices = make(map[string]string)
6767
for _, svc := range agent.services.Feeds {
6868
if _, ok := feedNames[svc.FeedName]; !ok {
69-
return fmt.Errorf("Feed Name %v not found in NS1 DataFeed with source = %v. Review NS1 configuration", svc.FeedName, agent.pusher.Cfg.SourceID)
69+
return fmt.Errorf("feed Name %v not found in NS1 DataFeed with source = %v. Review NS1 configuration", svc.FeedName, agent.pusher.Cfg.SourceID)
7070
}
7171
if agent.services.Method == globalMethod {
7272
agent.namedServices[svc.FeedName] = svc.FeedName
@@ -97,7 +97,7 @@ func (agent *Agent) processData(statsSlice []*client.Stats) (map[string]*interna
9797
}
9898

9999
if feedData == nil {
100-
log.Printf("Error: [%v] source was not found in the remote NGINX Plus instance(s). Check NGINX Plus config file or agent config file.", src)
100+
log.Printf("error: [%v] source was not found in the remote NGINX Plus instance(s). Check NGINX Plus config file or agent config file.", src)
101101
continue
102102
}
103103
newData[feed] = feedData
@@ -114,7 +114,7 @@ func (agent *Agent) processData(statsSlice []*client.Stats) (map[string]*interna
114114
}
115115

116116
func (agent *Agent) handleErrorAndSleep(err error) {
117-
log.Printf("Error while running the main loop: %v. No data will be sent this time, will try again in %d seconds", err, agent.cfg.RetryTime)
117+
log.Printf("error while running the main loop: %v. No data will be sent this time, will try again in %d seconds", err, agent.cfg.RetryTime)
118118
time.Sleep(time.Duration(agent.cfg.RetryTime) * time.Second)
119119
}
120120

@@ -134,7 +134,7 @@ func (agent *Agent) Run() {
134134

135135
err = agent.pusher.Push(data)
136136
if err != nil {
137-
log.Printf("Error pushing the data: %v", err)
137+
log.Printf("error pushing the data: %v", err)
138138
}
139139

140140
sleepTime := int(agent.cfg.Interval)
@@ -161,7 +161,7 @@ func New(globalConfig *Config) (*Agent, error) {
161161
// merge an array of Stats fetched from one or more NGINX Plus instances focusing on the right stats depending on the configured methods
162162
func (agent *Agent) mergeStats(statsSlice []*client.Stats) (map[string]*internal.FeedData, error) {
163163
if len(statsSlice) == 0 {
164-
return nil, fmt.Errorf("Error merging data: no data to merge, empty response")
164+
return nil, fmt.Errorf("error merging data: no data to merge, empty response")
165165
}
166166

167167
switch agent.services.Method {
@@ -173,7 +173,7 @@ func (agent *Agent) mergeStats(statsSlice []*client.Stats) (map[string]*internal
173173
return getStatusZonesConnectionsData(statsSlice, agent.namedServices), nil
174174
}
175175

176-
return nil, fmt.Errorf("Error processing the data from NGINX Plus instance(s): %v is not a valid NGINX Plus type", agent.services.Method)
176+
return nil, fmt.Errorf("error processing the data from NGINX Plus instance(s): %v is not a valid NGINX Plus type", agent.services.Method)
177177
}
178178

179179
func getGlobalConnectionsData(statsSlice []*client.Stats) map[string]*internal.FeedData {

internal/agent/agent_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestNewAgentFailureNoNGINXPlus(t *testing.T) {
2020
}
2121
_, err := New(globalCfg)
2222
if err == nil {
23-
t.Errorf("Agent creation err returned %+v but expected an error because NGINX Plus is not reachable", err)
23+
t.Errorf("agent creation err returned %+v but expected an error because NGINX Plus is not reachable", err)
2424
}
2525
}
2626

@@ -69,7 +69,7 @@ func TestProcessData(t *testing.T) {
6969
agent.services.Method = testCase.nType
7070
feedData, _ := agent.processData(testCase.input)
7171
if !reflect.DeepEqual(testCase.expected, feedData) {
72-
t.Errorf("Agent.processData returned %v, but %v expected for case: %v", feedData, testCase.expected, testCase.msg)
72+
t.Errorf("agent.processData returned %v, but %v expected for case: %v", feedData, testCase.expected, testCase.msg)
7373
}
7474
}
7575
}

internal/agent/configurator.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,43 @@ type Config struct {
2929
func ParseConfig(path *string) (*Config, error) {
3030
data, err := ioutil.ReadFile(*path)
3131
if err != nil {
32-
return nil, fmt.Errorf("Error reading file at %v: %w", path, err)
32+
return nil, fmt.Errorf("error reading file at %v: %w", path, err)
3333
}
3434

3535
globalConfig := &Config{}
3636
err = yaml.Unmarshal(data, globalConfig)
3737
if err != nil {
38-
return nil, fmt.Errorf("Error while parsing the configuration file: %w", err)
38+
return nil, fmt.Errorf("error while parsing the configuration file: %w", err)
3939
}
4040

4141
globalConfig = fillWithDefaults(globalConfig)
4242

4343
err = validateServicesCfg(globalConfig)
4444
if err != nil {
45-
return nil, fmt.Errorf("Error while validating Services configuration: %w", err)
45+
return nil, fmt.Errorf("error while validating Services configuration: %w", err)
4646
}
4747

4848
return globalConfig, nil
4949
}
5050

5151
func validateServicesCfg(cfg *Config) error {
5252
if len(cfg.Services.Feeds) == 0 {
53-
return fmt.Errorf("At least 1 Feed needs to be defined")
53+
return fmt.Errorf("at least 1 Feed needs to be defined")
5454
}
5555

5656
if cfg.Services.SamplingType != mergeAvg && cfg.Services.SamplingType != mergeCount {
57-
return fmt.Errorf("Sampling Type [%v] is not a valid type. Valid Sampling Types are: %v, %v", cfg.Services.SamplingType, mergeAvg, mergeCount)
57+
return fmt.Errorf("sampling Type [%v] is not a valid type. Valid Sampling Types are: %v, %v", cfg.Services.SamplingType, mergeAvg, mergeCount)
5858
}
5959

6060
names := make(map[string]bool)
6161
for _, feed := range cfg.Services.Feeds {
6262
if feed.FeedName == "" {
63-
return fmt.Errorf("Feeds must define at least a feed_name")
63+
return fmt.Errorf("feeds must define at least a feed_name")
6464
}
6565

6666
if cfg.Services.Method != globalMethod {
6767
if feed.Name == "" {
68-
return fmt.Errorf("Feeds must define a name for method: %v", cfg.Services.Method)
68+
return fmt.Errorf("feeds must define a name for method: %v", cfg.Services.Method)
6969
}
7070

7171
if _, ok := names[feed.Name]; ok {

internal/input/nginx.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (n *NginxPlus) Fetch() []*client.Stats {
7777
var statsSlice []*client.Stats
7878
for _, task := range finishedTasks {
7979
if task.err != nil {
80-
log.Printf("Error fetching from NGINX Plus instance: %v", task.err)
80+
log.Printf("error fetching from NGINX Plus instance: %v", task.err)
8181
} else {
8282
statsSlice = append(statsSlice, task.result)
8383
}
@@ -88,7 +88,7 @@ func (n *NginxPlus) Fetch() []*client.Stats {
8888
// Configure sets the configuration of the NginxPlus clients
8989
func (n *NginxPlus) Configure(cfg *Cfg) error {
9090
if len(cfg.Hosts) == 0 {
91-
return fmt.Errorf("The NGINX Plus Fetcher requires at least 1 host to be defined")
91+
return fmt.Errorf("the NGINX Plus Fetcher requires at least 1 host to be defined")
9292
}
9393
n.Cfg = cfg
9494
var resolvedHosts []NginxHost

internal/input/resolver_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ func TestResolverLookup(t *testing.T) {
1111
addrs, err := resolver.Lookup(host)
1212

1313
if len(addrs) == 0 {
14-
t.Errorf("Resolver didn't return any address for host %v", host)
14+
t.Errorf("resolver didn't return any address for host %v", host)
1515
}
1616

1717
if err != nil {
18-
t.Errorf("Error trying to resolve %v: %v", host, err)
18+
t.Errorf("error trying to resolve %v: %v", host, err)
1919
}
2020
}
2121

internal/output/ns1.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ func (ns1 *NS1) Push(data map[string]*internal.FeedData) error {
4646
// Configure sets the configuration for the NS1 client
4747
func (ns1 *NS1) Configure(cfg *Cfg) error {
4848
if cfg.APIKey == "" {
49-
return fmt.Errorf("The NS1 Pusher requires an API KEY to be defined")
49+
return fmt.Errorf("the NS1 Pusher requires an API KEY to be defined")
5050
}
5151

5252
if cfg.SourceID == "" {
53-
return fmt.Errorf("The NS1 Pusher requires a SourceID to be defined")
53+
return fmt.Errorf("the NS1 Pusher requires a SourceID to be defined")
5454
}
5555

5656
ns1.Cfg = cfg

0 commit comments

Comments
 (0)