From b6a52a149f9b85df4c82d1527f9c1845238bfb0f Mon Sep 17 00:00:00 2001 From: Alan Moran Date: Tue, 21 May 2024 16:26:49 +0200 Subject: [PATCH] Fix Linting --- Makefile | 2 +- .../metricsforwarder/metricsforwarder_spec.rb | 16 ++++++---------- src/acceptance/Makefile | 5 +---- src/autoscaler/metricsforwarder/config/config.go | 1 - .../metricsforwarder/forwarder/syslog_emitter.go | 7 ++----- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 987301ad12..aefd25358e 100644 --- a/Makefile +++ b/Makefile @@ -231,7 +231,7 @@ lint: $(addprefix lint_,$(go_modules)) rubocop rubocop: @echo " - ruby scripts" @bundle install - @bundle exec rubocop ./spec ./packages + @bundle exec rubocop ${RUBOCOP_OPTS} ./spec ./packages .PHONY: markdownlint markdownlint: markdownlint-cli diff --git a/spec/jobs/metricsforwarder/metricsforwarder_spec.rb b/spec/jobs/metricsforwarder/metricsforwarder_spec.rb index afc5fb4f44..344f807c9f 100644 --- a/spec/jobs/metricsforwarder/metricsforwarder_spec.rb +++ b/spec/jobs/metricsforwarder/metricsforwarder_spec.rb @@ -15,7 +15,7 @@ it "supports syslog forwarding" do properties["autoscaler"]["metricsforwarder"] = { "syslog" => { - "server_address" => "syslog-server", + "server_address" => "syslog-server" } } @@ -24,17 +24,16 @@ "syslog" => { "server_address" => "syslog-server", "port" => 6067, - "tls" => { + "tls" => { "key_file" => "/var/vcap/jobs/loggr-syslog-agent/config/certs/syslog_agent.key", "cert_file" => "/var/vcap/jobs/loggr-syslog-agent/config/certs/syslog_agent.crt", - "ca_file" => "/var/vcap/jobs/loggr-syslog-agent/config/certs/loggregator_ca.crt", + "ca_file" => "/var/vcap/jobs/loggr-syslog-agent/config/certs/loggregator_ca.crt" } } } ) end - it "does not set username nor password if not configured" do properties["autoscaler"]["metricsforwarder"] = { "health" => { @@ -65,13 +64,10 @@ ) end - it "has a cred helper impl by default" do - expect(rendered_template).to include( - { - "cred_helper_impl" => "default" - } - ) + expect(rendered_template).to include({ + "cred_helper_impl" => "default" + }) end it "has a cred helper impl configured for stored procedures" do diff --git a/src/acceptance/Makefile b/src/acceptance/Makefile index 011af07aa9..1b2e6e0dfb 100644 --- a/src/acceptance/Makefile +++ b/src/acceptance/Makefile @@ -66,7 +66,4 @@ test: bin/test $(filter-out $@,$(MAKECMDGOALS)) lint: - @go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} run - -lint-fix: - go run github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} run --fix + @cd ../../; make lint_acceptance OPTS=${OPTS} diff --git a/src/autoscaler/metricsforwarder/config/config.go b/src/autoscaler/metricsforwarder/config/config.go index d9d6f81871..ded7468bb8 100644 --- a/src/autoscaler/metricsforwarder/config/config.go +++ b/src/autoscaler/metricsforwarder/config/config.go @@ -104,7 +104,6 @@ func (c *Config) Validate() error { if c.UsingSyslog() { if c.SyslogConfig.TLS.CACertFile == "" { return fmt.Errorf("Configuration error: SyslogServer Loggregator CACert is empty") - } if c.SyslogConfig.TLS.CertFile == "" { return fmt.Errorf("Configuration error: SyslogServer ClientCert is empty") diff --git a/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go b/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go index 491547dff8..2ffd1dbd45 100644 --- a/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go +++ b/src/autoscaler/metricsforwarder/forwarder/syslog_emitter.go @@ -14,9 +14,8 @@ import ( ) type SyslogEmitter struct { - logger lager.Logger - netConf syslog.NetworkTimeoutConfig - Writer egress.WriteCloser + logger lager.Logger + Writer egress.WriteCloser } type Counter struct{} @@ -77,7 +76,6 @@ func NewSyslogEmitter(logger lager.Logger, conf *config.Config) (MetricForwarder } func (mf *SyslogEmitter) EmitMetric(metric *models.CustomMetric) { - e := &loggregator_v2.Envelope{ InstanceId: fmt.Sprintf("%d", metric.InstanceIndex), Timestamp: time.Now().UnixNano(), @@ -98,5 +96,4 @@ func (mf *SyslogEmitter) EmitMetric(metric *models.CustomMetric) { if err != nil { mf.logger.Error("failed-to-write-metric-to-syslog", err) } - }