Signed-off-by: Daniel Nephin <dnephin@docker.com>
| ... | ... |
@@ -18,7 +18,7 @@ type execBackend interface {
|
| 18 | 18 |
ContainerExecCreate(name string, config *types.ExecConfig) (string, error) |
| 19 | 19 |
ContainerExecInspect(id string) (*backend.ExecInspect, error) |
| 20 | 20 |
ContainerExecResize(name string, height, width int) error |
| 21 |
- ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error |
|
| 21 |
+ ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) error |
|
| 22 | 22 |
ExecExists(name string) (bool, error) |
| 23 | 23 |
} |
| 24 | 24 |
|
| ... | ... |
@@ -2,6 +2,7 @@ package swarm |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 |
+ "io" |
|
| 5 | 6 |
"net/http" |
| 6 | 7 |
|
| 7 | 8 |
"github.com/docker/docker/api/server/httputils" |
| ... | ... |
@@ -12,7 +13,7 @@ import ( |
| 12 | 12 |
|
| 13 | 13 |
// swarmLogs takes an http response, request, and selector, and writes the logs |
| 14 | 14 |
// specified by the selector to the response |
| 15 |
-func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, selector *backend.LogSelector) error {
|
|
| 15 |
+func (sr *swarmRouter) swarmLogs(ctx context.Context, w io.Writer, r *http.Request, selector *backend.LogSelector) error {
|
|
| 16 | 16 |
// Args are validated before the stream starts because when it starts we're |
| 17 | 17 |
// sending HTTP 200 by writing an empty chunk of data to tell the client that |
| 18 | 18 |
// daemon is going to stream. By sending this initial HTTP 200 we can't report |
| ... | ... |
@@ -110,7 +110,7 @@ func GetWithStatusError(address string) (resp *http.Response, err error) {
|
| 110 | 110 |
// - an io.Reader for the response body |
| 111 | 111 |
// - an error value which will be non-nil either when something goes wrong while |
| 112 | 112 |
// reading bytes from r or when the detected content-type is not acceptable. |
| 113 |
-func inspectResponse(ct string, r io.ReadCloser, clen int64) (string, io.ReadCloser, error) {
|
|
| 113 |
+func inspectResponse(ct string, r io.Reader, clen int64) (string, io.ReadCloser, error) {
|
|
| 114 | 114 |
plen := clen |
| 115 | 115 |
if plen <= 0 || plen > maxPreambleLength {
|
| 116 | 116 |
plen = maxPreambleLength |
| ... | ... |
@@ -119,10 +119,10 @@ func inspectResponse(ct string, r io.ReadCloser, clen int64) (string, io.ReadClo |
| 119 | 119 |
preamble := make([]byte, plen, plen) |
| 120 | 120 |
rlen, err := r.Read(preamble) |
| 121 | 121 |
if rlen == 0 {
|
| 122 |
- return ct, r, errors.New("empty response")
|
|
| 122 |
+ return ct, ioutil.NopCloser(r), errors.New("empty response")
|
|
| 123 | 123 |
} |
| 124 | 124 |
if err != nil && err != io.EOF {
|
| 125 |
- return ct, r, err |
|
| 125 |
+ return ct, ioutil.NopCloser(r), err |
|
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 | 128 |
preambleR := bytes.NewReader(preamble[:rlen]) |
| ... | ... |
@@ -7,7 +7,7 @@ import ( |
| 7 | 7 |
"github.com/docker/distribution/reference" |
| 8 | 8 |
"github.com/docker/docker/api/types" |
| 9 | 9 |
"github.com/docker/docker/api/types/swarm" |
| 10 |
- "github.com/opencontainers/go-digest" |
|
| 10 |
+ digest "github.com/opencontainers/go-digest" |
|
| 11 | 11 |
"github.com/pkg/errors" |
| 12 | 12 |
"golang.org/x/net/context" |
| 13 | 13 |
) |
| ... | ... |
@@ -85,7 +85,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, |
| 85 | 85 |
return response, err |
| 86 | 86 |
} |
| 87 | 87 |
|
| 88 |
-func imageDigestAndPlatforms(ctx context.Context, cli *Client, image, encodedAuth string) (string, []swarm.Platform, error) {
|
|
| 88 |
+func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
|
| 89 | 89 |
distributionInspect, err := cli.DistributionInspect(ctx, image, encodedAuth) |
| 90 | 90 |
imageWithDigest := image |
| 91 | 91 |
var platforms []swarm.Platform |
| ... | ... |
@@ -539,7 +539,7 @@ func initRouter(opts routerOptions) {
|
| 539 | 539 |
} |
| 540 | 540 |
|
| 541 | 541 |
// TODO: remove this from cli and return the authzMiddleware |
| 542 |
-func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config, pluginStore *plugin.Store) error {
|
|
| 542 |
+func (cli *DaemonCli) initMiddlewares(s *apiserver.Server, cfg *apiserver.Config, pluginStore plugingetter.PluginGetter) error {
|
|
| 543 | 543 |
v := cfg.Version |
| 544 | 544 |
|
| 545 | 545 |
exp := middleware.NewExperimentalMiddleware(cli.Config.Experimental) |
| ... | ... |
@@ -655,8 +655,12 @@ func (container *Container) BuildEndpointInfo(n libnetwork.Network, ep libnetwor |
| 655 | 655 |
return nil |
| 656 | 656 |
} |
| 657 | 657 |
|
| 658 |
+type named interface {
|
|
| 659 |
+ Name() string |
|
| 660 |
+} |
|
| 661 |
+ |
|
| 658 | 662 |
// UpdateJoinInfo updates network settings when container joins network n with endpoint ep. |
| 659 |
-func (container *Container) UpdateJoinInfo(n libnetwork.Network, ep libnetwork.Endpoint) error {
|
|
| 663 |
+func (container *Container) UpdateJoinInfo(n named, ep libnetwork.Endpoint) error {
|
|
| 660 | 664 |
if err := container.buildPortMapInfo(ep); err != nil {
|
| 661 | 665 |
return err |
| 662 | 666 |
} |
| ... | ... |
@@ -684,7 +688,7 @@ func (container *Container) UpdateSandboxNetworkSettings(sb libnetwork.Sandbox) |
| 684 | 684 |
} |
| 685 | 685 |
|
| 686 | 686 |
// BuildJoinOptions builds endpoint Join options from a given network. |
| 687 |
-func (container *Container) BuildJoinOptions(n libnetwork.Network) ([]libnetwork.EndpointOption, error) {
|
|
| 687 |
+func (container *Container) BuildJoinOptions(n named) ([]libnetwork.EndpointOption, error) {
|
|
| 688 | 688 |
var joinOptions []libnetwork.EndpointOption |
| 689 | 689 |
if epConfig, ok := container.NetworkSettings.Networks[n.Name()]; ok {
|
| 690 | 690 |
for _, str := range epConfig.Links {
|
| ... | ... |
@@ -142,7 +142,7 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str |
| 142 | 142 |
// ContainerExecStart starts a previously set up exec instance. The |
| 143 | 143 |
// std streams are set up. |
| 144 | 144 |
// If ctx is cancelled, the process is terminated. |
| 145 |
-func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) (err error) {
|
|
| 145 |
+func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.Reader, stdout io.Writer, stderr io.Writer) (err error) {
|
|
| 146 | 146 |
var ( |
| 147 | 147 |
cStdin io.ReadCloser |
| 148 | 148 |
cStdout, cStderr io.Writer |
| ... | ... |
@@ -28,7 +28,7 @@ import ( |
| 28 | 28 |
"github.com/docker/docker/pkg/system" |
| 29 | 29 |
refstore "github.com/docker/docker/reference" |
| 30 | 30 |
"github.com/docker/docker/registry" |
| 31 |
- "github.com/opencontainers/go-digest" |
|
| 31 |
+ digest "github.com/opencontainers/go-digest" |
|
| 32 | 32 |
"github.com/pkg/errors" |
| 33 | 33 |
"github.com/sirupsen/logrus" |
| 34 | 34 |
"golang.org/x/net/context" |
| ... | ... |
@@ -435,7 +435,7 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat |
| 435 | 435 |
return true, nil |
| 436 | 436 |
} |
| 437 | 437 |
|
| 438 |
-func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Named, unverifiedManifest *schema1.SignedManifest) (id digest.Digest, manifestDigest digest.Digest, err error) {
|
|
| 438 |
+func (p *v2Puller) pullSchema1(ctx context.Context, ref reference.Reference, unverifiedManifest *schema1.SignedManifest) (id digest.Digest, manifestDigest digest.Digest, err error) {
|
|
| 439 | 439 |
var verifiedManifest *schema1.Manifest |
| 440 | 440 |
verifiedManifest, err = verifySchema1Manifest(unverifiedManifest, ref) |
| 441 | 441 |
if err != nil {
|
| ... | ... |
@@ -838,7 +838,7 @@ func allowV1Fallback(err error) error {
|
| 838 | 838 |
return err |
| 839 | 839 |
} |
| 840 | 840 |
|
| 841 |
-func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference.Named) (m *schema1.Manifest, err error) {
|
|
| 841 |
+func verifySchema1Manifest(signedManifest *schema1.SignedManifest, ref reference.Reference) (m *schema1.Manifest, err error) {
|
|
| 842 | 842 |
// If pull by digest, then verify the manifest digest. NOTE: It is |
| 843 | 843 |
// important to do this first, before any other content validation. If the |
| 844 | 844 |
// digest cannot be verified, don't even bother with those other things. |
| ... | ... |
@@ -24,7 +24,7 @@ import ( |
| 24 | 24 |
"github.com/docker/docker/pkg/progress" |
| 25 | 25 |
"github.com/docker/docker/pkg/stringid" |
| 26 | 26 |
"github.com/docker/docker/registry" |
| 27 |
- "github.com/opencontainers/go-digest" |
|
| 27 |
+ digest "github.com/opencontainers/go-digest" |
|
| 28 | 28 |
"github.com/sirupsen/logrus" |
| 29 | 29 |
) |
| 30 | 30 |
|
| ... | ... |
@@ -651,6 +651,7 @@ func (bla byLikeness) Swap(i, j int) {
|
| 651 | 651 |
} |
| 652 | 652 |
func (bla byLikeness) Len() int { return len(bla.arr) }
|
| 653 | 653 |
|
| 654 |
+// nolint: interfacer |
|
| 654 | 655 |
func sortV2MetadataByLikenessAndAge(repoInfo reference.Named, hmacKey []byte, marr []metadata.V2Metadata) {
|
| 655 | 656 |
// reverse the metadata array to shift the newest entries to the beginning |
| 656 | 657 |
for i := 0; i < len(marr)/2; i++ {
|
| ... | ... |
@@ -23,7 +23,7 @@ import ( |
| 23 | 23 |
"github.com/docker/docker/pkg/stringid" |
| 24 | 24 |
"github.com/docker/docker/pkg/symlink" |
| 25 | 25 |
"github.com/docker/docker/pkg/system" |
| 26 |
- "github.com/opencontainers/go-digest" |
|
| 26 |
+ digest "github.com/opencontainers/go-digest" |
|
| 27 | 27 |
"github.com/sirupsen/logrus" |
| 28 | 28 |
) |
| 29 | 29 |
|
| ... | ... |
@@ -212,15 +212,12 @@ func (l *tarexporter) loadLayer(filename string, rootFS image.RootFS, id string, |
| 212 | 212 |
return l.ls.Register(inflatedLayerData, rootFS.ChainID(), platform) |
| 213 | 213 |
} |
| 214 | 214 |
|
| 215 |
-func (l *tarexporter) setLoadedTag(ref reference.NamedTagged, imgID digest.Digest, outStream io.Writer) error {
|
|
| 215 |
+func (l *tarexporter) setLoadedTag(ref reference.Named, imgID digest.Digest, outStream io.Writer) error {
|
|
| 216 | 216 |
if prevID, err := l.rs.Get(ref); err == nil && prevID != imgID {
|
| 217 | 217 |
fmt.Fprintf(outStream, "The image %s already exists, renaming the old one with ID %s to empty string\n", reference.FamiliarString(ref), string(prevID)) // todo: this message is wrong in case of multiple tags |
| 218 | 218 |
} |
| 219 | 219 |
|
| 220 |
- if err := l.rs.AddTag(ref, imgID, true); err != nil {
|
|
| 221 |
- return err |
|
| 222 |
- } |
|
| 223 |
- return nil |
|
| 220 |
+ return l.rs.AddTag(ref, imgID, true) |
|
| 224 | 221 |
} |
| 225 | 222 |
|
| 226 | 223 |
func (l *tarexporter) legacyLoad(tmpDir string, outStream io.Writer, progressOutput progress.Output) error {
|
| ... | ... |
@@ -247,6 +247,7 @@ func (err PingResponseError) Error() string {
|
| 247 | 247 |
// challenge manager for the supported authentication types and |
| 248 | 248 |
// whether v2 was confirmed by the response. If a response is received but |
| 249 | 249 |
// cannot be interpreted a PingResponseError will be returned. |
| 250 |
+// nolint: interfacer |
|
| 250 | 251 |
func PingV2Registry(endpoint *url.URL, transport http.RoundTripper) (challenge.Manager, bool, error) {
|
| 251 | 252 |
var ( |
| 252 | 253 |
foundV2 = false |