client: refactor Events, Info, RegistryLogin

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Austin Vazquez
2025-10-20 15:11:53 -05:00
committed by Sebastiaan van Stijn
parent c438b3fbbf
commit e46058cbae
32 changed files with 181 additions and 77 deletions

View File

@@ -985,8 +985,9 @@ func (d *Daemon) queryRootDir() (string, error) {
func (d *Daemon) Info(t testing.TB) system.Info {
t.Helper()
c := d.NewClientT(t)
info, err := c.Info(context.Background())
result, err := c.Info(context.Background(), client.InfoOptions{})
assert.NilError(t, err)
info := result.Info
assert.NilError(t, c.Close())
return info
}

View File

@@ -162,8 +162,9 @@ func (d *Daemon) SwarmLeave(ctx context.Context, t testing.TB, force bool) error
func (d *Daemon) SwarmInfo(ctx context.Context, t testing.TB) swarm.Info {
t.Helper()
cli := d.NewClientT(t)
info, err := cli.Info(ctx)
result, err := cli.Info(ctx, client.InfoOptions{})
assert.NilError(t, err, "get swarm info")
info := result.Info
return info.Swarm
}

View File

@@ -46,10 +46,11 @@ func New(ctx context.Context) (*Execution, error) {
// FromClient creates a new Execution environment from the passed in client
func FromClient(ctx context.Context, c *client.Client) (*Execution, error) {
info, err := c.Info(ctx)
result, err := c.Info(ctx, client.InfoOptions{})
if err != nil {
return nil, errors.Wrapf(err, "failed to get info from daemon")
}
info := result.Info
v, err := c.ServerVersion(context.Background())
if err != nil {
return nil, errors.Wrapf(err, "failed to get version info from daemon")

View File

@@ -33,14 +33,15 @@ func NewAPIClient(t testing.TB, ops ...client.Opt) client.APIClient {
}
// DaemonTime provides the current time on the daemon host
func DaemonTime(ctx context.Context, t testing.TB, client client.APIClient, testEnv *environment.Execution) time.Time {
func DaemonTime(ctx context.Context, t testing.TB, apiClient client.APIClient, testEnv *environment.Execution) time.Time {
t.Helper()
if testEnv.IsLocalDaemon() {
return time.Now()
}
info, err := client.Info(ctx)
result, err := apiClient.Info(ctx, client.InfoOptions{})
assert.NilError(t, err)
info := result.Info
dt, err := time.Parse(time.RFC3339Nano, info.SystemTime)
assert.NilError(t, err, "invalid time format in GET /info response")