|
@@ -57,37 +57,35 @@ func (s *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrite
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if err == nil {
|
|
|
|
- if image != "" { //pull
|
|
|
|
- metaHeaders := map[string][]string{}
|
|
|
|
- for k, v := range r.Header {
|
|
|
|
- if strings.HasPrefix(k, "X-Meta-") {
|
|
|
|
- metaHeaders[k] = v
|
|
|
|
- }
|
|
|
|
|
|
+ if image != "" { //pull
|
|
|
|
+ metaHeaders := map[string][]string{}
|
|
|
|
+ for k, v := range r.Header {
|
|
|
|
+ if strings.HasPrefix(k, "X-Meta-") {
|
|
|
|
+ metaHeaders[k] = v
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- authEncoded := r.Header.Get("X-Registry-Auth")
|
|
|
|
- authConfig := &types.AuthConfig{}
|
|
|
|
- if 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 = &types.AuthConfig{}
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- err = s.backend.PullImage(ctx, image, tag, platform, metaHeaders, authConfig, output)
|
|
|
|
- } else { //import
|
|
|
|
- src := r.Form.Get("fromSrc")
|
|
|
|
- // 'err' MUST NOT be defined within this block, we need any error
|
|
|
|
- // generated from the download to be available to the output
|
|
|
|
- // stream processing below
|
|
|
|
- os := ""
|
|
|
|
- if platform != nil {
|
|
|
|
- os = platform.OS
|
|
|
|
|
|
+ authEncoded := r.Header.Get("X-Registry-Auth")
|
|
|
|
+ authConfig := &types.AuthConfig{}
|
|
|
|
+ if 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 = &types.AuthConfig{}
|
|
}
|
|
}
|
|
- err = s.backend.ImportImage(src, repo, os, tag, message, r.Body, output, r.Form["changes"])
|
|
|
|
}
|
|
}
|
|
|
|
+ err = s.backend.PullImage(ctx, image, tag, platform, metaHeaders, authConfig, output)
|
|
|
|
+ } else { //import
|
|
|
|
+ src := r.Form.Get("fromSrc")
|
|
|
|
+ // 'err' MUST NOT be defined within this block, we need any error
|
|
|
|
+ // generated from the download to be available to the output
|
|
|
|
+ // stream processing below
|
|
|
|
+ os := ""
|
|
|
|
+ if platform != nil {
|
|
|
|
+ os = platform.OS
|
|
|
|
+ }
|
|
|
|
+ err = s.backend.ImportImage(src, repo, os, tag, message, r.Body, output, r.Form["changes"])
|
|
}
|
|
}
|
|
if err != nil {
|
|
if err != nil {
|
|
if !output.Flushed() {
|
|
if !output.Flushed() {
|