Skip to content

Conversation

@mdelapenya
Copy link
Member

@mdelapenya mdelapenya commented Oct 31, 2025

Summary

  • Add String() method to all wait strategy types for human-readable descriptions
  • Update container lifecycle logging to display wait strategy descriptions
  • Improve user experience by showing clear wait conditions instead of raw struct output

Changes

This PR adds String() methods to all wait strategy implementations:

  • HTTPStrategy: Shows HTTP/HTTPS method, port, and path
  • HealthStrategy: Shows 'container to become healthy'
  • LogStrategy: Shows log message/pattern with occurrence count
  • HostPortStrategy: Shows port and check type (listening/mapped/accessible)
  • FileStrategy: Shows file path and matcher condition
  • ExecStrategy: Shows command being executed
  • ExitStrategy: Shows 'container to exit'
  • waitForSQL: Shows database driver, port, and custom query
  • MultiStrategy: Shows all nested strategies
  • NopStrategy: Shows 'custom wait condition'
  • TLSStrategy: Shows certificate files being waited for

Example Output

Before:
Waiting for container to be ready containerID=0fc8e4de4995 image=nginx:alpine Waiting for: &{timeout: deadline:0x140001c7190 Strategies:[0x1400032e1d0]}

After:
Waiting for container to be ready containerID=0fc8e4de4995 image=nginx:alpine strategy='HTTP GET request on port 8080 path /health'

Test plan

  • All existing tests pass
  • Build completes successfully
  • Each wait strategy returns appropriate human-readable string

🤖 Generated with Claude Code

Add String() method to all wait strategy types to provide human-readable
descriptions that are displayed in container lifecycle logs. This improves
the user experience by showing clear wait conditions instead of raw struct
output.

Changes:
- Add String() method to HTTPStrategy, HealthStrategy, LogStrategy,
  HostPortStrategy, FileStrategy, ExecStrategy, ExitStrategy,
  waitForSQL, MultiStrategy, NopStrategy, and TLSStrategy
- Update lifecycle logging to use strategy String() output
- Each strategy provides contextual information (ports, paths, conditions)

Example output changes:
Before: Waiting for: &{timeout:<nil> deadline:0x140001c7190 Strategies:[0x1400032e1d0]}
After: Waiting for container to be ready strategy="HTTP GET request on port 8080 path /health"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Copilot AI review requested due to automatic review settings October 31, 2025 16:39
@mdelapenya mdelapenya self-assigned this Oct 31, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements the String() method (fmt.Stringer interface) for all wait strategy types to provide human-readable descriptions. This enables better logging when containers are waiting to become ready.

  • Adds String() method to all wait strategy implementations (TLSStrategy, SQLStrategy, NopStrategy, LogStrategy, HTTPStrategy, HostPortStrategy, HealthStrategy, FileStrategy, ExitStrategy, ExecStrategy, MultiStrategy)
  • Updates the lifecycle hook to use the String() method for enhanced logging output
  • Each implementation provides contextual information about what the strategy is waiting for

Reviewed Changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
container/wait/tls.go Adds String() method returning description of TLS certificates being waited for
container/wait/sql.go Adds String() method showing SQL port, driver, and optional custom query
container/wait/nop.go Adds String() method returning generic "custom wait condition" description
container/wait/log.go Adds String() method showing log message/pattern and occurrence count
container/wait/http.go Adds String() method describing HTTP/HTTPS request details
container/wait/host_port.go Adds String() method explaining port listening behavior
container/wait/health.go Adds String() method for health check strategy
container/wait/file.go Adds String() method describing file existence and optional matching condition
container/wait/exit.go Adds String() method for exit strategy
container/wait/exec.go Adds String() method showing exec command being waited for
container/wait/all.go Adds String() method handling multi-strategy composition with proper aggregation
container/lifecycle.create.go Updates readiness hook to use String() method for improved logging
Comments suppressed due to low confidence (1)

container/wait/http.go:1

  • When Path is empty (the default), the output will show path \"\" which may be confusing. Consider adding a conditional check: if ws.Path == \"\", use "path /" or omit the path segment entirely.
package wait

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mdelapenya and others added 4 commits October 31, 2025 17:43
- Use switch statement instead of if-else chain in HostPortStrategy
- Quote path in HTTPStrategy output for clarity
- Use Port.Port() method instead of string cast for nat.Port

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Only show command name and argument count instead of full command with
arguments, which may contain passwords, tokens, or other credentials.

Example: "exec command \"mysql\" with 4 argument(s)" instead of
["mysql", "-u", "root", "-pSecretPass", "mydb"]

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mdelapenya mdelapenya requested a review from Copilot November 3, 2025 09:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mdelapenya and others added 2 commits November 3, 2025 11:04
Always include "all of:" prefix even when there's only one strategy
after filtering out nils, to make it clear that a MultiStrategy wrapper
is being used.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
Use "argument" (singular) when argCount is 1, and "arguments" (plural)
otherwise for grammatically correct output.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@mdelapenya mdelapenya requested a review from Copilot November 3, 2025 10:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mdelapenya mdelapenya merged commit c1a5f75 into docker:main Nov 3, 2025
17 checks passed
@mdelapenya mdelapenya deleted the wait-strategy-stringer branch November 4, 2025 11:51
mdelapenya added a commit to ndeloof/go-sdk that referenced this pull request Nov 6, 2025
* main:
  feat(wait): add human-readable String() methods to all wait strategies (docker#119)
  feat(image): display formatted pull progress on Windows terminals (docker#118)
  chore(release): add Go proxy refresh automation (docker#117)
  chore(release): bump module versions
  chore(release): prevent for pushing to personal forks (docker#115)
  chore(release): add pre-release checks to make the release process more consistent (docker#114)
  chore(volume): return pointer in FindByID (docker#105)
  fix(container): proper error message on empty container names (docker#113)
  fix(container): add to nil modifiers (docker#112)
  feat(container): add new functional options to add container config, hostConfig and endpointSettings (docker#111)
  feat(container): configure pull handler at container creation (docker#110)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant