Skip to content

[client] Remove duplicate NewClient functions#34899

Merged
thaJeztah merged 4 commits intomoby:masterfrom
dnephin:fix-duplicate-new-client
Feb 21, 2018
Merged

[client] Remove duplicate NewClient functions#34899
thaJeztah merged 4 commits intomoby:masterfrom
dnephin:fix-duplicate-new-client

Conversation

@dnephin
Copy link
Member

@dnephin dnephin commented Sep 19, 2017

Improve docstrings in client package
Remove some unnecessary code in client
Add more ops to client
Remove duplicate ways of getting an APIClient for integration testing
Remove some deprecated code

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐮

@thaJeztah
Copy link
Member

CI is failing 😢

@thaJeztah thaJeztah added the status/failing-ci Indicates that the PR in its current state fails the test suite label Sep 20, 2017
@dnephin dnephin force-pushed the fix-duplicate-new-client branch from 69e0266 to ccf5103 Compare September 20, 2017 18:32
@dnephin dnephin removed the status/failing-ci Indicates that the PR in its current state fails the test suite label Sep 20, 2017
@dnephin dnephin force-pushed the fix-duplicate-new-client branch 3 times, most recently from b2990da to 818393f Compare September 20, 2017 22:15
@dnephin dnephin force-pushed the fix-duplicate-new-client branch 3 times, most recently from 2ba31f4 to a65413e Compare September 22, 2017 18:15
@GordonTheTurtle GordonTheTurtle added the dco/no Automatically set by a bot when one of the commits lacks proper signature label Sep 22, 2017
@dnephin dnephin force-pushed the fix-duplicate-new-client branch from d1fe81f to 7c09dc5 Compare September 22, 2017 21:04
@GordonTheTurtle GordonTheTurtle removed the dco/no Automatically set by a bot when one of the commits lacks proper signature label Sep 22, 2017
@moby moby deleted a comment from GordonTheTurtle Sep 25, 2017
@dnephin dnephin force-pushed the fix-duplicate-new-client branch from 3d4ae0e to ca1b31e Compare February 16, 2018 20:15
client/client.go Outdated
Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this because NewClientWithOpts always sets a default c.client, so there is no way for this branch to ever be hit. This is related to the fix from #36270. Before that fix we always set a new defaultHTTPClient, but now we never set a client because c.client is already set. cc @dperny

@dnephin dnephin changed the title [client] Remove duplicate ways of getting a client in integration/request [client] Remove duplicate NewClient functions Feb 16, 2018
@dnephin dnephin requested a review from tianon as a code owner February 16, 2018 22:29
@codecov
Copy link

codecov bot commented Feb 16, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@ee9abc2). Click here to learn what that means.
The diff coverage is 19.23%.

@@            Coverage Diff            @@
##             master   #34899   +/-   ##
=========================================
  Coverage          ?   34.31%           
=========================================
  Files             ?      609           
  Lines             ?    45308           
  Branches          ?        0           
=========================================
  Hits              ?    15549           
  Misses            ?    27759           
  Partials          ?     2000

Copy link
Member Author

Choose a reason for hiding this comment

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

I removed this because it was causing DockerSuite.TestBuildWithSession to fail.

I don't think we should be setting an explicit API version here. The client package uses this version to disable some features, so setting it to an old version makes it impossible to test those features.

I believe the pinned version of the cli we are using can properly negotiate the API version.

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Still LGTM 🦁

Copy link
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.

Left one question (related to the gotestyourself package), also, can you squash ca1b31e (Remove duplicate calls for getting an APIClient) and 78c097c (revert changes to exec resize)?

Copy link
Member

Choose a reason for hiding this comment

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

I noticed env.Patch() and env.PatchAll() have a difference in behaviour; where env.Patch() actually patches the current environment variables, env.PatchAll() is overriding the current environment (i.e., it removes all existing environment variables); https://github.com/gotestyourself/gotestyourself/blob/511344eed30e4384f010579a593dfb442033a692/env/env.go#L40-L45

I wonder if that function needs to have a different name, or if the os.ClearEnv() should be removed

Copy link
Member Author

@dnephin dnephin Feb 19, 2018

Choose a reason for hiding this comment

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

Yes, that is exactly how they are documented: https://godoc.org/github.com/gotestyourself/gotestyourself/env

Patch changes the value of an environment variable

PatchAll sets the environment to env


I wonder if that function needs to have a different name,

All -> "the whole of", complete, entire

I think the name should imply that it replaces everything. What did you expect PatchAll to do?

If it were just a "multi set" version of Patch it would be called something like PatchMany, or MatchMulti, but I think there is little value in such a call, so would not be in favor of adding it.

Copy link
Member

Choose a reason for hiding this comment

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

The “Patch” part lead me to believe I’d be modifying just what I sent, but keep other values as-is; even more because the “Patch” does so for a single var.

idk, “SetEnv()” / “Override()” would perhaps perhaps be closed to that it does

Copy link
Member Author

Choose a reason for hiding this comment

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

I think SetEnv would be too close to https://golang.org/pkg/os/#Setenv, and would be confusing because it's not just SetEnv, it also returns a cleanup function. Override doesn't really have any specific meaning in this context.

Patch here, in the context of testing, refers to Monkey Patching, not the more general patch as in "partial change".

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps that's where my confusion was; anyway, it's not really related to this PR 😅

Copy link
Member

Choose a reason for hiding this comment

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

How did this test pass previously on Windows?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are some big problems with this test. I think it's actually failing on windows, but all ignores are being ignored because it's ignoring all errors except EOF:

_, rc, err := request.Post(fmt.Sprintf("/exec/%s/resize?h=24&w=80", execID), request.ContentType("text/plain"))
// It's probably a panic of the daemon if io.ErrUnexpectedEOF is returned.
if err == io.ErrUnexpectedEOF {
return fmt.Errorf("The daemon might have crashed.")
}
if err == nil {
rc.Close()
}
// We only interested in the io.ErrUnexpectedEOF error, so we return nil otherwise.
return nil

I tried to fix it, but it was failing, so I decided to leave it for another time.

Copy link
Member Author

Choose a reason for hiding this comment

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

Opened #36354 for this issue

Copy link
Member

Choose a reason for hiding this comment

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

Ah, it's re-added here 😅

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Use client instead of helpers for TLS in integration test

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Remove request.SockRequest
Remove request.SockRequestHijack
Remove request.SockRequestRaw()
Remove deprecated ParseHost
Deprecate and unexport more helpers

Signed-off-by: Daniel Nephin <dnephin@docker.com>
Use the default version because it is used by the client package

Signed-off-by: Daniel Nephin <dnephin@docker.com>
@dnephin dnephin force-pushed the fix-duplicate-new-client branch from 7ad8dff to e73d742 Compare February 20, 2018 22:27
@dnephin
Copy link
Member Author

dnephin commented Feb 20, 2018

Squashed those 2 commits and fixed a test that was failing

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

LGTM 🐸

Copy link
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!

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.

6 participants