Skip to content

Refactor the (container) run command flagging process #1954

Open
@Laitr0n

Description

@Laitr0n

What is the problem you're trying to solve

I'm currently refactoring the process of handling flags for the (container) run command. However, it is very complex and I would like to discuss it further.

Describe the solution you'd like

First, we should split the createContainer function into smaller functions. As seen in the code at https://github.com/containerd/nerdctl/blob/1bbfe6930c56f3d69fe05b300f7c2817b828c024/cmd/nerdctl/container_run.go#L408-753
We will divide it into three tasks:

  1. Move all helper functions to pkg/cmd/*util;
  2. Add a function processInternalLabels;
  3. Move all flag retrieval to processCreateContainerFlags.

Next, we will move createContainer to pkg/cmd/containerutil.

Finally, we will create ContainerRunOptions in pkg/api/types/container_types.go and Run in pkg/cmd/container/run.go.

Due to the complexity of the createContainer function and its numerous helper functions, it will take more time to handle.

@AkihiroSuda @djdongjin @Zheaoli , WDYT? Can you share your ideas?

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions