Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compression grouiming, dependencies up #74

Merged
merged 1 commit into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
run:
allow-parallel-runners: true
go: '1.21'
go: '1.22'

output:
format: 'colored-line-number'
print-issued-lines: true
print-linter-name: true
sort-results: true
Expand All @@ -27,6 +26,7 @@ linters:
- depguard
- maligned
- varcheck
- intrange
- ifshort
- ireturn
- gofumpt
Expand All @@ -37,16 +37,13 @@ linters-settings:
errcheck:
check-type-assertions: true
govet:
check-shadowing: true
enable-all: true
funlen:
lines: 80
ignore-comments: true
cyclop:
max-complexity: 15
max-complexity: 13
skip-tests: true
gocognit:
min-complexity: 40
gocritic:
enabled-tags:
- performance
Expand Down Expand Up @@ -75,5 +72,6 @@ issues:
- goerr113
- gocritic
- errcheck
- maintidx
- funlen
- dupl
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ archives:
- decompose-bin
name_template: >-
{{ .ProjectName }}_
{{- .Tag }}_
{{- .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}_
{{- .Tag }}
{{- else }}{{ .Arch }}{{ end }}
format_overrides:
- goos: windows
format: zip
Expand Down
3 changes: 2 additions & 1 deletion cmd/decompose/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const (
autoPrefix = "auto:"
defaultProto = "all"
defaultOutput = "-"
defaultDiff = 3
)

// build-time values.
Expand Down Expand Up @@ -291,7 +292,7 @@ func prepareConfig() (
}

if fCompress {
cmp := graph.NewCompressor(bildr)
cmp := graph.NewCompressor(bildr, defaultDiff, true)

bildr, nwr = cmp, cmp
}
Expand Down
10 changes: 9 additions & 1 deletion docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ Reverse-engineering tool for docker environments.

# how to run

# scan containers
```
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /:/rootfs:ro \
-e IN_DOCKER_PROC_ROOT=/rootfs \
s0rg/decompose:latest -format stat
s0rg/decompose:latest > mystream.json
```

# process results
```
docker run \
s0rg/decompose:latest -load mystream.json -format sdsl > workspace.dsl
```


[more options and documentaion](https://github.com/s0rg/decompose)
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/s0rg/decompose
go 1.22

require (
github.com/docker/docker v25.0.5+incompatible
github.com/docker/docker v26.0.0+incompatible
github.com/emicklei/dot v1.6.1
github.com/expr-lang/expr v1.16.1
github.com/expr-lang/expr v1.16.2
github.com/prometheus/procfs v0.13.0
github.com/s0rg/set v1.2.0
github.com/s0rg/trie v1.3.1
github.com/s0rg/trie v1.3.3
gopkg.in/yaml.v3 v3.0.1
)

Expand All @@ -23,6 +23,7 @@ require (
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/term v0.5.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
Expand Down
14 changes: 8 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ 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.5.0 h1:/FUIFXtfc/x2gpa5/VGfiGLuOIdYa1t65IKK2OFGvA0=
github.com/distribution/reference v0.5.0/go.mod h1:BbU0aIcezP1/5jX/8MP0YiH4SdvB5Y4f/wlDRiLyi3E=
github.com/docker/docker v25.0.5+incompatible h1:UmQydMduGkrD5nQde1mecF/YnSbTOaPeFIeP5C4W+DE=
github.com/docker/docker v25.0.5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
github.com/docker/docker v26.0.0+incompatible h1:Ng2qi+gdKADUa/VM+6b6YaY2nlZhk/lVJiKR/2bMudU=
github.com/docker/docker v26.0.0+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=
github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
github.com/emicklei/dot v1.6.1 h1:ujpDlBkkwgWUY+qPId5IwapRW/xEoligRSYjioR6DFI=
github.com/emicklei/dot v1.6.1/go.mod h1:DeV7GvQtIw4h2u73RKBkkFdvVAz0D9fzeJrgPW6gy/s=
github.com/expr-lang/expr v1.16.1 h1:Na8CUcMdyGbnNpShY7kzcHCU7WqxuL+hnxgHZ4vaz/A=
github.com/expr-lang/expr v1.16.1/go.mod h1:uCkhfG+x7fcZ5A5sXHKuQ07jGZRl6J0FCAaf2k4PtVQ=
github.com/expr-lang/expr v1.16.2 h1:JvMnzUs3LeVHBvGFcXYmXo+Q6DPDmzrlcSBO6Wy3w4s=
github.com/expr-lang/expr v1.16.2/go.mod h1:uCkhfG+x7fcZ5A5sXHKuQ07jGZRl6J0FCAaf2k4PtVQ=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
Expand All @@ -46,6 +46,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0=
github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y=
github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A=
Expand All @@ -64,8 +66,8 @@ github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBO
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/trie v1.3.1 h1:O9THfLSiXqBN08gJoHegwdkkaGIIs3GnXlYQswfXWTk=
github.com/s0rg/trie v1.3.1/go.mod h1:BGS9ZEqxUvxDT+4qai+YZnzvUDvTpJrx8zBtP7LBjS8=
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=
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
Expand Down
2 changes: 1 addition & 1 deletion internal/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Create(kind string) (b graph.NamedBuilderWriter, ok bool) {

func SupportCluster(n string) (yes bool) {
switch n {
case KindDOT, KindStructurizr, KindSTAT, KindPlantUML:
case KindStructurizr, KindSTAT, KindPlantUML:
return true
}

Expand Down
2 changes: 1 addition & 1 deletion internal/builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ func TestSupportCluster(t *testing.T) {
t.Parallel()

does := []string{
builder.KindDOT,
builder.KindSTAT,
builder.KindStructurizr,
builder.KindPlantUML,
}

doesnt := []string{
builder.KindDOT,
builder.KindJSON,
builder.KindTREE,
builder.KindYAML,
Expand Down
10 changes: 6 additions & 4 deletions internal/builder/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ import (
)

func joinConnections(conns []*node.Connection, sep string) (rv string) {
raw := make([]string, 0, len(conns))
tmp := make([]string, 0, len(conns))

for _, c := range conns {
raw = append(raw, c.Port.Label())
tmp = append(tmp, c.Port.Label())
}

slices.Sort(raw)
slices.Sort(tmp)
tmp = slices.Compact(tmp)

return strings.Join(raw, sep)
return strings.Join(tmp, sep)
}

func joinListeners(ports map[string][]*node.Port, sep string) (rv string) {
Expand All @@ -29,6 +30,7 @@ func joinListeners(ports map[string][]*node.Port, sep string) (rv string) {
}

slices.Sort(tmp)
tmp = slices.Compact(tmp)

return strings.Join(tmp, sep)
}
Loading
Loading