diff --git a/src/go.mod b/src/go.mod index dba8896..4f91664 100644 --- a/src/go.mod +++ b/src/go.mod @@ -7,11 +7,12 @@ require ( github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5 github.com/containerd/log v0.1.0 // indirect github.com/distribution/reference v0.5.0 // indirect - github.com/docker/docker v25.0.4+incompatible + github.com/docker/docker v26.0.0+incompatible github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-units v0.5.0 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/google/gopacket v1.1.19 + github.com/moby/docker-image-spec v1.3.1 // indirect github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect github.com/morikuni/aec v1.0.0 // indirect github.com/opencontainers/image-spec v1.1.0-rc3 // indirect diff --git a/src/go.sum b/src/go.sum index f376962..769121e 100644 --- a/src/go.sum +++ b/src/go.sum @@ -849,8 +849,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.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.4+incompatible h1:XITZTrq+52tZyZxUOtFIahUf3aH367FLxJzt9vZeAF8= -github.com/docker/docker v25.0.4+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.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5XhDvyHbTtUxmeec= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= @@ -1054,12 +1054,15 @@ github.com/mattn/go-sqlite3 v1.14.14/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4 github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/minio/asm2plan9s v0.0.0-20200509001527-cdd76441f9d8/go.mod h1:mC1jAcsrzbxHt8iiaC+zU4b1ylILSosueou12R++wfY= github.com/minio/c2goasm v0.0.0-20190812172519-36a3d3bbc4f3/go.mod h1:RagcQ7I8IeTMnF8JTXieKnO4Z6JCsikNEzj0DwauVzE= +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.0.0-20210619224110-3f7ff695adc6 h1:dcztxKSvZ4Id8iPpHERQBbIJfabdt4wUm5qy3wOL2Zc= github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6/go.mod h1:E2VnQOmVuvZB6UYnnDB0qG5Nq/1tD9acaOpo6xmt0Kw= github.com/morikuni/aec v1.0.0 h1:nP9CBfwrvYnBRgY6qfDQkygYDmYwOilePFkwzv4dU8A= github.com/morikuni/aec v1.0.0/go.mod h1:BbKIizmSmc5MMPqRYbxO4ZU0S0+P200+tUnFx7PXmsc= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= +github.com/opencontainers/image-spec v1.0.2/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0= github.com/opencontainers/image-spec v1.1.0-rc3 h1:fzg1mXZFj8YdPeNkRXMg+zb88BFV0Ys52cJydRwBkb8= github.com/opencontainers/image-spec v1.1.0-rc3/go.mod h1:X4pATf0uXsnn3g5aiGIsVnJBR4mxhKzfwmvK/B2NTm8= github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY= diff --git a/src/group.go b/src/group.go index 0e7a648..ebb0a9b 100644 --- a/src/group.go +++ b/src/group.go @@ -30,12 +30,12 @@ type LazyGroup struct { var err error func (lg LazyGroup) MainLoop() { - // rxPacketCount is continiously updated by the getRxPackets goroutine + // rxPacketCount is continuously updated by the getRxPackets goroutine var rxPacketCount int go lg.getRxPackets(&rxPacketCount) inactiveSeconds := 0 - // initialize a slice to keep track of recnt network traffic + // initialize a slice to keep track of recent network traffic rxHistory := make([]int, int(math.Ceil(float64(lg.inactiveTimeout/lg.pollRate)))) sleepTime := time.Duration(lg.pollRate) * time.Second for { @@ -74,7 +74,7 @@ func (lg LazyGroup) MainLoop() { func (lg LazyGroup) getContainers() []types.Container { filter := filters.NewArgs(filters.Arg("label", "lazytainer.group="+lg.groupName)) - containers, err := dockerClient.ContainerList(context.Background(), types.ContainerListOptions{All: true, Filters: filter}) + containers, err := dockerClient.ContainerList(context.Background(), container.ListOptions{All: true, Filters: filter}) check(err) return containers @@ -103,7 +103,7 @@ func (lg LazyGroup) startContainers() { debugLogger.Println("starting container(s)") for _, c := range lg.getContainers() { if lg.sleepMethod == "stop" || lg.sleepMethod == "" { - if err := dockerClient.ContainerStart(context.Background(), c.ID, types.ContainerStartOptions{}); err != nil { + if err := dockerClient.ContainerStart(context.Background(), c.ID, container.StartOptions{}); err != nil { fmt.Printf("ERROR: Unable to start container %s: %s\n", c.Names[0], err) } else { infoLogger.Println("started container ", c.Names[0]) @@ -140,7 +140,7 @@ func (lg LazyGroup) getRxPackets(packetCount *int) { // At some point this wraps around I think. // I have no idea when that point is or what the consequences of letting it happen are so I'm forcing it to be 1m *packetCount = (*packetCount + 1) % 1000000 - debugLogger.Println("group", lg.groupName, "recieved", *packetCount, "packets") + debugLogger.Println("group", lg.groupName, "received", *packetCount, "packets") } } diff --git a/src/lazytainer.go b/src/lazytainer.go index 40dcfc1..863feec 100644 --- a/src/lazytainer.go +++ b/src/lazytainer.go @@ -2,13 +2,13 @@ package main import ( "context" - "io/ioutil" + "io" "log" "os" "strconv" "strings" - "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/client" ) @@ -26,7 +26,7 @@ func main() { // if the verbose flag isn't set to true, don't log debug logs verbose, verboseFlagSet := os.LookupEnv("VERBOSE") if !verboseFlagSet || strings.ToLower(verbose) != "true" { - debugLogger.SetOutput(ioutil.Discard) + debugLogger.SetOutput(io.Discard) } // configure groups. eventually it might be nice to have file based config as well. @@ -53,7 +53,7 @@ func configureFromLabels() map[string]LazyGroup { dockerClient.NegotiateAPIVersion(context.Background()) filter := filters.NewArgs(filters.Arg("id", container_id)) - containers, err := dockerClient.ContainerList(context.Background(), types.ContainerListOptions{All: true, Filters: filter}) + containers, err := dockerClient.ContainerList(context.Background(), container.ListOptions{All: true, Filters: filter}) check(err) groups := make(map[string]LazyGroup)