From b648084d95ef2fa691df53d47dcf4db376901ef3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=BE=B7?= Date: Mon, 8 Oct 2018 19:23:45 +0800 Subject: [PATCH] Improve code styles and fix after Harbor refactoring MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 陈德 --- docs/swagger.yaml | 4 ++-- src/common/models/retag.go | 4 ++-- src/common/models/retag_test.go | 4 ++-- src/common/utils/registry/auth/tokenauthorizer.go | 2 +- src/core/api/repository.go | 2 +- src/{ui => core}/utils/retag.go | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) rename src/{ui => core}/utils/retag.go (98%) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 0ca3f5c8c..795bcf2f8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -1139,7 +1139,7 @@ paths: parameters: - name: request in: body - description: reqeust to given source image and target tag + description: Request to give source image and target tag. required: true schema: $ref: '#/definitions/RetagReq' @@ -1149,7 +1149,7 @@ paths: '200': description: Image retag successfully. '400': - description: Invalid image values provided + description: Invalid image values provided. '401': description: User has no permission to the source project or destination project. '404': diff --git a/src/common/models/retag.go b/src/common/models/retag.go index 7f2951435..d684922b8 100644 --- a/src/common/models/retag.go +++ b/src/common/models/retag.go @@ -1,4 +1,4 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. +// Copyright Project Harbor Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -38,7 +38,7 @@ type Image struct { func ParseImage(image string) (*Image, error) { repo := strings.SplitN(image, "/", 2) if len(repo) < 2 { - return nil, fmt.Errorf("unable to parse image from string: %s", image) + return nil, fmt.Errorf("Unable to parse image from string: %s", image) } i := strings.SplitN(repo[1], ":", 2) res := &Image{ diff --git a/src/common/models/retag_test.go b/src/common/models/retag_test.go index 721d0a340..cf80a80d0 100644 --- a/src/common/models/retag_test.go +++ b/src/common/models/retag_test.go @@ -1,4 +1,4 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. +// Copyright Project Harbor Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -68,7 +68,7 @@ func TestParseImage(t *testing.T) { } } else { if err != nil { - t.Errorf("expect to parse %s fail, but not", c.Input) + t.Errorf("failed to parse image %s", c.Input) } } } diff --git a/src/common/utils/registry/auth/tokenauthorizer.go b/src/common/utils/registry/auth/tokenauthorizer.go index 1408ea11b..ccb4cca49 100644 --- a/src/common/utils/registry/auth/tokenauthorizer.go +++ b/src/common/utils/registry/auth/tokenauthorizer.go @@ -257,7 +257,7 @@ func ping(client *http.Client, endpoint string) (string, string, error) { } } - log.Warningf("schemas %v are unsupported", challenges) + log.Warningf("Schemas %v are unsupported", challenges) return "", "", nil } diff --git a/src/core/api/repository.go b/src/core/api/repository.go index 780e4d9bf..0802640be 100644 --- a/src/core/api/repository.go +++ b/src/core/api/repository.go @@ -491,7 +491,7 @@ func (ra *RepositoryAPI) Retag() { } // Retag the image - if err = uiutils.Retag(srcImage, &models.Image{ + if err = coreutils.Retag(srcImage, &models.Image{ Project: project, Repo: repo, Tag: request.Tag, diff --git a/src/ui/utils/retag.go b/src/core/utils/retag.go similarity index 98% rename from src/ui/utils/retag.go rename to src/core/utils/retag.go index 0394f0408..b53f5b713 100644 --- a/src/ui/utils/retag.go +++ b/src/core/utils/retag.go @@ -1,4 +1,4 @@ -// Copyright (c) 2017 VMware, Inc. All Rights Reserved. +// Copyright Project Harbor Authors // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License.