Skip to content

Commit f128aac

Browse files
committed
fix: refactor pkg/infoutil in order to resolve import cycle
This pull request will add the fields such as `CONTAINER_NAME` and `IMAGE_NAME` to the journald log entries sent by containers when `nerdctl run` is run with `--log-driver=journald`. However, the following `import cycle not allowed` error occurs when trying to import `containerutil package` in `logging package` in the implementation to be changed in this pull request. ``` > make CGO_ENABLED=0 GOOS=linux go -C /local/home/haytok/workspace/nerdctl build -ldflags "-s -w -X github.com/containerd/nerdctl/v2/pkg/version.Version=0d7dc8ec.m -X github.com/containerd/nerdctl/v2/pkg/version.Revision=0d7dc8ec4cda815acfca165b0281e801c4c5ef6e.m" -o /local/home/haytok/workspace/nerdctl/_output/nerdctl ./cmd/nerdctl package github.com/containerd/nerdctl/v2/cmd/nerdctl ... imports github.com/containerd/nerdctl/v2/pkg/infoutil: import cycle not allowed make: *** [nerdctl] Error 1 ``` Therefore, this commit refactors `infoutil package` to avoid `import cycle not allowd` error in the next commit. Signed-off-by: Hayato Kiwata <[email protected]>
1 parent db20fec commit f128aac

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/cmd/system/info.go

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"github.com/containerd/nerdctl/v2/pkg/infoutil"
3838
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
3939
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/native"
40+
"github.com/containerd/nerdctl/v2/pkg/logging"
4041
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
4142
"github.com/containerd/nerdctl/v2/pkg/strutil"
4243
)
@@ -72,6 +73,7 @@ func Info(ctx context.Context, client *containerd.Client, options types.SystemIn
7273
if err != nil {
7374
return err
7475
}
76+
infoCompat.Plugins.Log = logging.Drivers()
7577
default:
7678
return fmt.Errorf("unknown mode %q", options.Mode)
7779
}

pkg/infoutil/infoutil.go

-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ import (
3535
"github.com/containerd/nerdctl/v2/pkg/buildkitutil"
3636
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/dockercompat"
3737
"github.com/containerd/nerdctl/v2/pkg/inspecttypes/native"
38-
"github.com/containerd/nerdctl/v2/pkg/logging"
3938
"github.com/containerd/nerdctl/v2/pkg/version"
4039
)
4140

@@ -82,7 +81,6 @@ func Info(ctx context.Context, client *containerd.Client, snapshotter, cgroupMan
8281
info.ID = daemonIntro.UUID
8382
// Storage drivers and logging drivers are not really Server concept for nerdctl, but mimics `docker info` output
8483
info.Driver = snapshotter
85-
info.Plugins.Log = logging.Drivers()
8684
info.Plugins.Storage = snapshotterPlugins
8785
info.SystemTime = time.Now().Format(time.RFC3339Nano)
8886
info.LoggingDriver = "json-file" // hard-coded

0 commit comments

Comments
 (0)