Skip to content

Commit d985050

Browse files
author
shin-
committed
gofmt pass
1 parent 0c5e769 commit d985050

3 files changed

Lines changed: 19 additions & 19 deletions

File tree

image.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ func (img *Image) Checksum() (string, error) {
303303
return "", err
304304
}
305305

306-
hash := "sha256:"+hex.EncodeToString(h.Sum(nil))
306+
hash := "sha256:" + hex.EncodeToString(h.Sum(nil))
307307
if *checksums == nil {
308308
*checksums = map[string]string{}
309309
}

registry.go

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (graph *Graph) getRemoteHistory(imgId, registry string, token []string) ([]
4545
if err != nil {
4646
return nil, err
4747
}
48-
req.Header.Set("Authorization", "Token " + strings.Join(token, ", "))
48+
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
4949
res, err := client.Do(req)
5050
if err != nil || res.StatusCode != 200 {
5151
if res != nil {
@@ -90,7 +90,7 @@ func (graph *Graph) LookupRemoteImage(imgId, registry string, authConfig *auth.A
9090
}
9191

9292
func (graph *Graph) getImagesInRepository(repository string, authConfig *auth.AuthConfig) ([]map[string]string, error) {
93-
u := INDEX_ENDPOINT+"/repositories/"+repository+"/images"
93+
u := INDEX_ENDPOINT + "/repositories/" + repository + "/images"
9494
req, err := http.NewRequest("GET", u, nil)
9595
if err != nil {
9696
return nil, err
@@ -131,7 +131,7 @@ func (graph *Graph) getRemoteImage(stdout io.Writer, imgId, registry string, tok
131131
if err != nil {
132132
return nil, nil, fmt.Errorf("Failed to download json: %s", err)
133133
}
134-
req.Header.Set("Authorization", "Token " + strings.Join(token, ", "))
134+
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
135135
res, err := client.Do(req)
136136
if err != nil {
137137
return nil, nil, fmt.Errorf("Failed to download json: %s", err)
@@ -158,7 +158,7 @@ func (graph *Graph) getRemoteImage(stdout io.Writer, imgId, registry string, tok
158158
if err != nil {
159159
return nil, nil, fmt.Errorf("Error while getting from the server: %s\n", err)
160160
}
161-
req.Header.Set("Authorization", "Token " + strings.Join(token, ", "))
161+
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
162162
res, err = client.Do(req)
163163
if err != nil {
164164
return nil, nil, err
@@ -174,7 +174,7 @@ func (graph *Graph) getRemoteTags(stdout io.Writer, registries []string, reposit
174174
if err != nil {
175175
return nil, err
176176
}
177-
req.Header.Set("Authorization", "Token " + strings.Join(token, ", "))
177+
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
178178
res, err := client.Do(req)
179179
defer res.Body.Close()
180180
if err != nil || (res.StatusCode != 200 && res.StatusCode != 404) {
@@ -209,7 +209,7 @@ func (graph *Graph) getImageForTag(stdout io.Writer, tag, remote, registry strin
209209
if err != nil {
210210
return "", err
211211
}
212-
req.Header.Set("Authorization", "Token " + strings.Join(token, ", "))
212+
req.Header.Set("Authorization", "Token "+strings.Join(token, ", "))
213213
res, err := client.Do(req)
214214
if err != nil {
215215
return "", fmt.Errorf("Error while retrieving repository info: %v", err)
@@ -357,7 +357,7 @@ func pushImageRec(graph *Graph, stdout io.Writer, img *Image, registry string, t
357357
return err
358358
}
359359
req.Header.Add("Content-type", "application/json")
360-
req.Header.Set("Authorization", "Token " + strings.Join(token, ","))
360+
req.Header.Set("Authorization", "Token "+strings.Join(token, ","))
361361

362362
checksum, err := img.Checksum()
363363
if err != nil {
@@ -403,7 +403,7 @@ func pushImageRec(graph *Graph, stdout io.Writer, img *Image, registry string, t
403403

404404
req3.ContentLength = -1
405405
req3.TransferEncoding = []string{"chunked"}
406-
req3.Header.Set("Authorization", "Token " + strings.Join(token, ","))
406+
req3.Header.Set("Authorization", "Token "+strings.Join(token, ","))
407407
res3, err := doWithCookies(client, req3)
408408
if err != nil {
409409
return fmt.Errorf("Failed to upload layer: %s", err)
@@ -442,7 +442,7 @@ func (graph *Graph) pushTag(remote, revision, tag, registry string, token []stri
442442
return err
443443
}
444444
req.Header.Add("Content-type", "application/json")
445-
req.Header.Set("Authorization", "Token " + strings.Join(token, ","))
445+
req.Header.Set("Authorization", "Token "+strings.Join(token, ","))
446446
req.ContentLength = int64(len(revision))
447447
res, err := doWithCookies(client, req)
448448
if err != nil {
@@ -493,7 +493,6 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re
493493
return fmt.Errorf("Error occured while fetching the list: %v", err)
494494
}
495495

496-
497496
// Filter list to only send images/checksums not already uploaded
498497
i := 0
499498
for _, obj := range checksums {

utils.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,15 @@ func CopyEscapable(dst io.Writer, src io.ReadCloser) (written int64, err error)
397397
return written, err
398398
}
399399

400+
401+
func HashData(src io.Reader) (string, error) {
402+
h := sha256.New()
403+
if _, err := io.Copy(h, src); err != nil {
404+
return "", err
405+
}
406+
return "sha256:" + hex.EncodeToString(h.Sum(nil)), nil
407+
}
408+
400409
type KernelVersionInfo struct {
401410
Kernel int
402411
Major int
@@ -457,12 +466,4 @@ func FindCgroupMountpoint(cgroupType string) (string, error) {
457466
}
458467

459468
return "", fmt.Errorf("cgroup mountpoint not found for %s", cgroupType)
460-
}
461-
462-
func HashData(src io.Reader) (string, error) {
463-
h := sha256.New()
464-
if _, err := io.Copy(h, src); err != nil {
465-
return "", err
466-
}
467-
return "sha256:"+hex.EncodeToString(h.Sum(nil)), nil
468469
}

0 commit comments

Comments
 (0)