Merge pull request #13160 from runcom/remove-api-codepath-less-than-1-12
Remove API codepaths < 1.12
This commit is contained in:
commit
f35038dfba
|
@ -353,28 +353,7 @@ func (s *Server) getImagesJSON(version version.Version, w http.ResponseWriter, r
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if version.GreaterThanOrEqualTo("1.7") {
|
return writeJSON(w, http.StatusOK, images)
|
||||||
return writeJSON(w, http.StatusOK, images)
|
|
||||||
}
|
|
||||||
|
|
||||||
legacyImages := []types.LegacyImage{}
|
|
||||||
|
|
||||||
for _, image := range images {
|
|
||||||
for _, repoTag := range image.RepoTags {
|
|
||||||
repo, tag := parsers.ParseRepositoryTag(repoTag)
|
|
||||||
legacyImage := types.LegacyImage{
|
|
||||||
Repository: repo,
|
|
||||||
Tag: tag,
|
|
||||||
ID: image.ID,
|
|
||||||
Created: image.Created,
|
|
||||||
Size: image.Size,
|
|
||||||
VirtualSize: image.VirtualSize,
|
|
||||||
}
|
|
||||||
legacyImages = append(legacyImages, legacyImage)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return writeJSON(w, http.StatusOK, legacyImages)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getInfo(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (s *Server) getInfo(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
|
@ -520,10 +499,6 @@ func (s *Server) getContainersChanges(version version.Version, w http.ResponseWr
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) getContainersTop(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (s *Server) getContainersTop(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if version.LessThan("1.4") {
|
|
||||||
return fmt.Errorf("top was improved a lot since 1.3, Please upgrade your docker client.")
|
|
||||||
}
|
|
||||||
|
|
||||||
if vars == nil {
|
if vars == nil {
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
|
@ -706,14 +681,11 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
useJSON = version.GreaterThan("1.0")
|
output = ioutils.NewWriteFlusher(w)
|
||||||
output = ioutils.NewWriteFlusher(w)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if useJSON {
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
}
|
|
||||||
|
|
||||||
if image != "" { //pull
|
if image != "" { //pull
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
|
@ -727,15 +699,12 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter
|
||||||
}
|
}
|
||||||
|
|
||||||
imagePullConfig := &graph.ImagePullConfig{
|
imagePullConfig := &graph.ImagePullConfig{
|
||||||
Parallel: version.GreaterThan("1.3"),
|
|
||||||
MetaHeaders: metaHeaders,
|
MetaHeaders: metaHeaders,
|
||||||
AuthConfig: authConfig,
|
AuthConfig: authConfig,
|
||||||
OutStream: output,
|
OutStream: output,
|
||||||
Json: useJSON,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
err = s.daemon.Repositories().Pull(image, tag, imagePullConfig)
|
err = s.daemon.Repositories().Pull(image, tag, imagePullConfig)
|
||||||
|
|
||||||
} else { //import
|
} else { //import
|
||||||
if tag == "" {
|
if tag == "" {
|
||||||
repo, tag = parsers.ParseRepositoryTag(repo)
|
repo, tag = parsers.ParseRepositoryTag(repo)
|
||||||
|
@ -746,7 +715,6 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter
|
||||||
Changes: r.Form["changes"],
|
Changes: r.Form["changes"],
|
||||||
InConfig: r.Body,
|
InConfig: r.Body,
|
||||||
OutStream: output,
|
OutStream: output,
|
||||||
Json: useJSON,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
|
newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
|
||||||
|
@ -762,7 +730,7 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter
|
||||||
if !output.Flushed() {
|
if !output.Flushed() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sf := streamformatter.NewStreamFormatter(useJSON)
|
sf := streamformatter.NewStreamFormatter(true)
|
||||||
output.Write(sf.FormatError(err))
|
output.Write(sf.FormatError(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -831,26 +799,22 @@ func (s *Server) postImagesPush(version version.Version, w http.ResponseWriter,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
useJSON := version.GreaterThan("1.0")
|
|
||||||
name := vars["name"]
|
name := vars["name"]
|
||||||
|
|
||||||
output := ioutils.NewWriteFlusher(w)
|
output := ioutils.NewWriteFlusher(w)
|
||||||
imagePushConfig := &graph.ImagePushConfig{
|
imagePushConfig := &graph.ImagePushConfig{
|
||||||
MetaHeaders: metaHeaders,
|
MetaHeaders: metaHeaders,
|
||||||
AuthConfig: authConfig,
|
AuthConfig: authConfig,
|
||||||
Tag: r.Form.Get("tag"),
|
Tag: r.Form.Get("tag"),
|
||||||
OutStream: output,
|
OutStream: output,
|
||||||
Json: useJSON,
|
|
||||||
}
|
|
||||||
if useJSON {
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
|
||||||
if err := s.daemon.Repositories().Push(name, imagePushConfig); err != nil {
|
if err := s.daemon.Repositories().Push(name, imagePushConfig); err != nil {
|
||||||
if !output.Flushed() {
|
if !output.Flushed() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sf := streamformatter.NewStreamFormatter(useJSON)
|
sf := streamformatter.NewStreamFormatter(true)
|
||||||
output.Write(sf.FormatError(err))
|
output.Write(sf.FormatError(err))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -865,10 +829,7 @@ func (s *Server) getImagesGet(version version.Version, w http.ResponseWriter, r
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
useJSON := version.GreaterThan("1.0")
|
w.Header().Set("Content-Type", "application/x-tar")
|
||||||
if useJSON {
|
|
||||||
w.Header().Set("Content-Type", "application/x-tar")
|
|
||||||
}
|
|
||||||
|
|
||||||
output := ioutils.NewWriteFlusher(w)
|
output := ioutils.NewWriteFlusher(w)
|
||||||
imageExportConfig := &graph.ImageExportConfig{Outstream: output}
|
imageExportConfig := &graph.ImageExportConfig{Outstream: output}
|
||||||
|
@ -882,7 +843,7 @@ func (s *Server) getImagesGet(version version.Version, w http.ResponseWriter, r
|
||||||
if !output.Flushed() {
|
if !output.Flushed() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sf := streamformatter.NewStreamFormatter(useJSON)
|
sf := streamformatter.NewStreamFormatter(true)
|
||||||
output.Write(sf.FormatError(err))
|
output.Write(sf.FormatError(err))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -1169,16 +1130,7 @@ func (s *Server) getContainersByName(version version.Version, w http.ResponseWri
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
name := vars["name"]
|
containerJSON, err := s.daemon.ContainerInspect(vars["name"])
|
||||||
|
|
||||||
if version.LessThan("1.12") {
|
|
||||||
containerJSONRaw, err := s.daemon.ContainerInspectRaw(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return writeJSON(w, http.StatusOK, containerJSONRaw)
|
|
||||||
}
|
|
||||||
containerJSON, err := s.daemon.ContainerInspect(name)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1203,17 +1155,7 @@ func (s *Server) getImagesByName(version version.Version, w http.ResponseWriter,
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
name := vars["name"]
|
imageInspect, err := s.daemon.Repositories().Lookup(vars["name"])
|
||||||
if version.LessThan("1.12") {
|
|
||||||
imageInspectRaw, err := s.daemon.Repositories().LookupRaw(name)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
return writeJSON(w, http.StatusOK, imageInspectRaw)
|
|
||||||
}
|
|
||||||
|
|
||||||
imageInspect, err := s.daemon.Repositories().Lookup(name)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -1222,30 +1164,13 @@ func (s *Server) getImagesByName(version version.Version, w http.ResponseWriter,
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
||||||
if version.LessThan("1.3") {
|
|
||||||
return fmt.Errorf("Multipart upload for build is no longer supported. Please upgrade your docker client.")
|
|
||||||
}
|
|
||||||
var (
|
var (
|
||||||
authEncoded = r.Header.Get("X-Registry-Auth")
|
|
||||||
authConfig = &cliconfig.AuthConfig{}
|
authConfig = &cliconfig.AuthConfig{}
|
||||||
configFileEncoded = r.Header.Get("X-Registry-Config")
|
configFileEncoded = r.Header.Get("X-Registry-Config")
|
||||||
configFile = &cliconfig.ConfigFile{}
|
configFile = &cliconfig.ConfigFile{}
|
||||||
buildConfig = builder.NewBuildConfig()
|
buildConfig = builder.NewBuildConfig()
|
||||||
)
|
)
|
||||||
|
|
||||||
// This block can be removed when API versions prior to 1.9 are deprecated.
|
|
||||||
// Both headers will be parsed and sent along to the daemon, but if a non-empty
|
|
||||||
// ConfigFile is present, any value provided as an AuthConfig directly will
|
|
||||||
// be overridden. See BuildFile::CmdFrom for details.
|
|
||||||
if version.LessThan("1.9") && authEncoded != "" {
|
|
||||||
authJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded))
|
|
||||||
if err := json.NewDecoder(authJson).Decode(authConfig); err != nil {
|
|
||||||
// for a pull it is not an error if no auth was given
|
|
||||||
// to increase compatibility with the existing api it is defaulting to be empty
|
|
||||||
authConfig = &cliconfig.AuthConfig{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if configFileEncoded != "" {
|
if configFileEncoded != "" {
|
||||||
configFileJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(configFileEncoded))
|
configFileJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(configFileEncoded))
|
||||||
if err := json.NewDecoder(configFileJson).Decode(configFile); err != nil {
|
if err := json.NewDecoder(configFileJson).Decode(configFile); err != nil {
|
||||||
|
@ -1255,10 +1180,7 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if version.GreaterThanOrEqualTo("1.8") {
|
w.Header().Set("Content-Type", "application/json")
|
||||||
w.Header().Set("Content-Type", "application/json")
|
|
||||||
buildConfig.JSONFormat = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if boolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
|
if boolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
|
||||||
buildConfig.Remove = true
|
buildConfig.Remove = true
|
||||||
|
@ -1312,7 +1234,7 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht
|
||||||
if !output.Flushed() {
|
if !output.Flushed() {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
sf := streamformatter.NewStreamFormatter(version.GreaterThanOrEqualTo("1.8"))
|
sf := streamformatter.NewStreamFormatter(true)
|
||||||
w.Write(sf.FormatError(err))
|
w.Write(sf.FormatError(err))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -1418,12 +1340,11 @@ func (s *Server) postContainerExecStart(version version.Version, w http.Response
|
||||||
fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
|
fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
|
||||||
}
|
}
|
||||||
|
|
||||||
if !execStartCheck.Tty && version.GreaterThanOrEqualTo("1.6") {
|
if !execStartCheck.Tty {
|
||||||
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
|
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
|
||||||
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
|
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
|
||||||
} else {
|
|
||||||
errStream = outStream
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stdin = inStream
|
stdin = inStream
|
||||||
stdout = outStream
|
stdout = outStream
|
||||||
stderr = errStream
|
stderr = errStream
|
||||||
|
|
|
@ -92,15 +92,6 @@ type ImageInspect struct {
|
||||||
VirtualSize int64
|
VirtualSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
type LegacyImage struct {
|
|
||||||
ID string `json:"Id"`
|
|
||||||
Repository string
|
|
||||||
Tag string
|
|
||||||
Created int
|
|
||||||
Size int
|
|
||||||
VirtualSize int
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET "/containers/json"
|
// GET "/containers/json"
|
||||||
type Port struct {
|
type Port struct {
|
||||||
IP string
|
IP string
|
||||||
|
|
|
@ -458,10 +458,8 @@ func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
imagePullConfig := &graph.ImagePullConfig{
|
imagePullConfig := &graph.ImagePullConfig{
|
||||||
Parallel: true,
|
|
||||||
AuthConfig: pullRegistryAuth,
|
AuthConfig: pullRegistryAuth,
|
||||||
OutStream: ioutils.NopWriteCloser(b.OutOld),
|
OutStream: ioutils.NopWriteCloser(b.OutOld),
|
||||||
Json: b.StreamFormatter.Json(),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig); err != nil {
|
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig); err != nil {
|
||||||
|
|
|
@ -45,7 +45,6 @@ type Config struct {
|
||||||
Remove bool
|
Remove bool
|
||||||
ForceRemove bool
|
ForceRemove bool
|
||||||
Pull bool
|
Pull bool
|
||||||
JSONFormat bool
|
|
||||||
Memory int64
|
Memory int64
|
||||||
MemorySwap int64
|
MemorySwap int64
|
||||||
CpuShares int64
|
CpuShares int64
|
||||||
|
@ -142,7 +141,7 @@ func Build(d *daemon.Daemon, buildConfig *Config) error {
|
||||||
}
|
}
|
||||||
defer context.Close()
|
defer context.Close()
|
||||||
|
|
||||||
sf := streamformatter.NewStreamFormatter(buildConfig.JSONFormat)
|
sf := streamformatter.NewStreamFormatter(true)
|
||||||
|
|
||||||
builder := &Builder{
|
builder := &Builder{
|
||||||
Daemon: d,
|
Daemon: d,
|
||||||
|
|
|
@ -12,18 +12,6 @@ type ContainerJSONRaw struct {
|
||||||
HostConfig *runconfig.HostConfig
|
HostConfig *runconfig.HostConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func (daemon *Daemon) ContainerInspectRaw(name string) (*ContainerJSONRaw, error) {
|
|
||||||
container, err := daemon.Get(name)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
container.Lock()
|
|
||||||
defer container.Unlock()
|
|
||||||
|
|
||||||
return &ContainerJSONRaw{container, container.hostConfig}, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (daemon *Daemon) ContainerInspect(name string) (*types.ContainerJSON, error) {
|
func (daemon *Daemon) ContainerInspect(name string) (*types.ContainerJSON, error) {
|
||||||
container, err := daemon.Get(name)
|
container, err := daemon.Get(name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -16,14 +16,13 @@ import (
|
||||||
type ImageImportConfig struct {
|
type ImageImportConfig struct {
|
||||||
Changes []string
|
Changes []string
|
||||||
InConfig io.ReadCloser
|
InConfig io.ReadCloser
|
||||||
Json bool
|
|
||||||
OutStream io.Writer
|
OutStream io.Writer
|
||||||
ContainerConfig *runconfig.Config
|
ContainerConfig *runconfig.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) Import(src string, repo string, tag string, imageImportConfig *ImageImportConfig) error {
|
func (s *TagStore) Import(src string, repo string, tag string, imageImportConfig *ImageImportConfig) error {
|
||||||
var (
|
var (
|
||||||
sf = streamformatter.NewStreamFormatter(imageImportConfig.Json)
|
sf = streamformatter.NewStreamFormatter(true)
|
||||||
archive archive.ArchiveReader
|
archive archive.ArchiveReader
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
)
|
)
|
||||||
|
|
|
@ -22,16 +22,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ImagePullConfig struct {
|
type ImagePullConfig struct {
|
||||||
Parallel bool
|
|
||||||
MetaHeaders map[string][]string
|
MetaHeaders map[string][]string
|
||||||
AuthConfig *cliconfig.AuthConfig
|
AuthConfig *cliconfig.AuthConfig
|
||||||
Json bool
|
|
||||||
OutStream io.Writer
|
OutStream io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig) error {
|
func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig) error {
|
||||||
var (
|
var (
|
||||||
sf = streamformatter.NewStreamFormatter(imagePullConfig.Json)
|
sf = streamformatter.NewStreamFormatter(true)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Resolve the Repository name from fqn to RepositoryInfo
|
// Resolve the Repository name from fqn to RepositoryInfo
|
||||||
|
@ -78,7 +76,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName)
|
logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName)
|
||||||
if err := s.pullV2Repository(r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err == nil {
|
if err := s.pullV2Repository(r, imagePullConfig.OutStream, repoInfo, tag, sf); err == nil {
|
||||||
s.eventsService.Log("pull", logName, "")
|
s.eventsService.Log("pull", logName, "")
|
||||||
return nil
|
return nil
|
||||||
} else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable {
|
} else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable {
|
||||||
|
@ -89,7 +87,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Debugf("pulling v1 repository with local name %q", repoInfo.LocalName)
|
logrus.Debugf("pulling v1 repository with local name %q", repoInfo.LocalName)
|
||||||
if err = s.pullRepository(r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err != nil {
|
if err = s.pullRepository(r, imagePullConfig.OutStream, repoInfo, tag, sf); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +96,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, askedTag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, askedTag string, sf *streamformatter.StreamFormatter) error {
|
||||||
out.Write(sf.FormatStatus("", "Pulling repository %s", repoInfo.CanonicalName))
|
out.Write(sf.FormatStatus("", "Pulling repository %s", repoInfo.CanonicalName))
|
||||||
|
|
||||||
repoData, err := r.GetRepositoryData(repoInfo.RemoteName)
|
repoData, err := r.GetRepositoryData(repoInfo.RemoteName)
|
||||||
|
@ -146,17 +144,13 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *
|
||||||
for _, image := range repoData.ImgList {
|
for _, image := range repoData.ImgList {
|
||||||
downloadImage := func(img *registry.ImgData) {
|
downloadImage := func(img *registry.ImgData) {
|
||||||
if askedTag != "" && img.Tag != askedTag {
|
if askedTag != "" && img.Tag != askedTag {
|
||||||
if parallel {
|
errors <- nil
|
||||||
errors <- nil
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if img.Tag == "" {
|
if img.Tag == "" {
|
||||||
logrus.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID)
|
logrus.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID)
|
||||||
if parallel {
|
errors <- nil
|
||||||
errors <- nil
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,9 +163,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *
|
||||||
} else {
|
} else {
|
||||||
logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err)
|
logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err)
|
||||||
}
|
}
|
||||||
if parallel {
|
errors <- nil
|
||||||
errors <- nil
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer s.poolRemove("pull", "img:"+img.ID)
|
defer s.poolRemove("pull", "img:"+img.ID)
|
||||||
|
@ -209,36 +201,27 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *
|
||||||
if !success {
|
if !success {
|
||||||
err := fmt.Errorf("Error pulling image (%s) from %s, %v", img.Tag, repoInfo.CanonicalName, lastErr)
|
err := fmt.Errorf("Error pulling image (%s) from %s, %v", img.Tag, repoInfo.CanonicalName, lastErr)
|
||||||
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), err.Error(), nil))
|
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), err.Error(), nil))
|
||||||
if parallel {
|
errors <- err
|
||||||
errors <- err
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil))
|
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil))
|
||||||
|
|
||||||
if parallel {
|
errors <- nil
|
||||||
errors <- nil
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if parallel {
|
go downloadImage(image)
|
||||||
go downloadImage(image)
|
|
||||||
} else {
|
|
||||||
downloadImage(image)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if parallel {
|
|
||||||
var lastError error
|
|
||||||
for i := 0; i < len(repoData.ImgList); i++ {
|
|
||||||
if err := <-errors; err != nil {
|
|
||||||
lastError = err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if lastError != nil {
|
|
||||||
return lastError
|
|
||||||
}
|
|
||||||
|
|
||||||
|
var lastError error
|
||||||
|
for i := 0; i < len(repoData.ImgList); i++ {
|
||||||
|
if err := <-errors; err != nil {
|
||||||
|
lastError = err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if lastError != nil {
|
||||||
|
return lastError
|
||||||
|
}
|
||||||
|
|
||||||
for tag, id := range tagsList {
|
for tag, id := range tagsList {
|
||||||
if askedTag != "" && tag != askedTag {
|
if askedTag != "" && tag != askedTag {
|
||||||
continue
|
continue
|
||||||
|
@ -373,7 +356,7 @@ type downloadInfo struct {
|
||||||
err chan error
|
err chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter) error {
|
||||||
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
|
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if repoInfo.Index.Official {
|
if repoInfo.Index.Official {
|
||||||
|
@ -397,14 +380,14 @@ func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo
|
||||||
return registry.ErrDoesNotExist
|
return registry.ErrDoesNotExist
|
||||||
}
|
}
|
||||||
for _, t := range tags {
|
for _, t := range tags {
|
||||||
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, t, sf, parallel, auth); err != nil {
|
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, t, sf, auth); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if downloaded {
|
} else if downloaded {
|
||||||
layersDownloaded = true
|
layersDownloaded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, tag, sf, parallel, auth); err != nil {
|
if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, tag, sf, auth); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if downloaded {
|
} else if downloaded {
|
||||||
layersDownloaded = true
|
layersDownloaded = true
|
||||||
|
@ -419,7 +402,7 @@ func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *TagStore) pullV2Tag(r *registry.Session, out io.Writer, endpoint *registry.Endpoint, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool, auth *registry.RequestAuthorization) (bool, error) {
|
func (s *TagStore) pullV2Tag(r *registry.Session, out io.Writer, endpoint *registry.Endpoint, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, auth *registry.RequestAuthorization) (bool, error) {
|
||||||
logrus.Debugf("Pulling tag from V2 registry: %q", tag)
|
logrus.Debugf("Pulling tag from V2 registry: %q", tag)
|
||||||
|
|
||||||
manifestBytes, manifestDigest, err := r.GetV2ImageManifest(endpoint, repoInfo.RemoteName, tag, auth)
|
manifestBytes, manifestDigest, err := r.GetV2ImageManifest(endpoint, repoInfo.RemoteName, tag, auth)
|
||||||
|
@ -531,16 +514,10 @@ func (s *TagStore) pullV2Tag(r *registry.Session, out io.Writer, endpoint *regis
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if parallel {
|
downloads[i].err = make(chan error)
|
||||||
downloads[i].err = make(chan error)
|
go func(di *downloadInfo) {
|
||||||
go func(di *downloadInfo) {
|
di.err <- downloadFunc(di)
|
||||||
di.err <- downloadFunc(di)
|
}(&downloads[i])
|
||||||
}(&downloads[i])
|
|
||||||
} else {
|
|
||||||
if err := downloadFunc(&downloads[i]); err != nil {
|
|
||||||
return false, err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var tagUpdated bool
|
var tagUpdated bool
|
||||||
|
|
|
@ -30,7 +30,6 @@ type ImagePushConfig struct {
|
||||||
MetaHeaders map[string][]string
|
MetaHeaders map[string][]string
|
||||||
AuthConfig *cliconfig.AuthConfig
|
AuthConfig *cliconfig.AuthConfig
|
||||||
Tag string
|
Tag string
|
||||||
Json bool
|
|
||||||
OutStream io.Writer
|
OutStream io.Writer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,7 +495,7 @@ func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint *
|
||||||
// FIXME: Allow to interrupt current push when new push of same image is done.
|
// FIXME: Allow to interrupt current push when new push of same image is done.
|
||||||
func (s *TagStore) Push(localName string, imagePushConfig *ImagePushConfig) error {
|
func (s *TagStore) Push(localName string, imagePushConfig *ImagePushConfig) error {
|
||||||
var (
|
var (
|
||||||
sf = streamformatter.NewStreamFormatter(imagePushConfig.Json)
|
sf = streamformatter.NewStreamFormatter(true)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Resolve the Repository name from fqn to RepositoryInfo
|
// Resolve the Repository name from fqn to RepositoryInfo
|
||||||
|
|
|
@ -11,21 +11,6 @@ import (
|
||||||
"github.com/go-check/check"
|
"github.com/go-check/check"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *DockerSuite) TestLegacyImages(c *check.C) {
|
|
||||||
status, body, err := sockRequest("GET", "/v1.6/images/json", nil)
|
|
||||||
c.Assert(status, check.Equals, http.StatusOK)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
images := []types.LegacyImage{}
|
|
||||||
if err = json.Unmarshal(body, &images); err != nil {
|
|
||||||
c.Fatalf("Error on unmarshal: %s", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(images) == 0 || images[0].Tag == "" || images[0].Repository == "" {
|
|
||||||
c.Fatalf("Bad data: %q", images)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *DockerSuite) TestApiImagesFilter(c *check.C) {
|
func (s *DockerSuite) TestApiImagesFilter(c *check.C) {
|
||||||
name := "utest:tag1"
|
name := "utest:tag1"
|
||||||
name2 := "utest/docker:tag2"
|
name2 := "utest/docker:tag2"
|
||||||
|
|
|
@ -18,40 +18,27 @@ func (s *DockerSuite) TestInspectApiContainerResponse(c *check.C) {
|
||||||
|
|
||||||
cleanedContainerID := strings.TrimSpace(out)
|
cleanedContainerID := strings.TrimSpace(out)
|
||||||
|
|
||||||
// test on json marshal version
|
endpoint := "/containers/" + cleanedContainerID + "/json"
|
||||||
// and latest version
|
status, body, err := sockRequest("GET", endpoint, nil)
|
||||||
testVersions := []string{"v1.11", "latest"}
|
c.Assert(status, check.Equals, http.StatusOK)
|
||||||
|
c.Assert(err, check.IsNil)
|
||||||
|
|
||||||
for _, testVersion := range testVersions {
|
var inspectJSON map[string]interface{}
|
||||||
endpoint := "/containers/" + cleanedContainerID + "/json"
|
if err = json.Unmarshal(body, &inspectJSON); err != nil {
|
||||||
if testVersion != "latest" {
|
c.Fatalf("unable to unmarshal body for latest version: %v", err)
|
||||||
endpoint = "/" + testVersion + endpoint
|
}
|
||||||
}
|
|
||||||
status, body, err := sockRequest("GET", endpoint, nil)
|
|
||||||
c.Assert(status, check.Equals, http.StatusOK)
|
|
||||||
c.Assert(err, check.IsNil)
|
|
||||||
|
|
||||||
var inspectJSON map[string]interface{}
|
keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW"}
|
||||||
if err = json.Unmarshal(body, &inspectJSON); err != nil {
|
|
||||||
c.Fatalf("unable to unmarshal body for %s version: %v", testVersion, err)
|
|
||||||
}
|
|
||||||
|
|
||||||
keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW"}
|
keys = append(keys, "Id")
|
||||||
|
|
||||||
if testVersion == "v1.11" {
|
for _, key := range keys {
|
||||||
keys = append(keys, "ID")
|
if _, ok := inspectJSON[key]; !ok {
|
||||||
} else {
|
c.Fatalf("%s does not exist in response for latest version", key)
|
||||||
keys = append(keys, "Id")
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, key := range keys {
|
|
||||||
if _, ok := inspectJSON[key]; !ok {
|
|
||||||
c.Fatalf("%s does not exist in response for %s version", key, testVersion)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Issue #6830: type not properly converted to JSON/back
|
|
||||||
if _, ok := inspectJSON["Path"].(bool); ok {
|
|
||||||
c.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Issue #6830: type not properly converted to JSON/back
|
||||||
|
if _, ok := inspectJSON["Path"].(bool); ok {
|
||||||
|
c.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue