mirror of
https://github.com/clearlinux/docker.git
synced 2026-09-06 21:51:33 +00:00
Move context stuff to its own package
Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
+1
-2
@@ -4,10 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/cliconfig"
|
||||
"github.com/docker/docker/context"
|
||||
)
|
||||
|
||||
func (s *Server) postAuth(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
|
||||
@@ -8,15 +8,14 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"golang.org/x/net/websocket"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/signal"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
"github.com/docker/docker/runconfig"
|
||||
)
|
||||
|
||||
@@ -251,7 +250,7 @@ func (s *Server) postContainersKill(ctx context.Context, w http.ResponseWriter,
|
||||
// Return error that's not caused because the container is stopped.
|
||||
// Return error if the container is not running and the api is >= 1.20
|
||||
// to keep backwards compatibility.
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
if version.GreaterThanOrEqualTo("1.20") || !isStopped {
|
||||
return fmt.Errorf("Cannot kill container %s: %v", name, err)
|
||||
}
|
||||
@@ -392,7 +391,7 @@ func (s *Server) postContainersCreate(ctx context.Context, w http.ResponseWriter
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
adjustCPUShares := version.LessThan("1.19")
|
||||
|
||||
container, warnings, err := s.daemon.ContainerCreate(name, config, hostConfig, adjustCPUShares)
|
||||
|
||||
+1
-2
@@ -9,9 +9,8 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/context"
|
||||
)
|
||||
|
||||
// postContainersCopy is deprecated in favor of getContainersArchive.
|
||||
|
||||
@@ -8,17 +8,15 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/autogen/dockerversion"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/jsonmessage"
|
||||
"github.com/docker/docker/pkg/parsers/filters"
|
||||
"github.com/docker/docker/pkg/parsers/kernel"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
|
||||
@@ -33,7 +31,7 @@ func (s *Server) getVersion(ctx context.Context, w http.ResponseWriter, r *http.
|
||||
BuildTime: dockerversion.BUILDTIME,
|
||||
}
|
||||
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
|
||||
if version.GreaterThanOrEqualTo("1.19") {
|
||||
v.Experimental = utils.ExperimentalBuild()
|
||||
|
||||
+1
-2
@@ -7,10 +7,9 @@ import (
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/pkg/stdcopy"
|
||||
"github.com/docker/docker/runconfig"
|
||||
)
|
||||
|
||||
+3
-5
@@ -8,18 +8,16 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/builder"
|
||||
"github.com/docker/docker/cliconfig"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/graph"
|
||||
"github.com/docker/docker/pkg/ioutils"
|
||||
"github.com/docker/docker/pkg/parsers"
|
||||
"github.com/docker/docker/pkg/streamformatter"
|
||||
"github.com/docker/docker/pkg/ulimit"
|
||||
"github.com/docker/docker/pkg/version"
|
||||
"github.com/docker/docker/runconfig"
|
||||
"github.com/docker/docker/utils"
|
||||
)
|
||||
@@ -36,7 +34,7 @@ func (s *Server) postCommit(ctx context.Context, w http.ResponseWriter, r *http.
|
||||
cname := r.Form.Get("container")
|
||||
|
||||
pause := boolValue(r, "pause")
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
if r.FormValue("pause") == "" && version.GreaterThanOrEqualTo("1.13") {
|
||||
pause = true
|
||||
}
|
||||
@@ -283,7 +281,7 @@ func (s *Server) postBuild(ctx context.Context, w http.ResponseWriter, r *http.R
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
if boolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
|
||||
buildConfig.Remove = true
|
||||
} else if r.FormValue("rm") == "" && version.GreaterThanOrEqualTo("1.12") {
|
||||
|
||||
@@ -4,9 +4,7 @@ import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/docker/pkg/version"
|
||||
"github.com/docker/docker/context"
|
||||
)
|
||||
|
||||
// getContainersByName inspects containers configuration and serializes it as json.
|
||||
@@ -18,7 +16,7 @@ func (s *Server) getContainersByName(ctx context.Context, w http.ResponseWriter,
|
||||
var json interface{}
|
||||
var err error
|
||||
|
||||
version, _ := ctx.Value("api-version").(version.Version)
|
||||
version := ctx.Version()
|
||||
|
||||
switch {
|
||||
case version.LessThan("1.20"):
|
||||
|
||||
@@ -12,11 +12,11 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/api"
|
||||
"github.com/docker/docker/autogen/dockerversion"
|
||||
"github.com/docker/docker/context"
|
||||
"github.com/docker/docker/daemon"
|
||||
"github.com/docker/docker/pkg/sockets"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
@@ -261,14 +261,14 @@ func makeHTTPHandler(logging bool, localMethod string, localRoute string, handle
|
||||
// as 'args' on the function call.
|
||||
|
||||
reqID := stringid.TruncateID(stringid.GenerateNonCryptoID())
|
||||
api_version := version.Version(mux.Vars(r)["version"])
|
||||
if api_version == "" {
|
||||
api_version = api.Version
|
||||
apiVersion := version.Version(mux.Vars(r)["version"])
|
||||
if apiVersion == "" {
|
||||
apiVersion = api.Version
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
ctx = context.WithValue(ctx, "docker-request-id", reqID)
|
||||
ctx = context.WithValue(ctx, "api-version", api_version)
|
||||
ctx = context.WithValue(ctx, context.RequestID, reqID)
|
||||
ctx = context.WithValue(ctx, context.APIVersion, apiVersion)
|
||||
|
||||
// log the request
|
||||
logrus.Debugf("Calling %s %s", localMethod, localRoute)
|
||||
@@ -294,11 +294,11 @@ func makeHTTPHandler(logging bool, localMethod string, localRoute string, handle
|
||||
writeCorsHeaders(w, r, corsHeaders)
|
||||
}
|
||||
|
||||
if api_version.GreaterThan(api.Version) {
|
||||
http.Error(w, fmt.Errorf("client is newer than server (client API version: %s, server API version: %s)", api_version, api.Version).Error(), http.StatusBadRequest)
|
||||
if apiVersion.GreaterThan(api.Version) {
|
||||
http.Error(w, fmt.Errorf("client is newer than server (client API version: %s, server API version: %s)", apiVersion, api.Version).Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if api_version.LessThan(api.MinVersion) {
|
||||
if apiVersion.LessThan(api.MinVersion) {
|
||||
http.Error(w, fmt.Errorf("client is too old, minimum supported API version is %s, please upgrade your client to a newer version", api.MinVersion).Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,9 +4,8 @@ import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/context"
|
||||
)
|
||||
|
||||
func (s *Server) getVolumesList(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||
|
||||
Reference in New Issue
Block a user