Skip to content

[Refactor] Refactor the load command flagging process#1820

Merged
AkihiroSuda merged 1 commit into
containerd:mainfrom
Zheaoli:manjusaka/refactor-load
Jan 9, 2023
Merged

[Refactor] Refactor the load command flagging process#1820
AkihiroSuda merged 1 commit into
containerd:mainfrom
Zheaoli:manjusaka/refactor-load

Conversation

@Zheaoli
Copy link
Copy Markdown
Member

@Zheaoli Zheaoli commented Jan 9, 2023

Checklist:

  • Create a file in pkg/api/types/${cmd}_types.go, and define the CommandOption for this command
  • Create some file in pkg/cmd/${cmd}, and move the command entry point in real into this package

Signed-off-by: Zheao.Li me@manjusaka.me

@Zheaoli Zheaoli marked this pull request as draft January 9, 2023 03:58
Signed-off-by: Zheao.Li <me@manjusaka.me>
@Zheaoli Zheaoli force-pushed the manjusaka/refactor-load branch from a903585 to efaf3d6 Compare January 9, 2023 04:00
@Zheaoli Zheaoli marked this pull request as ready for review January 9, 2023 05:16
@Zheaoli Zheaoli added this to the v1.2.0 milestone Jan 9, 2023
Comment thread cmd/nerdctl/load.go

return loadImage(decompressor, cmd, globalOptions, platMC, false)
return types.LoadCommandOptions{
GOptions: *globalOptions,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no change required here, but we might gradually change the pointer usage of global option to non-pointer to avoid unintented shared memory among goroutines (#1795 (comment)) and also be consistent with other command option usages.

  1. Those global options in function signatures should be fine, as they should be gradually replaced by individual command options (with global option being a field).
  2. processRootCmdFlags should be changed to return a struct not a struct pointer. Similarly, SubCommandOptions should hold a global option struct (as in LoadCommandOptions) not a struct pointer.

I guess the original intent of using global option as a pointer is to avoid unnecessary copies, but I think it should be fine as those option structs are quite small, and also pointers use heap allocation which means more GC work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will make a split PR to update it

Copy link
Copy Markdown
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@AkihiroSuda AkihiroSuda merged commit 7a6c73b into containerd:main Jan 9, 2023
@Zheaoli Zheaoli deleted the manjusaka/refactor-load branch January 11, 2023 03:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants