Skip to content

Commit 57b4a2a

Browse files
mariasharamprice
andcommitted
Fix linting errors
Signed-off-by: Aram Price <aram.price@broadcom.com> Co-authored-by: Aram Price <aram.price@broadcom.com>
1 parent ad27aa1 commit 57b4a2a

7 files changed

Lines changed: 26 additions & 40 deletions

File tree

handler/common_event_format.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (cef concreteCommonEventFormat) ProduceHTTPRequestEventLog(request *http.Re
5252
var buffer bytes.Buffer
5353

5454
buffer.WriteString(extension)
55-
buffer.WriteString(fmt.Sprintf("cs4=%s cs4Label=statusReason", respBody))
55+
buffer.WriteString(fmt.Sprintf("cs4=%s cs4Label=statusReason", respBody)) //nolint:staticcheck
5656
extension = buffer.String()
5757
}
5858

@@ -73,7 +73,7 @@ func (cef concreteCommonEventFormat) ProduceNATSRequestEventLog(addr string, por
7373
var buffer bytes.Buffer
7474

7575
buffer.WriteString(extension)
76-
buffer.WriteString(fmt.Sprintf("cs1=%s cs1Label=statusReason", respBody))
76+
buffer.WriteString(fmt.Sprintf("cs1=%s cs1Label=statusReason", respBody)) //nolint:staticcheck
7777
extension = buffer.String()
7878
}
7979

main/agent.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import (
1212

1313
boshapp "github.com/cloudfoundry/bosh-agent/v2/app"
1414
"github.com/cloudfoundry/bosh-agent/v2/infrastructure/agentlogger"
15-
"github.com/cloudfoundry/bosh-agent/v2/monitaccess"
1615
"github.com/cloudfoundry/bosh-agent/v2/platform"
16+
"github.com/cloudfoundry/bosh-agent/v2/platform/firewall"
1717
)
1818

1919
const mainLogTag = "main"
@@ -86,7 +86,7 @@ func main() {
8686
compileTarball(cmd, os.Args[2:])
8787
return
8888
case "enable-monit-access":
89-
monitaccess.EnableMonitAccess(logger, cmd, os.Args[2:])
89+
firewall.EnableMonitAccess(logger, cmd, os.Args[2:])
9090
return
9191
}
9292
}

monitaccess/monit_access_windows.go

Lines changed: 0 additions & 11 deletions
This file was deleted.

platform/firewall/firewall.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,22 @@
1313
// fails in nested container environments due to cgroup filesystem bind-mount issues.
1414
package firewall
1515

16+
import "fmt"
17+
18+
const (
19+
TableName = "bosh_agent"
20+
MonitChainName = "monit_access"
21+
MonitJobsChainName = "monit_access_jobs"
22+
NATSChainName = "nats_access"
23+
MonitPort = 2822
24+
MonitAccessLogPrefix = "bosh-monit-access: "
25+
)
26+
27+
var (
28+
ErrMonitJobsChainNotFound = fmt.Errorf("%s chain not found", MonitJobsChainName)
29+
ErrBoshTableNotFound = fmt.Errorf("%s table not found", TableName)
30+
)
31+
1632
// Manager handles firewall setup
1733
//
1834
//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
//
99
// This binary serves as a replacement for the complex bash firewall setup logic
1010
// that was previously in job service scripts.
11-
package monitaccess
11+
package firewall
1212

1313
import (
1414
"errors"
1515
"os"
1616

17-
"github.com/cloudfoundry/bosh-agent/v2/platform/firewall"
1817
boshlog "github.com/cloudfoundry/bosh-utils/logger"
1918
)
2019

@@ -23,24 +22,24 @@ func EnableMonitAccess(logger boshlog.Logger, command string, args []string) {
2322

2423
// Validate nftables mode: verify if nftables is available
2524
if len(args) > 1 && args[0] == "--validate-nftables-present" {
26-
mgr, err := firewall.NewNftablesFirewall(logger)
25+
mgr, err := NewNftablesFirewall(logger)
2726
if err != nil {
2827
os.Exit(1)
2928
}
30-
defer mgr.Cleanup()
29+
defer mgr.Cleanup() //nolint:errcheck
3130
os.Exit(0)
3231
}
3332

34-
mgr, err := firewall.NewNftablesFirewall(logger)
33+
mgr, err := NewNftablesFirewall(logger)
3534
if err != nil {
36-
if errors.Is(err, firewall.ErrMonitJobsChainNotFound) {
35+
if errors.Is(err, ErrMonitJobsChainNotFound) {
3736
logger.Info(command, "monit_access_jobs chain not found (old stemcell), skipping")
3837
os.Exit(0)
3938
}
4039
logger.Error(command, "Failed to create firewall manager: %v", err)
4140
os.Exit(1)
4241
}
43-
defer mgr.Cleanup()
42+
defer mgr.Cleanup() //nolint:errcheck
4443

4544
// Setup mode: add firewall rule
4645
logger.Info(command, "Setting up monit firewall rule")

platform/firewall/nftables_firewall.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,6 @@ import (
1919
"golang.org/x/sys/unix"
2020
)
2121

22-
const (
23-
TableName = "bosh_agent"
24-
MonitChainName = "monit_access"
25-
MonitJobsChainName = "monit_access_jobs"
26-
NATSChainName = "nats_access"
27-
MonitPort = 2822
28-
MonitAccessLogPrefix = "bosh-monit-access: "
29-
)
30-
31-
var (
32-
ErrMonitJobsChainNotFound = fmt.Errorf("%s chain not found", MonitJobsChainName)
33-
ErrBoshTableNotFound = fmt.Errorf("%s table not found", TableName)
34-
)
35-
3622
// NftablesConn abstracts the nftables connection for testing
3723
//
3824
//counterfeiter:generate -header ./firewallfakes/linux_build_constraint.txt . NftablesConn

platform/firewall/nftables_firewall_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,6 @@ var _ = Describe("NftablesFirewall", func() {
277277
err := manager.EnableMonitAccess()
278278
Expect(err).To(HaveOccurred())
279279
Expect(err.Error()).To(ContainSubstring("bosh_agent table not found"))
280-
})
281-
282-
It("does not add any rules", func() {
283-
_ = manager.EnableMonitAccess()
284280
Expect(fakeConn.AddRuleCallCount()).To(Equal(0))
285281
})
286282
})

0 commit comments

Comments
 (0)