@@ -49,6 +49,10 @@ type VerificationStatus struct {
49
49
Complete bool `json:"complete"`
50
50
}
51
51
52
+ func userAgent () string {
53
+ return fmt .Sprintf ("Cog/%s" , global .Version )
54
+ }
55
+
52
56
func FastPush (ctx context.Context , image string , projectDir string , command Command ) error {
53
57
g , _ := errgroup .WithContext (ctx )
54
58
@@ -193,6 +197,7 @@ func uploadFile(ctx context.Context, objectType string, digest string, path stri
193
197
return err
194
198
}
195
199
req .Header .Set ("Authorization" , "Bearer " + token )
200
+ req .Header .Set ("User-Agent" , userAgent ())
196
201
resp , err := client .Do (req )
197
202
if err != nil {
198
203
return err
@@ -202,7 +207,7 @@ func uploadFile(ctx context.Context, objectType string, digest string, path stri
202
207
// A conflict means we have already uploaded this file.
203
208
if resp .StatusCode == http .StatusConflict {
204
209
return nil
205
- } else if resp .StatusCode != http .StatusOK {
210
+ } else if resp .StatusCode != http .StatusOK && resp . StatusCode != http . StatusCreated {
206
211
return errors .New ("Bad response: " + strconv .Itoa (resp .StatusCode ))
207
212
}
208
213
@@ -225,6 +230,7 @@ func uploadFile(ctx context.Context, objectType string, digest string, path stri
225
230
console .Debug ("multi-part uploading file: " + path )
226
231
cfg := aws .NewConfig ()
227
232
cfg .BaseEndpoint = & data .Endpoint
233
+ cfg .Region = "auto"
228
234
cfg .Credentials = credentials.StaticCredentialsProvider {
229
235
Value : aws.Credentials {
230
236
AccessKeyID : data .AccessKeyId ,
@@ -255,6 +261,7 @@ func uploadFile(ctx context.Context, objectType string, digest string, path stri
255
261
return err
256
262
}
257
263
req .Header .Set ("Authorization" , "Bearer " + token )
264
+ req .Header .Set ("User-Agent" , userAgent ())
258
265
beginResp , err := client .Do (req )
259
266
if err != nil {
260
267
return err
@@ -270,6 +277,7 @@ func uploadFile(ctx context.Context, objectType string, digest string, path stri
270
277
return err
271
278
}
272
279
req .Header .Set ("Authorization" , "Bearer " + token )
280
+ req .Header .Set ("User-Agent" , userAgent ())
273
281
for i := 0 ; i < 100 ; i ++ {
274
282
final , err := checkVerificationStatus (req , client )
275
283
if final {
0 commit comments