Skip to content

Commit

Permalink
chore: refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: thediveo <[email protected]>
  • Loading branch information
thediveo committed Jan 18, 2024
1 parent d9ffd27 commit 6aacc31
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
4 changes: 0 additions & 4 deletions decorator/dockernet/dockernet.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"context"
"fmt"
"strings"
"time"

"github.com/siemens/ghostwire/v2/decorator"
"github.com/siemens/ghostwire/v2/network"
Expand Down Expand Up @@ -70,7 +69,6 @@ type dockerNetworks struct {
func makeDockerNetworks(ctx context.Context, engine *model.ContainerEngine, allnetns network.NetworkNamespaces) (
docknets dockerNetworks,
) {
start := time.Now()
dockerclient, err := client.NewClientWithOpts(
client.WithHost(engine.API),
client.WithAPIVersionNegotiation())
Expand All @@ -81,8 +79,6 @@ func makeDockerNetworks(ctx context.Context, engine *model.ContainerEngine, alln
}
networks, _ := dockerclient.NetworkList(ctx, types.NetworkListOptions{})
_ = dockerclient.Close()
span := time.Since(start)
log.Debugf("docker(%d) network ls took %s", engine.PID, span)
netnsid, _ := ops.NamespacePath(fmt.Sprintf("/proc/%d/ns/net", engine.PID)).ID()
docknets.networks = networks
docknets.engine = engine
Expand Down
7 changes: 7 additions & 0 deletions decorator/podmannet/libpodclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ func ensureReaderClosed(resp *http.Response) {
resp.Body.Close()
}

// ping the /_ping API endpoint (which is unversioned) and return the value of
// the “Libpod-Api-Version” header that came back from this endpoint, or an
// empty string. The libpod API version is in semver format, without any “v”
// prefix.
//
// Use the returned API version to set Client.libpodVersion so that following
// libpod endpoint calls are properly versioned.
func (c *Client) ping(ctx context.Context) (libpodAPIVersion string) {
resp, err := c.get(ctx, "/_ping")
defer ensureReaderClosed(resp)
Expand Down
4 changes: 0 additions & 4 deletions decorator/podmannet/podmannet.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package podmannet
import (
"context"
"fmt"
"time"

"github.com/siemens/ghostwire/v2/decorator"
"github.com/siemens/ghostwire/v2/decorator/dockernet"
Expand Down Expand Up @@ -48,7 +47,6 @@ type podmanNetworks struct {
func makePodmanNetworks(ctx context.Context, engine *model.ContainerEngine, allnetns network.NetworkNamespaces) (
podmannets podmanNetworks,
) {
start := time.Now()
libpodclient, err := newLibpodClient(engine.API)
if err != nil {
log.Warnf("cannot discover podman-managed networks from API %s, reason: %s",
Expand All @@ -58,8 +56,6 @@ func makePodmanNetworks(ctx context.Context, engine *model.ContainerEngine, alln
libpodclient.libpodVersion = libpodclient.ping(ctx)
networks, _ := libpodclient.networkList(ctx)
_ = libpodclient.Close()
span := time.Since(start)
log.Debugf("podman(%d) network ls took %s", engine.PID, span)
netnsid, _ := ops.NamespacePath(fmt.Sprintf("/proc/%d/ns/net", engine.PID)).ID()
podmannets.networks = networks
podmannets.engine = engine
Expand Down
2 changes: 1 addition & 1 deletion defs_version.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6aacc31

Please sign in to comment.