Refactor the package structure in cmd/nerdctl#1639
Conversation
95f23b0 to
b05df8f
Compare
154b510 to
4d114ab
Compare
djdongjin
left a comment
There was a problem hiding this comment.
nit: integration might be a better name than e2e
nice catch( |
4d114ab to
50cc8b3
Compare
50cc8b3 to
3d2fcd9
Compare
|
|
||
| "github.com/containerd/containerd/events" | ||
| "github.com/containerd/containerd/log" | ||
| client2 "github.com/containerd/nerdctl/cmd/nerdctl/client" |
There was a problem hiding this comment.
I'd prefer the package name to be like ncclient
There was a problem hiding this comment.
Yes, I will clean dirty name when I pass all CI(lol
There was a problem hiding this comment.
another suggestion is ndclient 😃 since nd reads more similar to nerdctl
There was a problem hiding this comment.
I'd argue that the contaiNERD client library is also "nerd" 🤓
| "github.com/containerd/containerd/events" | ||
| "github.com/containerd/containerd/log" | ||
| client2 "github.com/containerd/nerdctl/cmd/nerdctl/client" | ||
| fmt2 "github.com/containerd/nerdctl/cmd/nerdctl/utils" |
There was a problem hiding this comment.
I'd prefer the package name to be something like utils/fmtutil.
| */ | ||
|
|
||
| package main | ||
| package create |
There was a problem hiding this comment.
Should this be in the nerdctl/container package, or maybe better in the nerdctl/container/create pkg?
Because the "canonical" form of nerdctl create is nerdctl container create.
Same applies to the run, exec, cp commands, etc.
Also, nerdctl info should be in nerdctl/system or nerdctl/system/info.
| "github.com/containerd/containerd/images" | ||
| "github.com/containerd/containerd/images/converter" | ||
| "github.com/containerd/containerd/images/converter/uncompress" | ||
| client2 "github.com/containerd/nerdctl/cmd/nerdctl/client" |
There was a problem hiding this comment.
Maybe we can change either the package name (something like cliclient or nerdclient) or rename the variable client to avoid client2.
87fa51d to
8e52853
Compare
Revert unexpected changes in 5588f70 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
b46d661 to
dc34976
Compare
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
dc34976 to
206e0c8
Compare
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
48788c3 to
c0566a4
Compare
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
|
A bunch of functions seems misplaced in wrong files. (See my follow-up commits above) I'm trying to fix them, but if I fail to do that by the end of the day, I'll prioritize merging other PRs. |
|
And I also don't want to split the integration test package from the command packages |
There was a problem hiding this comment.
I'm trying to fix them, but if I fail to do that by the end of the day, I'll prioritize merging other PRs.
But I fear that basically this PR isn't rebaseable after merging other PRs...
Thank you for the following up. Possible plan B might be incrementally separating out cobra-independent functions into pkg directory but I'm not sure we need to do so because codes under cmd/nerdctl are tightly coupled. (cc @Zheaoli)
| func InspectAction(cmd *cobra.Command, args []string) error { | ||
| client, ctx, cancel, err := ncclient.New(cmd) |
There was a problem hiding this comment.
Exported functions should have godoc. In this case, XAction seems prints formatted strings to stdout so godoc should include the information about the format so that the caller can make sure it prints the expected outputs.
Maybe, exported functions should be independent from cobra and stdio.
| "github.com/containerd/containerd/cio" | ||
| ) | ||
|
|
||
| func PauseContainer(ctx context.Context, client *containerd.Client, id string) error { |
There was a problem hiding this comment.
It seems that we can put this under pkg dir because it doesn't have cobra dependency?
| // formatSlice is expected to be only used for `nerdctl OBJECT inspect` commands. | ||
| func formatSlice(cmd *cobra.Command, x []interface{}) error { | ||
| // FormatSlice is expected to be only used for `nerdctl OBJECT inspect` commands. | ||
| func FormatSlice(cmd *cobra.Command, x []interface{}) error { |
There was a problem hiding this comment.
If the purpose of the function is formatting rather than printing, I think it should receive io.Writer rather than *cobra.Command.
Probably we can prioritize bugfix PRs which usually happens in |
|
Sorry, I have to admit that I'm unable to review/carry this amount of PR 🙇♂️
Yes, this should be done in a series of small PRs if we want to continue this.
The git diff has to be kept minimal for ease of reviewing and potential rebasing. Also, there shouldn't be the We also have to revisit whether we really have to split Then there might be no good reason to split @Zheaoli |
I'm sorry for this huge PR, very sorry. It's my bad, the effort scope is beyond my think when I start this process. I will close this PR first, and I will make a refactor proposal to design the refactor step. Sorry again for this damn huge PR... |
|
Not "damn", don't blame your self ❤️ |
Fix #1631
First, I'm sorry that I make this PR too large to review. I have to make a one-shot PR if I want to re-structured the directory because the code in the
cmd/nerdctlhas been mixed,In this PR, I have made four things below
cmd/nerdctlinto subdirectory which the subcommand has organizedcmd/nerdctl/utilscmd/nerdct/completionSigned-off-by: Zheao.Li me@manjusaka.me