Skip to content
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
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ linters:
- depguard
- exhaustruct
- tagliatelle
- wsl
settings:
errcheck:
check-type-assertions: true
Expand Down
1 change: 1 addition & 0 deletions entry_groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (e *entryGroups) get(containerID string) (*avahi.EntryGroup, func(), error)
}

e.mutex.Lock()

if _, ok := e.groups[containerID]; !ok {
entryGroup, err := e.avahiServer.EntryGroupNew()
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
require (
github.com/carlmjohnson/versioninfo v0.22.5
github.com/coreos/go-systemd/v22 v22.6.0
github.com/google/gops v0.3.28
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gops v0.3.28 h1:2Xr57tqKAmQYRAfG12E+yLcoa2Y42UJo2lOrUFL9ark=
github.com/google/gops v0.3.28/go.mod h1:6f6+Nl8LcHrzJwi8+p0ii+vmBFSlB4f8cOOkTJ7sk4c=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 h1:YBftPWNWd4WwGqtY2yeZL2ef8rHAxPBD8KFhJpmcqms=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0/go.mod h1:YN5jB8ie0yfIUg6VvR9Kz84aCaG7AsGZnLjhHbUqwPg=
github.com/holoplot/go-avahi v1.0.1 h1:XcqR2keL4qWRnlxHD5CAOdWpLFZJ+EOUK0vEuylfvvk=
Expand Down
18 changes: 18 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/coreos/go-systemd/v22/daemon"
"github.com/docker/docker/client"
"github.com/godbus/dbus/v5"
"github.com/google/gops/agent"
"github.com/holoplot/go-avahi"
"github.com/kelseyhightower/envconfig"
"ldddns.arnested.dk/internal/log"
Expand All @@ -29,6 +30,7 @@ var (
//
//nolint:lll
type Config struct {
Gops bool `default:"false" json:"Gops" split_words:"true"`
HostnameLookup []string `default:"env:VIRTUAL_HOST,containerName" json:"HostnameLookup" split_words:"true"`
IgnoreDockerComposeOneoff bool `default:"true" json:"IgnoreDockerComposeOneoff" split_words:"true"`
}
Expand All @@ -53,6 +55,8 @@ func main() {
panic(fmt.Errorf("could not read environment config: %w", err))
}

gops(config.Gops)

docker, err := client.NewClientWithOpts(
client.FromEnv,
client.WithAPIVersionNegotiation(),
Expand Down Expand Up @@ -132,3 +136,17 @@ func getVersion() string {

return version
}

// gops starts the gops agent if the config option is set.
func gops(start bool) {
if !start {
return
}

err := agent.Listen(agent.Options{
ShutdownCleanup: true, // automatically closes on os.Interrupt
})
if err != nil {
panic(fmt.Errorf("could not start gops agent: %w", err))
}
}
Loading