diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 566d97e..389679a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -3,7 +3,7 @@ version: 2 updates: - package-ecosystem: gomod directory: / - target-branch: develop + target-branch: master labels: - gomod schedule: @@ -11,7 +11,7 @@ updates: day: friday - package-ecosystem: github-actions directory: / - target-branch: develop + target-branch: master labels: - github-actions schedule: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 50c7ee9..b6e89cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,9 +22,9 @@ jobs: with: go-version: ^1.23 - name: golangci-lint - uses: golangci/golangci-lint-action@v5 + uses: golangci/golangci-lint-action@v6 - name: goreleaser-check - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: version: latest args: check -f .goreleaser.yml @@ -44,7 +44,7 @@ jobs: run: make test - name: test-coverage if: ${{ github.event_name == 'push' }} - uses: paambaati/codeclimate-action@v6.0.0 + uses: paambaati/codeclimate-action@v9.0.0 env: CC_TEST_REPORTER_ID: ${{ secrets.CC_TEST_REPORTER_ID }} with: @@ -65,8 +65,8 @@ jobs: with: go-version: ^1.23 - name: init codeql - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: 'go' - name: run analysis - uses: github/codeql-action/analyze@v2 + uses: github/codeql-action/analyze@v3 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e065861..9e45101 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: with: go-version: ^1.23 - name: build - uses: goreleaser/goreleaser-action@v5 + uses: goreleaser/goreleaser-action@v6 with: version: latest args: release -f .goreleaser.yml --clean diff --git a/.golangci.yml b/.golangci.yml index aae5d94..96c9fc3 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,5 @@ run: allow-parallel-runners: true - go: '1.22' output: print-issued-lines: true diff --git a/go.mod b/go.mod index 95f7073..51f07a5 100644 --- a/go.mod +++ b/go.mod @@ -3,11 +3,11 @@ module github.com/s0rg/decompose go 1.23 require ( - github.com/docker/docker v27.1.2+incompatible + github.com/docker/docker v27.2.1+incompatible github.com/emicklei/dot v1.6.2 github.com/expr-lang/expr v1.16.9 github.com/prometheus/procfs v0.15.1 - github.com/s0rg/set v1.2.0 + github.com/s0rg/set v1.2.1 github.com/s0rg/trie v1.3.3 gopkg.in/yaml.v3 v3.0.1 ) @@ -29,14 +29,14 @@ require ( github.com/opencontainers/go-digest v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0 // indirect github.com/pkg/errors v0.9.1 // indirect - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 // indirect + go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 // indirect go.opentelemetry.io/otel v1.29.0 // indirect go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.22.0 // indirect go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/sdk v1.22.0 // indirect go.opentelemetry.io/otel/trace v1.29.0 // indirect golang.org/x/net v0.24.0 // indirect - golang.org/x/sys v0.24.0 // indirect + golang.org/x/sys v0.25.0 // indirect golang.org/x/time v0.3.0 // indirect gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect gotest.tools/v3 v3.5.0 // indirect diff --git a/go.sum b/go.sum index 88c15d2..5fe166d 100644 --- a/go.sum +++ b/go.sum @@ -11,8 +11,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/distribution/reference v0.6.0 h1:0IXCQ5g4/QMHHkarYzh5l+u8T3t73zM5QvfrDyIgxBk= github.com/distribution/reference v0.6.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E= -github.com/docker/docker v27.1.2+incompatible h1:AhGzR1xaQIy53qCkxARaFluI00WPGtXn0AJuoQsVYTY= -github.com/docker/docker v27.1.2+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/docker v27.2.1+incompatible h1:fQdiLfW7VLscyoeYEBz7/J8soYFDZV1u6VW6gJEjNMI= +github.com/docker/docker v27.2.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -64,8 +64,8 @@ github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0leargg github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k= github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= -github.com/s0rg/set v1.2.0 h1:53b207YMktNQJXYei/oHuTR5oOO2e9+eieZOncYsh9g= -github.com/s0rg/set v1.2.0/go.mod h1:xz3nDbjF4nyMLvAHvmE7rigXpNrKKTsi6iANznIB1/4= +github.com/s0rg/set v1.2.1 h1:OMm/sxnO0tIqINEFdr7RbvMWLEFrdleNOuoEQNMTnGk= +github.com/s0rg/set v1.2.1/go.mod h1:/7U/8G00WOM4Nhlww3hXj7Q96Pw+bFinc17N5sh0l8E= github.com/s0rg/trie v1.3.3 h1:eBzjWs7hU5RSNvWWQVLKKhurfXxjf50WbAFVfis81Uw= github.com/s0rg/trie v1.3.3/go.mod h1:BGS9ZEqxUvxDT+4qai+YZnzvUDvTpJrx8zBtP7LBjS8= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= @@ -74,8 +74,8 @@ github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsT github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0 h1:4K4tsIXefpVJtvA/8srF4V4y0akAoPHkIslgAkjixJA= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.53.0/go.mod h1:jjdQuTGVsXV4vSs+CJ2qYDeDPf9yIJV23qlIzBm73Vg= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0 h1:TT4fX+nBOA/+LUkobKGW1ydGcn+G3vRw9+g5HwCphpk= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.54.0/go.mod h1:L7UH0GbB0p47T4Rri3uHjbpCFYrVrwc1I25QhNPiGK8= go.opentelemetry.io/otel v1.29.0 h1:PdomN/Al4q/lN6iBJEN3AwPvUiHPMlt93c8bqTG5Llw= go.opentelemetry.io/otel v1.29.0/go.mod h1:N/WtXPs1CNCUEx+Agz5uouwCba+i+bJGFicT8SR4NP8= go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.22.0 h1:9M3+rhx7kZCIQQhQRYaZCdNu1V73tm4TvXs2ntl98C4= @@ -107,8 +107,8 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= diff --git a/internal/client/inodes.go b/internal/client/inodes.go index f0e1d7a..8ec88f4 100644 --- a/internal/client/inodes.go +++ b/internal/client/inodes.go @@ -65,10 +65,6 @@ func (m *InodesMap) MarkListener(containerID string, pid int, path string) { } func (m *InodesMap) findListener(containerID string, pid int) (path string, ok bool) { - if m.l == nil { - return - } - pids, ok := m.l[containerID] if !ok { return @@ -80,10 +76,6 @@ func (m *InodesMap) findListener(containerID string, pid int) (path string, ok b } func (m *InodesMap) nameFor(containerID string, pid int) (name string, ok bool) { - if m.n == nil { - return - } - names, ok := m.n[containerID] if !ok { return diff --git a/internal/graph/connection_test.go b/internal/graph/connection_test.go index 4ca3e7c..7dbfe8e 100644 --- a/internal/graph/connection_test.go +++ b/internal/graph/connection_test.go @@ -39,3 +39,32 @@ func TestConnectionIsInbound(t *testing.T) { t.Fail() } } + +func TestConnectionUNIX(t *testing.T) { + t.Parallel() + + const uniqID = "/some/unix.sock" + + c := graph.Connection{ + Proto: graph.UNIX, + Path: uniqID, + } + + if c.IsLocal() { + t.Fail() + } + + if c.IsInbound() { + t.Fail() + } + + c.Listen = true + + if !c.IsInbound() { + t.Fail() + } + + if _, ok := c.UniqID(); !ok { + t.Fail() + } +} diff --git a/internal/node/port_test.go b/internal/node/port_test.go index 47a2f43..48c48d6 100644 --- a/internal/node/port_test.go +++ b/internal/node/port_test.go @@ -135,3 +135,34 @@ func TestPortsHasAny(t *testing.T) { } } } + +func TestPortJSON(t *testing.T) { + t.Parallel() + + testCases := []struct { + JSON []byte + Ok bool + Number int + }{ + {[]byte(`{`), false, 0}, + {[]byte(`{"value": "string"}`), false, 0}, + {[]byte(`{"kind": "tcp", "value": "80"}`), true, 80}, + } + + for _, tc := range testCases { + var p node.Port + + err := p.UnmarshalJSON(tc.JSON) + + switch { + case err != nil && !tc.Ok: + case err == nil && tc.Ok: + default: + t.FailNow() + } + + if p.Number != tc.Number { + t.FailNow() + } + } +}