Signed-off-by: Antonio Murdaca <me@runcom.ninja>
| ... | ... |
@@ -353,28 +353,7 @@ func (s *Server) getImagesJSON(version version.Version, w http.ResponseWriter, r |
| 353 | 353 |
return err |
| 354 | 354 |
} |
| 355 | 355 |
|
| 356 |
- if version.GreaterThanOrEqualTo("1.7") {
|
|
| 357 |
- return writeJSON(w, http.StatusOK, images) |
|
| 358 |
- } |
|
| 359 |
- |
|
| 360 |
- legacyImages := []types.LegacyImage{}
|
|
| 361 |
- |
|
| 362 |
- for _, image := range images {
|
|
| 363 |
- for _, repoTag := range image.RepoTags {
|
|
| 364 |
- repo, tag := parsers.ParseRepositoryTag(repoTag) |
|
| 365 |
- legacyImage := types.LegacyImage{
|
|
| 366 |
- Repository: repo, |
|
| 367 |
- Tag: tag, |
|
| 368 |
- ID: image.ID, |
|
| 369 |
- Created: image.Created, |
|
| 370 |
- Size: image.Size, |
|
| 371 |
- VirtualSize: image.VirtualSize, |
|
| 372 |
- } |
|
| 373 |
- legacyImages = append(legacyImages, legacyImage) |
|
| 374 |
- } |
|
| 375 |
- } |
|
| 376 |
- |
|
| 377 |
- return writeJSON(w, http.StatusOK, legacyImages) |
|
| 356 |
+ return writeJSON(w, http.StatusOK, images) |
|
| 378 | 357 |
} |
| 379 | 358 |
|
| 380 | 359 |
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 |
| 520 | 520 |
} |
| 521 | 521 |
|
| 522 | 522 |
func (s *Server) getContainersTop(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 523 |
- if version.LessThan("1.4") {
|
|
| 524 |
- return fmt.Errorf("top was improved a lot since 1.3, Please upgrade your docker client.")
|
|
| 525 |
- } |
|
| 526 |
- |
|
| 527 | 523 |
if vars == nil {
|
| 528 | 524 |
return fmt.Errorf("Missing parameter")
|
| 529 | 525 |
} |
| ... | ... |
@@ -706,14 +681,11 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter |
| 706 | 706 |
} |
| 707 | 707 |
|
| 708 | 708 |
var ( |
| 709 |
- err error |
|
| 710 |
- useJSON = version.GreaterThan("1.0")
|
|
| 711 |
- output = ioutils.NewWriteFlusher(w) |
|
| 709 |
+ err error |
|
| 710 |
+ output = ioutils.NewWriteFlusher(w) |
|
| 712 | 711 |
) |
| 713 | 712 |
|
| 714 |
- if useJSON {
|
|
| 715 |
- w.Header().Set("Content-Type", "application/json")
|
|
| 716 |
- } |
|
| 713 |
+ w.Header().Set("Content-Type", "application/json")
|
|
| 717 | 714 |
|
| 718 | 715 |
if image != "" { //pull
|
| 719 | 716 |
if tag == "" {
|
| ... | ... |
@@ -727,15 +699,12 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter |
| 727 | 727 |
} |
| 728 | 728 |
|
| 729 | 729 |
imagePullConfig := &graph.ImagePullConfig{
|
| 730 |
- Parallel: version.GreaterThan("1.3"),
|
|
| 731 | 730 |
MetaHeaders: metaHeaders, |
| 732 | 731 |
AuthConfig: authConfig, |
| 733 | 732 |
OutStream: output, |
| 734 |
- Json: useJSON, |
|
| 735 | 733 |
} |
| 736 | 734 |
|
| 737 | 735 |
err = s.daemon.Repositories().Pull(image, tag, imagePullConfig) |
| 738 |
- |
|
| 739 | 736 |
} else { //import
|
| 740 | 737 |
if tag == "" {
|
| 741 | 738 |
repo, tag = parsers.ParseRepositoryTag(repo) |
| ... | ... |
@@ -746,7 +715,6 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter |
| 746 | 746 |
Changes: r.Form["changes"], |
| 747 | 747 |
InConfig: r.Body, |
| 748 | 748 |
OutStream: output, |
| 749 |
- Json: useJSON, |
|
| 750 | 749 |
} |
| 751 | 750 |
|
| 752 | 751 |
newConfig, err := builder.BuildFromConfig(s.daemon, &runconfig.Config{}, imageImportConfig.Changes)
|
| ... | ... |
@@ -762,7 +730,7 @@ func (s *Server) postImagesCreate(version version.Version, w http.ResponseWriter |
| 762 | 762 |
if !output.Flushed() {
|
| 763 | 763 |
return err |
| 764 | 764 |
} |
| 765 |
- sf := streamformatter.NewStreamFormatter(useJSON) |
|
| 765 |
+ sf := streamformatter.NewStreamFormatter(true) |
|
| 766 | 766 |
output.Write(sf.FormatError(err)) |
| 767 | 767 |
} |
| 768 | 768 |
|
| ... | ... |
@@ -831,26 +799,22 @@ func (s *Server) postImagesPush(version version.Version, w http.ResponseWriter, |
| 831 | 831 |
} |
| 832 | 832 |
} |
| 833 | 833 |
|
| 834 |
- useJSON := version.GreaterThan("1.0")
|
|
| 835 | 834 |
name := vars["name"] |
| 836 |
- |
|
| 837 | 835 |
output := ioutils.NewWriteFlusher(w) |
| 838 | 836 |
imagePushConfig := &graph.ImagePushConfig{
|
| 839 | 837 |
MetaHeaders: metaHeaders, |
| 840 | 838 |
AuthConfig: authConfig, |
| 841 | 839 |
Tag: r.Form.Get("tag"),
|
| 842 | 840 |
OutStream: output, |
| 843 |
- Json: useJSON, |
|
| 844 |
- } |
|
| 845 |
- if useJSON {
|
|
| 846 |
- w.Header().Set("Content-Type", "application/json")
|
|
| 847 | 841 |
} |
| 848 | 842 |
|
| 843 |
+ w.Header().Set("Content-Type", "application/json")
|
|
| 844 |
+ |
|
| 849 | 845 |
if err := s.daemon.Repositories().Push(name, imagePushConfig); err != nil {
|
| 850 | 846 |
if !output.Flushed() {
|
| 851 | 847 |
return err |
| 852 | 848 |
} |
| 853 |
- sf := streamformatter.NewStreamFormatter(useJSON) |
|
| 849 |
+ sf := streamformatter.NewStreamFormatter(true) |
|
| 854 | 850 |
output.Write(sf.FormatError(err)) |
| 855 | 851 |
} |
| 856 | 852 |
return nil |
| ... | ... |
@@ -865,10 +829,7 @@ func (s *Server) getImagesGet(version version.Version, w http.ResponseWriter, r |
| 865 | 865 |
return err |
| 866 | 866 |
} |
| 867 | 867 |
|
| 868 |
- useJSON := version.GreaterThan("1.0")
|
|
| 869 |
- if useJSON {
|
|
| 870 |
- w.Header().Set("Content-Type", "application/x-tar")
|
|
| 871 |
- } |
|
| 868 |
+ w.Header().Set("Content-Type", "application/x-tar")
|
|
| 872 | 869 |
|
| 873 | 870 |
output := ioutils.NewWriteFlusher(w) |
| 874 | 871 |
imageExportConfig := &graph.ImageExportConfig{Outstream: output}
|
| ... | ... |
@@ -882,7 +843,7 @@ func (s *Server) getImagesGet(version version.Version, w http.ResponseWriter, r |
| 882 | 882 |
if !output.Flushed() {
|
| 883 | 883 |
return err |
| 884 | 884 |
} |
| 885 |
- sf := streamformatter.NewStreamFormatter(useJSON) |
|
| 885 |
+ sf := streamformatter.NewStreamFormatter(true) |
|
| 886 | 886 |
output.Write(sf.FormatError(err)) |
| 887 | 887 |
} |
| 888 | 888 |
return nil |
| ... | ... |
@@ -1169,16 +1130,7 @@ func (s *Server) getContainersByName(version version.Version, w http.ResponseWri |
| 1169 | 1169 |
return fmt.Errorf("Missing parameter")
|
| 1170 | 1170 |
} |
| 1171 | 1171 |
|
| 1172 |
- name := vars["name"] |
|
| 1173 |
- |
|
| 1174 |
- if version.LessThan("1.12") {
|
|
| 1175 |
- containerJSONRaw, err := s.daemon.ContainerInspectRaw(name) |
|
| 1176 |
- if err != nil {
|
|
| 1177 |
- return err |
|
| 1178 |
- } |
|
| 1179 |
- return writeJSON(w, http.StatusOK, containerJSONRaw) |
|
| 1180 |
- } |
|
| 1181 |
- containerJSON, err := s.daemon.ContainerInspect(name) |
|
| 1172 |
+ containerJSON, err := s.daemon.ContainerInspect(vars["name"]) |
|
| 1182 | 1173 |
if err != nil {
|
| 1183 | 1174 |
return err |
| 1184 | 1175 |
} |
| ... | ... |
@@ -1203,17 +1155,7 @@ func (s *Server) getImagesByName(version version.Version, w http.ResponseWriter, |
| 1203 | 1203 |
return fmt.Errorf("Missing parameter")
|
| 1204 | 1204 |
} |
| 1205 | 1205 |
|
| 1206 |
- name := vars["name"] |
|
| 1207 |
- if version.LessThan("1.12") {
|
|
| 1208 |
- imageInspectRaw, err := s.daemon.Repositories().LookupRaw(name) |
|
| 1209 |
- if err != nil {
|
|
| 1210 |
- return err |
|
| 1211 |
- } |
|
| 1212 |
- |
|
| 1213 |
- return writeJSON(w, http.StatusOK, imageInspectRaw) |
|
| 1214 |
- } |
|
| 1215 |
- |
|
| 1216 |
- imageInspect, err := s.daemon.Repositories().Lookup(name) |
|
| 1206 |
+ imageInspect, err := s.daemon.Repositories().Lookup(vars["name"]) |
|
| 1217 | 1207 |
if err != nil {
|
| 1218 | 1208 |
return err |
| 1219 | 1209 |
} |
| ... | ... |
@@ -1222,30 +1164,13 @@ func (s *Server) getImagesByName(version version.Version, w http.ResponseWriter, |
| 1222 | 1222 |
} |
| 1223 | 1223 |
|
| 1224 | 1224 |
func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
|
| 1225 |
- if version.LessThan("1.3") {
|
|
| 1226 |
- return fmt.Errorf("Multipart upload for build is no longer supported. Please upgrade your docker client.")
|
|
| 1227 |
- } |
|
| 1228 | 1225 |
var ( |
| 1229 |
- authEncoded = r.Header.Get("X-Registry-Auth")
|
|
| 1230 | 1226 |
authConfig = &cliconfig.AuthConfig{}
|
| 1231 | 1227 |
configFileEncoded = r.Header.Get("X-Registry-Config")
|
| 1232 | 1228 |
configFile = &cliconfig.ConfigFile{}
|
| 1233 | 1229 |
buildConfig = builder.NewBuildConfig() |
| 1234 | 1230 |
) |
| 1235 | 1231 |
|
| 1236 |
- // This block can be removed when API versions prior to 1.9 are deprecated. |
|
| 1237 |
- // Both headers will be parsed and sent along to the daemon, but if a non-empty |
|
| 1238 |
- // ConfigFile is present, any value provided as an AuthConfig directly will |
|
| 1239 |
- // be overridden. See BuildFile::CmdFrom for details. |
|
| 1240 |
- if version.LessThan("1.9") && authEncoded != "" {
|
|
| 1241 |
- authJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(authEncoded)) |
|
| 1242 |
- if err := json.NewDecoder(authJson).Decode(authConfig); err != nil {
|
|
| 1243 |
- // for a pull it is not an error if no auth was given |
|
| 1244 |
- // to increase compatibility with the existing api it is defaulting to be empty |
|
| 1245 |
- authConfig = &cliconfig.AuthConfig{}
|
|
| 1246 |
- } |
|
| 1247 |
- } |
|
| 1248 |
- |
|
| 1249 | 1232 |
if configFileEncoded != "" {
|
| 1250 | 1233 |
configFileJson := base64.NewDecoder(base64.URLEncoding, strings.NewReader(configFileEncoded)) |
| 1251 | 1234 |
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 |
| 1255 | 1255 |
} |
| 1256 | 1256 |
} |
| 1257 | 1257 |
|
| 1258 |
- if version.GreaterThanOrEqualTo("1.8") {
|
|
| 1259 |
- w.Header().Set("Content-Type", "application/json")
|
|
| 1260 |
- buildConfig.JSONFormat = true |
|
| 1261 |
- } |
|
| 1258 |
+ w.Header().Set("Content-Type", "application/json")
|
|
| 1262 | 1259 |
|
| 1263 | 1260 |
if boolValue(r, "forcerm") && version.GreaterThanOrEqualTo("1.12") {
|
| 1264 | 1261 |
buildConfig.Remove = true |
| ... | ... |
@@ -1312,7 +1234,7 @@ func (s *Server) postBuild(version version.Version, w http.ResponseWriter, r *ht |
| 1312 | 1312 |
if !output.Flushed() {
|
| 1313 | 1313 |
return err |
| 1314 | 1314 |
} |
| 1315 |
- sf := streamformatter.NewStreamFormatter(version.GreaterThanOrEqualTo("1.8"))
|
|
| 1315 |
+ sf := streamformatter.NewStreamFormatter(true) |
|
| 1316 | 1316 |
w.Write(sf.FormatError(err)) |
| 1317 | 1317 |
} |
| 1318 | 1318 |
return nil |
| ... | ... |
@@ -1418,12 +1340,11 @@ func (s *Server) postContainerExecStart(version version.Version, w http.Response |
| 1418 | 1418 |
fmt.Fprintf(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n") |
| 1419 | 1419 |
} |
| 1420 | 1420 |
|
| 1421 |
- if !execStartCheck.Tty && version.GreaterThanOrEqualTo("1.6") {
|
|
| 1421 |
+ if !execStartCheck.Tty {
|
|
| 1422 | 1422 |
errStream = stdcopy.NewStdWriter(outStream, stdcopy.Stderr) |
| 1423 | 1423 |
outStream = stdcopy.NewStdWriter(outStream, stdcopy.Stdout) |
| 1424 |
- } else {
|
|
| 1425 |
- errStream = outStream |
|
| 1426 | 1424 |
} |
| 1425 |
+ |
|
| 1427 | 1426 |
stdin = inStream |
| 1428 | 1427 |
stdout = outStream |
| 1429 | 1428 |
stderr = errStream |
| ... | ... |
@@ -92,15 +92,6 @@ type ImageInspect struct {
|
| 92 | 92 |
VirtualSize int64 |
| 93 | 93 |
} |
| 94 | 94 |
|
| 95 |
-type LegacyImage struct {
|
|
| 96 |
- ID string `json:"Id"` |
|
| 97 |
- Repository string |
|
| 98 |
- Tag string |
|
| 99 |
- Created int |
|
| 100 |
- Size int |
|
| 101 |
- VirtualSize int |
|
| 102 |
-} |
|
| 103 |
- |
|
| 104 | 95 |
// GET "/containers/json" |
| 105 | 96 |
type Port struct {
|
| 106 | 97 |
IP string |
| ... | ... |
@@ -458,10 +458,8 @@ func (b *Builder) pullImage(name string) (*imagepkg.Image, error) {
|
| 458 | 458 |
} |
| 459 | 459 |
|
| 460 | 460 |
imagePullConfig := &graph.ImagePullConfig{
|
| 461 |
- Parallel: true, |
|
| 462 | 461 |
AuthConfig: pullRegistryAuth, |
| 463 | 462 |
OutStream: ioutils.NopWriteCloser(b.OutOld), |
| 464 |
- Json: b.StreamFormatter.Json(), |
|
| 465 | 463 |
} |
| 466 | 464 |
|
| 467 | 465 |
if err := b.Daemon.Repositories().Pull(remote, tag, imagePullConfig); err != nil {
|
| ... | ... |
@@ -45,7 +45,6 @@ type Config struct {
|
| 45 | 45 |
Remove bool |
| 46 | 46 |
ForceRemove bool |
| 47 | 47 |
Pull bool |
| 48 |
- JSONFormat bool |
|
| 49 | 48 |
Memory int64 |
| 50 | 49 |
MemorySwap int64 |
| 51 | 50 |
CpuShares int64 |
| ... | ... |
@@ -142,7 +141,7 @@ func Build(d *daemon.Daemon, buildConfig *Config) error {
|
| 142 | 142 |
} |
| 143 | 143 |
defer context.Close() |
| 144 | 144 |
|
| 145 |
- sf := streamformatter.NewStreamFormatter(buildConfig.JSONFormat) |
|
| 145 |
+ sf := streamformatter.NewStreamFormatter(true) |
|
| 146 | 146 |
|
| 147 | 147 |
builder := &Builder{
|
| 148 | 148 |
Daemon: d, |
| ... | ... |
@@ -12,18 +12,6 @@ type ContainerJSONRaw struct {
|
| 12 | 12 |
HostConfig *runconfig.HostConfig |
| 13 | 13 |
} |
| 14 | 14 |
|
| 15 |
-func (daemon *Daemon) ContainerInspectRaw(name string) (*ContainerJSONRaw, error) {
|
|
| 16 |
- container, err := daemon.Get(name) |
|
| 17 |
- if err != nil {
|
|
| 18 |
- return nil, err |
|
| 19 |
- } |
|
| 20 |
- |
|
| 21 |
- container.Lock() |
|
| 22 |
- defer container.Unlock() |
|
| 23 |
- |
|
| 24 |
- return &ContainerJSONRaw{container, container.hostConfig}, nil
|
|
| 25 |
-} |
|
| 26 |
- |
|
| 27 | 15 |
func (daemon *Daemon) ContainerInspect(name string) (*types.ContainerJSON, error) {
|
| 28 | 16 |
container, err := daemon.Get(name) |
| 29 | 17 |
if err != nil {
|
| ... | ... |
@@ -16,14 +16,13 @@ import ( |
| 16 | 16 |
type ImageImportConfig struct {
|
| 17 | 17 |
Changes []string |
| 18 | 18 |
InConfig io.ReadCloser |
| 19 |
- Json bool |
|
| 20 | 19 |
OutStream io.Writer |
| 21 | 20 |
ContainerConfig *runconfig.Config |
| 22 | 21 |
} |
| 23 | 22 |
|
| 24 | 23 |
func (s *TagStore) Import(src string, repo string, tag string, imageImportConfig *ImageImportConfig) error {
|
| 25 | 24 |
var ( |
| 26 |
- sf = streamformatter.NewStreamFormatter(imageImportConfig.Json) |
|
| 25 |
+ sf = streamformatter.NewStreamFormatter(true) |
|
| 27 | 26 |
archive archive.ArchiveReader |
| 28 | 27 |
resp *http.Response |
| 29 | 28 |
) |
| ... | ... |
@@ -22,16 +22,14 @@ import ( |
| 22 | 22 |
) |
| 23 | 23 |
|
| 24 | 24 |
type ImagePullConfig struct {
|
| 25 |
- Parallel bool |
|
| 26 | 25 |
MetaHeaders map[string][]string |
| 27 | 26 |
AuthConfig *cliconfig.AuthConfig |
| 28 |
- Json bool |
|
| 29 | 27 |
OutStream io.Writer |
| 30 | 28 |
} |
| 31 | 29 |
|
| 32 | 30 |
func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConfig) error {
|
| 33 | 31 |
var ( |
| 34 |
- sf = streamformatter.NewStreamFormatter(imagePullConfig.Json) |
|
| 32 |
+ sf = streamformatter.NewStreamFormatter(true) |
|
| 35 | 33 |
) |
| 36 | 34 |
|
| 37 | 35 |
// Resolve the Repository name from fqn to RepositoryInfo |
| ... | ... |
@@ -78,7 +76,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf |
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
logrus.Debugf("pulling v2 repository with local name %q", repoInfo.LocalName)
|
| 81 |
- if err := s.pullV2Repository(r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err == nil {
|
|
| 81 |
+ if err := s.pullV2Repository(r, imagePullConfig.OutStream, repoInfo, tag, sf); err == nil {
|
|
| 82 | 82 |
s.eventsService.Log("pull", logName, "")
|
| 83 | 83 |
return nil |
| 84 | 84 |
} else if err != registry.ErrDoesNotExist && err != ErrV2RegistryUnavailable {
|
| ... | ... |
@@ -89,7 +87,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf |
| 89 | 89 |
} |
| 90 | 90 |
|
| 91 | 91 |
logrus.Debugf("pulling v1 repository with local name %q", repoInfo.LocalName)
|
| 92 |
- if err = s.pullRepository(r, imagePullConfig.OutStream, repoInfo, tag, sf, imagePullConfig.Parallel); err != nil {
|
|
| 92 |
+ if err = s.pullRepository(r, imagePullConfig.OutStream, repoInfo, tag, sf); err != nil {
|
|
| 93 | 93 |
return err |
| 94 | 94 |
} |
| 95 | 95 |
|
| ... | ... |
@@ -98,7 +96,7 @@ func (s *TagStore) Pull(image string, tag string, imagePullConfig *ImagePullConf |
| 98 | 98 |
return nil |
| 99 | 99 |
} |
| 100 | 100 |
|
| 101 |
-func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, askedTag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
|
| 101 |
+func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, askedTag string, sf *streamformatter.StreamFormatter) error {
|
|
| 102 | 102 |
out.Write(sf.FormatStatus("", "Pulling repository %s", repoInfo.CanonicalName))
|
| 103 | 103 |
|
| 104 | 104 |
repoData, err := r.GetRepositoryData(repoInfo.RemoteName) |
| ... | ... |
@@ -146,17 +144,13 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * |
| 146 | 146 |
for _, image := range repoData.ImgList {
|
| 147 | 147 |
downloadImage := func(img *registry.ImgData) {
|
| 148 | 148 |
if askedTag != "" && img.Tag != askedTag {
|
| 149 |
- if parallel {
|
|
| 150 |
- errors <- nil |
|
| 151 |
- } |
|
| 149 |
+ errors <- nil |
|
| 152 | 150 |
return |
| 153 | 151 |
} |
| 154 | 152 |
|
| 155 | 153 |
if img.Tag == "" {
|
| 156 | 154 |
logrus.Debugf("Image (id: %s) present in this repository but untagged, skipping", img.ID)
|
| 157 |
- if parallel {
|
|
| 158 |
- errors <- nil |
|
| 159 |
- } |
|
| 155 |
+ errors <- nil |
|
| 160 | 156 |
return |
| 161 | 157 |
} |
| 162 | 158 |
|
| ... | ... |
@@ -169,9 +163,7 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * |
| 169 | 169 |
} else {
|
| 170 | 170 |
logrus.Debugf("Image (id: %s) pull is already running, skipping: %v", img.ID, err)
|
| 171 | 171 |
} |
| 172 |
- if parallel {
|
|
| 173 |
- errors <- nil |
|
| 174 |
- } |
|
| 172 |
+ errors <- nil |
|
| 175 | 173 |
return |
| 176 | 174 |
} |
| 177 | 175 |
defer s.poolRemove("pull", "img:"+img.ID)
|
| ... | ... |
@@ -209,36 +201,27 @@ func (s *TagStore) pullRepository(r *registry.Session, out io.Writer, repoInfo * |
| 209 | 209 |
if !success {
|
| 210 | 210 |
err := fmt.Errorf("Error pulling image (%s) from %s, %v", img.Tag, repoInfo.CanonicalName, lastErr)
|
| 211 | 211 |
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), err.Error(), nil)) |
| 212 |
- if parallel {
|
|
| 213 |
- errors <- err |
|
| 214 |
- return |
|
| 215 |
- } |
|
| 212 |
+ errors <- err |
|
| 213 |
+ return |
|
| 216 | 214 |
} |
| 217 | 215 |
out.Write(sf.FormatProgress(stringid.TruncateID(img.ID), "Download complete", nil)) |
| 218 | 216 |
|
| 219 |
- if parallel {
|
|
| 220 |
- errors <- nil |
|
| 221 |
- } |
|
| 217 |
+ errors <- nil |
|
| 222 | 218 |
} |
| 223 | 219 |
|
| 224 |
- if parallel {
|
|
| 225 |
- go downloadImage(image) |
|
| 226 |
- } else {
|
|
| 227 |
- downloadImage(image) |
|
| 228 |
- } |
|
| 220 |
+ go downloadImage(image) |
|
| 229 | 221 |
} |
| 230 |
- if parallel {
|
|
| 231 |
- var lastError error |
|
| 232 |
- for i := 0; i < len(repoData.ImgList); i++ {
|
|
| 233 |
- if err := <-errors; err != nil {
|
|
| 234 |
- lastError = err |
|
| 235 |
- } |
|
| 236 |
- } |
|
| 237 |
- if lastError != nil {
|
|
| 238 |
- return lastError |
|
| 239 |
- } |
|
| 240 | 222 |
|
| 223 |
+ var lastError error |
|
| 224 |
+ for i := 0; i < len(repoData.ImgList); i++ {
|
|
| 225 |
+ if err := <-errors; err != nil {
|
|
| 226 |
+ lastError = err |
|
| 227 |
+ } |
|
| 228 |
+ } |
|
| 229 |
+ if lastError != nil {
|
|
| 230 |
+ return lastError |
|
| 241 | 231 |
} |
| 232 |
+ |
|
| 242 | 233 |
for tag, id := range tagsList {
|
| 243 | 234 |
if askedTag != "" && tag != askedTag {
|
| 244 | 235 |
continue |
| ... | ... |
@@ -373,7 +356,7 @@ type downloadInfo struct {
|
| 373 | 373 |
err chan error |
| 374 | 374 |
} |
| 375 | 375 |
|
| 376 |
-func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter, parallel bool) error {
|
|
| 376 |
+func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo *registry.RepositoryInfo, tag string, sf *streamformatter.StreamFormatter) error {
|
|
| 377 | 377 |
endpoint, err := r.V2RegistryEndpoint(repoInfo.Index) |
| 378 | 378 |
if err != nil {
|
| 379 | 379 |
if repoInfo.Index.Official {
|
| ... | ... |
@@ -397,14 +380,14 @@ func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo |
| 397 | 397 |
return registry.ErrDoesNotExist |
| 398 | 398 |
} |
| 399 | 399 |
for _, t := range tags {
|
| 400 |
- if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, t, sf, parallel, auth); err != nil {
|
|
| 400 |
+ if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, t, sf, auth); err != nil {
|
|
| 401 | 401 |
return err |
| 402 | 402 |
} else if downloaded {
|
| 403 | 403 |
layersDownloaded = true |
| 404 | 404 |
} |
| 405 | 405 |
} |
| 406 | 406 |
} else {
|
| 407 |
- if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, tag, sf, parallel, auth); err != nil {
|
|
| 407 |
+ if downloaded, err := s.pullV2Tag(r, out, endpoint, repoInfo, tag, sf, auth); err != nil {
|
|
| 408 | 408 |
return err |
| 409 | 409 |
} else if downloaded {
|
| 410 | 410 |
layersDownloaded = true |
| ... | ... |
@@ -419,7 +402,7 @@ func (s *TagStore) pullV2Repository(r *registry.Session, out io.Writer, repoInfo |
| 419 | 419 |
return nil |
| 420 | 420 |
} |
| 421 | 421 |
|
| 422 |
-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) {
|
|
| 422 |
+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) {
|
|
| 423 | 423 |
logrus.Debugf("Pulling tag from V2 registry: %q", tag)
|
| 424 | 424 |
|
| 425 | 425 |
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 |
| 531 | 531 |
return nil |
| 532 | 532 |
} |
| 533 | 533 |
|
| 534 |
- if parallel {
|
|
| 535 |
- downloads[i].err = make(chan error) |
|
| 536 |
- go func(di *downloadInfo) {
|
|
| 537 |
- di.err <- downloadFunc(di) |
|
| 538 |
- }(&downloads[i]) |
|
| 539 |
- } else {
|
|
| 540 |
- if err := downloadFunc(&downloads[i]); err != nil {
|
|
| 541 |
- return false, err |
|
| 542 |
- } |
|
| 543 |
- } |
|
| 534 |
+ downloads[i].err = make(chan error) |
|
| 535 |
+ go func(di *downloadInfo) {
|
|
| 536 |
+ di.err <- downloadFunc(di) |
|
| 537 |
+ }(&downloads[i]) |
|
| 544 | 538 |
} |
| 545 | 539 |
|
| 546 | 540 |
var tagUpdated bool |
| ... | ... |
@@ -30,7 +30,6 @@ type ImagePushConfig struct {
|
| 30 | 30 |
MetaHeaders map[string][]string |
| 31 | 31 |
AuthConfig *cliconfig.AuthConfig |
| 32 | 32 |
Tag string |
| 33 |
- Json bool |
|
| 34 | 33 |
OutStream io.Writer |
| 35 | 34 |
} |
| 36 | 35 |
|
| ... | ... |
@@ -496,7 +495,7 @@ func (s *TagStore) pushV2Image(r *registry.Session, img *image.Image, endpoint * |
| 496 | 496 |
// FIXME: Allow to interrupt current push when new push of same image is done. |
| 497 | 497 |
func (s *TagStore) Push(localName string, imagePushConfig *ImagePushConfig) error {
|
| 498 | 498 |
var ( |
| 499 |
- sf = streamformatter.NewStreamFormatter(imagePushConfig.Json) |
|
| 499 |
+ sf = streamformatter.NewStreamFormatter(true) |
|
| 500 | 500 |
) |
| 501 | 501 |
|
| 502 | 502 |
// Resolve the Repository name from fqn to RepositoryInfo |
| ... | ... |
@@ -11,21 +11,6 @@ import ( |
| 11 | 11 |
"github.com/go-check/check" |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 |
-func (s *DockerSuite) TestLegacyImages(c *check.C) {
|
|
| 15 |
- status, body, err := sockRequest("GET", "/v1.6/images/json", nil)
|
|
| 16 |
- c.Assert(status, check.Equals, http.StatusOK) |
|
| 17 |
- c.Assert(err, check.IsNil) |
|
| 18 |
- |
|
| 19 |
- images := []types.LegacyImage{}
|
|
| 20 |
- if err = json.Unmarshal(body, &images); err != nil {
|
|
| 21 |
- c.Fatalf("Error on unmarshal: %s", err)
|
|
| 22 |
- } |
|
| 23 |
- |
|
| 24 |
- if len(images) == 0 || images[0].Tag == "" || images[0].Repository == "" {
|
|
| 25 |
- c.Fatalf("Bad data: %q", images)
|
|
| 26 |
- } |
|
| 27 |
-} |
|
| 28 |
- |
|
| 29 | 14 |
func (s *DockerSuite) TestApiImagesFilter(c *check.C) {
|
| 30 | 15 |
name := "utest:tag1" |
| 31 | 16 |
name2 := "utest/docker:tag2" |
| ... | ... |
@@ -18,40 +18,27 @@ func (s *DockerSuite) TestInspectApiContainerResponse(c *check.C) {
|
| 18 | 18 |
|
| 19 | 19 |
cleanedContainerID := strings.TrimSpace(out) |
| 20 | 20 |
|
| 21 |
- // test on json marshal version |
|
| 22 |
- // and latest version |
|
| 23 |
- testVersions := []string{"v1.11", "latest"}
|
|
| 24 |
- |
|
| 25 |
- for _, testVersion := range testVersions {
|
|
| 26 |
- endpoint := "/containers/" + cleanedContainerID + "/json" |
|
| 27 |
- if testVersion != "latest" {
|
|
| 28 |
- endpoint = "/" + testVersion + endpoint |
|
| 29 |
- } |
|
| 30 |
- status, body, err := sockRequest("GET", endpoint, nil)
|
|
| 31 |
- c.Assert(status, check.Equals, http.StatusOK) |
|
| 32 |
- c.Assert(err, check.IsNil) |
|
| 21 |
+ endpoint := "/containers/" + cleanedContainerID + "/json" |
|
| 22 |
+ status, body, err := sockRequest("GET", endpoint, nil)
|
|
| 23 |
+ c.Assert(status, check.Equals, http.StatusOK) |
|
| 24 |
+ c.Assert(err, check.IsNil) |
|
| 25 |
+ |
|
| 26 |
+ var inspectJSON map[string]interface{}
|
|
| 27 |
+ if err = json.Unmarshal(body, &inspectJSON); err != nil {
|
|
| 28 |
+ c.Fatalf("unable to unmarshal body for latest version: %v", err)
|
|
| 29 |
+ } |
|
| 33 | 30 |
|
| 34 |
- var inspectJSON map[string]interface{}
|
|
| 35 |
- if err = json.Unmarshal(body, &inspectJSON); err != nil {
|
|
| 36 |
- c.Fatalf("unable to unmarshal body for %s version: %v", testVersion, err)
|
|
| 37 |
- } |
|
| 31 |
+ keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW"}
|
|
| 38 | 32 |
|
| 39 |
- keys := []string{"State", "Created", "Path", "Args", "Config", "Image", "NetworkSettings", "ResolvConfPath", "HostnamePath", "HostsPath", "LogPath", "Name", "Driver", "ExecDriver", "MountLabel", "ProcessLabel", "Volumes", "VolumesRW"}
|
|
| 33 |
+ keys = append(keys, "Id") |
|
| 40 | 34 |
|
| 41 |
- if testVersion == "v1.11" {
|
|
| 42 |
- keys = append(keys, "ID") |
|
| 43 |
- } else {
|
|
| 44 |
- keys = append(keys, "Id") |
|
| 45 |
- } |
|
| 46 |
- |
|
| 47 |
- for _, key := range keys {
|
|
| 48 |
- if _, ok := inspectJSON[key]; !ok {
|
|
| 49 |
- c.Fatalf("%s does not exist in response for %s version", key, testVersion)
|
|
| 50 |
- } |
|
| 51 |
- } |
|
| 52 |
- //Issue #6830: type not properly converted to JSON/back |
|
| 53 |
- if _, ok := inspectJSON["Path"].(bool); ok {
|
|
| 54 |
- c.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
|
| 35 |
+ for _, key := range keys {
|
|
| 36 |
+ if _, ok := inspectJSON[key]; !ok {
|
|
| 37 |
+ c.Fatalf("%s does not exist in response for latest version", key)
|
|
| 55 | 38 |
} |
| 56 | 39 |
} |
| 40 |
+ //Issue #6830: type not properly converted to JSON/back |
|
| 41 |
+ if _, ok := inspectJSON["Path"].(bool); ok {
|
|
| 42 |
+ c.Fatalf("Path of `true` should not be converted to boolean `true` via JSON marshalling")
|
|
| 43 |
+ } |
|
| 57 | 44 |
} |