@@ -89,21 +89,8 @@ func (s *router) postImagesCreate(ctx context.Context, w http.ResponseWriter, r
8989 repo = r .Form .Get ("repo" )
9090 tag = r .Form .Get ("tag" )
9191 message = r .Form .Get ("message" )
92- )
93- authEncoded := r .Header .Get ("X-Registry-Auth" )
94- authConfig := & types.AuthConfig {}
95- if authEncoded != "" {
96- authJSON := base64 .NewDecoder (base64 .URLEncoding , strings .NewReader (authEncoded ))
97- if err := json .NewDecoder (authJSON ).Decode (authConfig ); err != nil {
98- // for a pull it is not an error if no auth was given
99- // to increase compatibility with the existing api it is defaulting to be empty
100- authConfig = & types.AuthConfig {}
101- }
102- }
103-
104- var (
105- err error
106- output = ioutils .NewWriteFlusher (w )
92+ err error
93+ output = ioutils .NewWriteFlusher (w )
10794 )
10895 defer output .Close ()
10996
@@ -136,6 +123,17 @@ func (s *router) postImagesCreate(ctx context.Context, w http.ResponseWriter, r
136123 }
137124 }
138125
126+ authEncoded := r .Header .Get ("X-Registry-Auth" )
127+ authConfig := & types.AuthConfig {}
128+ if authEncoded != "" {
129+ authJSON := base64 .NewDecoder (base64 .URLEncoding , strings .NewReader (authEncoded ))
130+ if err := json .NewDecoder (authJSON ).Decode (authConfig ); err != nil {
131+ // for a pull it is not an error if no auth was given
132+ // to increase compatibility with the existing api it is defaulting to be empty
133+ authConfig = & types.AuthConfig {}
134+ }
135+ }
136+
139137 err = s .daemon .PullImage (ref , metaHeaders , authConfig , output )
140138 }
141139 }
0 commit comments