Skip to content

client/container_exec: Separate structs for Start and Attach#51289

Merged
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:client-container-exec2
Oct 25, 2025
Merged

client/container_exec: Separate structs for Start and Attach#51289
thaJeztah merged 1 commit intomoby:masterfrom
vvoland:client-container-exec2

Conversation

@vvoland
Copy link
Copy Markdown
Contributor

@vvoland vvoland commented Oct 24, 2025

@vvoland vvoland added this to the 29.0.0 milestone Oct 24, 2025
@vvoland vvoland self-assigned this Oct 24, 2025
@vvoland vvoland added the kind/refactor PR's that refactor, or clean-up code label Oct 24, 2025
Comment thread client/container_exec.go
Comment thread client/container_exec.go Outdated
Comment on lines +92 to +93
// ExecStart will first check if it's detached
Detach bool
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.

So for ExecAttach - does it make sense to have a Detach option?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nope 😅

Comment thread client/container_exec.go Outdated
Comment on lines +96 to +97
// Terminal size [height, width], unused if Tty == false
ConsoleSize *[2]uint `json:",omitempty"`
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.

We could make this explicit With, Height (could be a struct);

type ConsoleSize struct { Width, Height uint}

Could be either a pointer, or just consider the zero-value( 0, 0) being "not set" when we convert it to the API request, WDYT?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah good idea.

Also thinking if that struct could be combined with the TTY field itself (as the Console size doesnt make sense without TTY).

But:

type TTYConsole struct {
    Enabled bool
    Size ConsoleSize
}

Is not ideal because you could still pass Enabled=false so we don't gain much.

And:

type TTYConsole struct {
    Size ConsoleSize
}

Would be confusing because the struct being non-nil would be equivalent to the current Tty=true and that would be easy to do "accidentaly".

Comment thread client/container_exec.go Outdated
@vvoland vvoland force-pushed the client-container-exec2 branch from 397205c to 4aac139 Compare October 25, 2025 10:23
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

Comment thread client/container_exec.go
ConsoleSize *[2]uint `json:",omitempty"`
TTY bool
// Terminal size [height, width], unused if TTY == false
ConsoleSize ConsoleSize `json:",omitzero"`
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.

Nit: we can remove the json: label, because client options are never expected to be marshalled to JSON.

Fine for a follow-up though; there may be more.

Comment thread client/container_exec.go
Comment on lines +101 to +102
// Terminal size [height, width], unused if TTY == false
ConsoleSize ConsoleSize `json:",omitzero"`
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.

Same for this one

Comment thread client/container_exec.go
Comment on lines 84 to +86
func (cli *Client) ExecStart(ctx context.Context, execID string, options ExecStartOptions) (ExecStartResult, error) {
req := container.ExecStartRequest{
Detach: options.Detach,
Tty: options.Tty,
ConsoleSize: options.ConsoleSize,
Detach: options.Detach,
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.

For a follow-up, I'm considering;

  • Perhaps we should ditch ExecAttach altogether, and just have ExecStart (with options to attach)
  • Change Detach to Attach, so that ExecStart defaults to just "starting", but optionally allows to attach.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we should just ditch ExecAttach in favor of ExecStart.

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.

Yup; agreed; added it to the list here;

@thaJeztah thaJeztah merged commit bc2d0b4 into moby:master Oct 25, 2025
344 of 347 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dependencies kind/refactor PR's that refactor, or clean-up code module/client

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants