Skip to content

Commit

Permalink
update dependencides and fix lint issues (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnmahanth authored May 6, 2024
1 parent c801681 commit e125799
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 157 deletions.
12 changes: 8 additions & 4 deletions autodetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/deepfence/vessel/docker"
selfPodman "github.com/deepfence/vessel/podman"
"github.com/deepfence/vessel/utils"
"github.com/docker/docker/api/types"
containerTypes "github.com/docker/docker/api/types/container"
"github.com/docker/docker/client"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -240,9 +240,10 @@ func isDockerRunning(host string) (bool, error) {
return false, errors.Wrapf(err, " :error creating docker client")
}
defer dockerCli.Close()
containers, err := dockerCli.ContainerList(context.Background(), types.ContainerListOptions{
All: true, Size: false,
})
containers, err := dockerCli.ContainerList(context.Background(),
containerTypes.ListOptions{
All: true, Size: false,
})
if err != nil {
return false, errors.Wrapf(err, " :error creating docker client")
}
Expand All @@ -268,6 +269,9 @@ func isContainerdRunning(host string) (bool, error) {
namespace_store := clientd.NamespaceService()

list, err := namespace_store.List(context.Background())
if err != nil {
return false, errors.Wrapf(err, " :error creating containerd client")
}
for _, l := range list {

namespace := namespaces.WithNamespace(context.Background(), l)
Expand Down
3 changes: 2 additions & 1 deletion cmd/vessel/main.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package main

import (
"os"

"github.com/deepfence/vessel"
"github.com/joho/godotenv"
"github.com/sirupsen/logrus"
"os"
)

var activeRuntime string
Expand Down
9 changes: 7 additions & 2 deletions containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
"github.com/deepfence/vessel/utils"
"github.com/sirupsen/logrus"

"github.com/containerd/containerd"
containerdApi "github.com/containerd/containerd"
"github.com/containerd/containerd/images"
"github.com/containerd/containerd/images/archive"
Expand All @@ -32,7 +31,7 @@ func New(host string) *Containerd {
}

func getNamespaces(host string) []string {
clientd, err := containerd.New(strings.Replace(host, "unix://", "", 1))
clientd, err := containerdApi.New(strings.Replace(host, "unix://", "", 1))
if err != nil {
return nil
}
Expand Down Expand Up @@ -233,6 +232,9 @@ func (c Containerd) ExtractFileSystem(imageTarPath string, outputTarPath string,
info, _ := container.Info(ctx)
snapshotter := client.SnapshotService(info.Snapshotter)
mounts, err := snapshotter.Mounts(ctx, info.SnapshotKey)
if err != nil {
logrus.Errorf("Error mount snapshot %s: %s", info.SnapshotKey, err.Error())
}
target := strings.Replace(outputTarPath, ".tar", "", 1) + containerName
_, err = exec.Command("mkdir", target).Output()
if err != nil && !strings.Contains(err.Error(), "exit status 1") {
Expand Down Expand Up @@ -281,6 +283,9 @@ func (c Containerd) ExtractFileSystemContainer(containerId string, namespace str
info, _ := container.Info(ctx)
snapshotter := client.SnapshotService(info.Snapshotter)
mounts, err := snapshotter.Mounts(ctx, info.SnapshotKey)
if err != nil {
logrus.Errorf("Error mount snapshot %s: %s", info.SnapshotKey, err.Error())
}
target := strings.Replace(outputTarPath, ".tar", "", 1) + containerId
_, err = exec.Command("mkdir", target).Output()
if err != nil && !strings.Contains(err.Error(), "exit status 1") {
Expand Down
2 changes: 1 addition & 1 deletion docker/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (d Docker) ExtractFileSystem(imageTarPath string, outputTarPath string, ima
}
}
if imageId == "" {
return errors.New("image not found from docker load with output: " + string(imageMsg.Bytes()))
return errors.New("image not found from docker load with output: " + imageMsg.String())
}
containerOutput, err := utils.RunCommand(exec.Command("docker", "create", imageId), "docker create: "+imageId)
if err != nil {
Expand Down
69 changes: 34 additions & 35 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,64 +1,63 @@
module github.com/deepfence/vessel

go 1.20
go 1.21

require (
github.com/containerd/containerd v1.7.11
github.com/docker/docker v24.0.7+incompatible
github.com/containerd/containerd v1.7.16
github.com/docker/docker v26.1.1+incompatible
github.com/joho/godotenv v1.5.1
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
google.golang.org/grpc v1.60.1
google.golang.org/grpc v1.63.2
)

require (
github.com/AdaLogics/go-fuzz-headers v0.0.0-20230811130428-ced1acdcaa24 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20230306123547-8075edf89bb0 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/hcsshim v0.11.4 // indirect
github.com/containerd/cgroups v1.1.0 // indirect
github.com/containerd/continuity v0.4.2 // indirect
github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/Microsoft/hcsshim v0.12.3 // indirect
github.com/containerd/cgroups/v3 v3.0.2 // indirect
github.com/containerd/continuity v0.4.3 // indirect
github.com/containerd/errdefs v0.1.0 // indirect
github.com/containerd/fifo v1.1.0 // indirect
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/ttrpc v1.2.2 // indirect
github.com/containerd/ttrpc v1.2.3 // indirect
github.com/containerd/typeurl/v2 v2.1.1 // indirect
github.com/docker/distribution v2.8.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/go-connections v0.5.0 // indirect
github.com/docker/go-events v0.0.0-20190806004212-e31b211e4f1c // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/felixge/httpsnoop v1.0.3 // indirect
github.com/go-logr/logr v1.2.4 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/klauspost/compress v1.16.0 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/klauspost/compress v1.17.8 // indirect
github.com/moby/docker-image-spec v1.3.1 // indirect
github.com/moby/locker v1.0.1 // indirect
github.com/moby/sys/mountinfo v0.6.2 // indirect
github.com/moby/sys/mountinfo v0.7.1 // indirect
github.com/moby/sys/sequential v0.5.0 // indirect
github.com/moby/sys/signal v0.7.0 // indirect
github.com/moby/sys/user v0.1.0 // 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
github.com/opencontainers/image-spec v1.1.0-rc2.0.20221005185240-3a7f492d3f1b // indirect
github.com/opencontainers/runc v1.1.5 // indirect
github.com/opencontainers/runtime-spec v1.1.0-rc.1 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/opencontainers/runtime-spec v1.2.0 // indirect
github.com/opencontainers/selinux v1.11.0 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
go.opentelemetry.io/otel v1.19.0 // indirect
go.opentelemetry.io/otel/metric v1.19.0 // indirect
go.opentelemetry.io/otel/trace v1.19.0 // indirect
golang.org/x/mod v0.11.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/sync v0.4.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.10.0 // indirect
google.golang.org/genproto v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
google.golang.org/protobuf v1.31.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.51.0 // indirect
go.opentelemetry.io/otel v1.26.0 // indirect
go.opentelemetry.io/otel/metric v1.26.0 // indirect
go.opentelemetry.io/otel/trace v1.26.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240429193739-8cf5692501f6 // indirect
google.golang.org/protobuf v1.34.0 // indirect
gotest.tools/v3 v3.5.1 // indirect
)
Loading

0 comments on commit e125799

Please sign in to comment.