From 5d59d6fab8e2bf732dba01e5a9a0d8b6b736265d Mon Sep 17 00:00:00 2001 From: Daniel Jiang Date: Mon, 26 Nov 2018 13:27:57 +0800 Subject: [PATCH] Bump up golang to 1.11.2 Signed-off-by: Daniel Jiang --- .travis.yml | 10 ++-- Makefile | 4 +- docs/compile_guide.md | 8 +-- docs/use_make.md | 4 +- make/photon/chartserver/builder | 2 +- make/photon/clair/Dockerfile.binary | 2 +- make/photon/clair/builder | 2 +- make/photon/notary/binary.Dockerfile | 2 +- make/photon/notary/builder | 2 +- make/photon/registry/Dockerfile.binary | 2 +- make/photon/registry/builder | 2 +- src/common/models/scan_job.go | 2 +- src/core/api/project_test.go | 4 +- src/core/api/target_test.go | 4 +- src/core/api/user_test.go | 56 +++++++++---------- src/core/config/config.go | 6 +- src/core/filter/security.go | 2 +- .../service/notifications/registry/handler.go | 2 +- .../imagestorage/filesystem/driver_test.go | 2 +- src/core/utils/job.go | 2 +- src/replication/trigger/manager.go | 2 +- tests/e2e-image/Dockerfile | 2 +- tests/travis/api_common_install.sh | 4 +- tests/travis/distro_installer.sh | 4 +- 24 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.travis.yml b/.travis.yml index 63c5a81e4..e0099564e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,23 @@ sudo: true language: go go: -- 1.9.2 +- 1.11.2 go_import_path: github.com/goharbor/harbor services: - docker dist: trusty matrix: include: - - go: 1.9.2 + - go: 1.11.2 env: - UTTEST=true - - go: 1.9.2 + - go: 1.11.2 env: - APITEST_DB=true - - go: 1.9.2 + - go: 1.11.2 env: - APITEST_LDAP=true - - go: 1.9.2 + - go: 1.11.2 env: - OFFLINE=true env: diff --git a/Makefile b/Makefile index e95515c98..7f9c7a51b 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ # compile_golangimage: # compile from golang image # for example: make compile_golangimage -e GOBUILDIMAGE= \ -# golang:1.7.3 +# golang:1.11.2 # compile_adminserver, compile_core, compile_jobservice: compile specific binary # # build: build Harbor docker images from photon baseimage @@ -124,7 +124,7 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOBUILDIMAGE=golang:1.9.2 +GOBUILDIMAGE=golang:1.11.2 GOBUILDPATH=$(GOBASEPATH)/harbor GOIMAGEBUILDCMD=/usr/local/go/bin/go GOIMAGEBUILD=$(GOIMAGEBUILDCMD) build diff --git a/docs/compile_guide.md b/docs/compile_guide.md index 34603131b..8886777fa 100644 --- a/docs/compile_guide.md +++ b/docs/compile_guide.md @@ -44,25 +44,25 @@ You can compile the code by one of the three approaches: * Get official Golang image from docker hub: ```sh - $ docker pull golang:1.9.2 + $ docker pull golang:1.11.2 ``` * Build, install and bring up Harbor without Notary: ```sh - $ make install GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage + $ make install GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage ``` * Build, install and bring up Harbor with Notary: ```sh - $ make install GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage NOTARYFLAG=true + $ make install GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage NOTARYFLAG=true ``` * Build, install and bring up Harbor with Clair: ```sh - $ make install GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage CLAIRFLAG=true + $ make install GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage CLAIRFLAG=true ``` #### II. Compile code with your own Golang environment, then build Harbor diff --git a/docs/use_make.md b/docs/use_make.md index 887598181..7fc98888d 100644 --- a/docs/use_make.md +++ b/docs/use_make.md @@ -37,10 +37,10 @@ version | set harbor version #### EXAMPLE: #### Build and run harbor from source code. -make install GOBUILDIMAGE=golang:1.7.3 COMPILETAG=compile_golangimage NOTARYFLAG=true +make install GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Package offline installer -make package_offline GOBUILDIMAGE=golang:1.7.3 COMPILETAG=compile_golangimage NOTARYFLAG=true +make package_offline GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Start harbor with notary make -e NOTARYFLAG=true start diff --git a/make/photon/chartserver/builder b/make/photon/chartserver/builder index 579eadf6b..ea7142075 100755 --- a/make/photon/chartserver/builder +++ b/make/photon/chartserver/builder @@ -4,7 +4,7 @@ set +e usage(){ echo "Usage: builder " - echo "e.g: builder golang:1.9.2 github.com/helm/chartmuseum v0.7.1 cmd/chartmuseum chartm" + echo "e.g: builder golang:1.11.2 github.com/helm/chartmuseum v0.7.1 cmd/chartmuseum chartm" exit 1 } diff --git a/make/photon/clair/Dockerfile.binary b/make/photon/clair/Dockerfile.binary index 87cf99fcf..d478e260f 100644 --- a/make/photon/clair/Dockerfile.binary +++ b/make/photon/clair/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.9.2 +FROM golang:1.11.2 ADD . /go/src/github.com/coreos/clair/ WORKDIR /go/src/github.com/coreos/clair/ diff --git a/make/photon/clair/builder b/make/photon/clair/builder index 860f5985b..16ae1118c 100755 --- a/make/photon/clair/builder +++ b/make/photon/clair/builder @@ -23,7 +23,7 @@ TEMP=`mktemp -d /$TMPDIR/clair.XXXXXX` git clone https://github.com/coreos/clair.git $TEMP cd $TEMP; git checkout $VERSION; cd - -echo 'build the clair binary bases on the golang:1.7.3...' +echo 'build the clair binary bases on the golang:1.11.2...' cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t clair-golang $TEMP diff --git a/make/photon/notary/binary.Dockerfile b/make/photon/notary/binary.Dockerfile index 1b9d73096..8c653197b 100644 --- a/make/photon/notary/binary.Dockerfile +++ b/make/photon/notary/binary.Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.9.4 +FROM golang:1.11.2 ENV NOTARYPKG github.com/theupdateframework/notary diff --git a/make/photon/notary/builder b/make/photon/notary/builder index 3dd5df358..88e6c8376 100755 --- a/make/photon/notary/builder +++ b/make/photon/notary/builder @@ -23,7 +23,7 @@ cur=$PWD TEMP=`mktemp -d /$TMPDIR/notary.XXXXXX` git clone -b $VERSION https://github.com/theupdateframework/notary.git $TEMP -echo 'build the notary binary bases on the golang:1.9.4...' +echo 'build the notary binary bases on the golang:1.11.2...' cp binary.Dockerfile $TEMP cd $TEMP docker build -f binary.Dockerfile -t notary-golang $TEMP diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index d9427e869..a8bc2f14a 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -7,4 +7,4 @@ WORKDIR $DISTRIBUTION_DIR COPY . $DISTRIBUTION_DIR COPY cmd/registry/config-dev.yml /etc/docker/registry/config.yml -RUN make PREFIX=/go clean binaries \ No newline at end of file +RUN make PREFIX=/go clean binaries diff --git a/make/photon/registry/builder b/make/photon/registry/builder index 902bb04ae..c249c1d09 100755 --- a/make/photon/registry/builder +++ b/make/photon/registry/builder @@ -22,7 +22,7 @@ cur=$PWD TEMP=`mktemp -d /$TMPDIR/distribution.XXXXXX` git clone -b $VERSION https://github.com/docker/distribution.git $TEMP -echo 'build the registry binary bases on the golang:1.7.3...' +echo 'build the registry binary bases on the golang:1.11.2...' cp Dockerfile.binary $TEMP docker build -f $TEMP/Dockerfile.binary -t registry-golang $TEMP diff --git a/src/common/models/scan_job.go b/src/common/models/scan_job.go index bb1db0f25..8a26fd741 100644 --- a/src/common/models/scan_job.go +++ b/src/common/models/scan_job.go @@ -115,7 +115,7 @@ type VulnerabilityItem struct { // ScanAllPolicy is represent the json request and object for scan all policy, the parm is het type ScanAllPolicy struct { Type string `json:"type"` - Parm map[string]interface{} `json:"parameter, omitempty"` + Parm map[string]interface{} `json:"parameter,omitempty"` } const ( diff --git a/src/core/api/project_test.go b/src/core/api/project_test.go index 59d2564a5..8f42ed35d 100644 --- a/src/core/api/project_test.go +++ b/src/core/api/project_test.go @@ -31,7 +31,7 @@ var addProject *apilib.ProjectReq var addPID int func InitAddPro() { - addProject = &apilib.ProjectReq{"add_project", map[string]string{models.ProMetaPublic: "true"}} + addProject = &apilib.ProjectReq{ProjectName: "add_project", Metadata: map[string]string{models.ProMetaPublic: "true"}} } func TestAddProject(t *testing.T) { @@ -82,7 +82,7 @@ func TestAddProject(t *testing.T) { // case 4: response code = 400 : Project name is illegal in length fmt.Println("case 4 : response code = 400 : Project name is illegal in length ") - result, err = apiTest.ProjectsPost(*admin, apilib.ProjectReq{"t", map[string]string{models.ProMetaPublic: "true"}}) + result, err = apiTest.ProjectsPost(*admin, apilib.ProjectReq{ProjectName: "t", Metadata: map[string]string{models.ProMetaPublic: "true"}}) if err != nil { t.Error("Error while creat project", err.Error()) t.Log(err) diff --git a/src/core/api/target_test.go b/src/core/api/target_test.go index af668cae5..142dae7fd 100644 --- a/src/core/api/target_test.go +++ b/src/core/api/target_test.go @@ -39,7 +39,7 @@ func TestTargetsPost(t *testing.T) { apiTest := newHarborAPI() endPoint := os.Getenv("REGISTRY_URL") - repTargets := &apilib.RepTargetPost{endPoint, addTargetName, adminName, adminPwd} + repTargets := &apilib.RepTargetPost{Endpoint: endPoint, Name: addTargetName, Username: adminName, Password: adminPwd} fmt.Println("Testing Targets Post API") @@ -195,7 +195,7 @@ func TestTargetsPut(t *testing.T) { apiTest := newHarborAPI() endPoint := "1.1.1.1" - updateRepTargets := &apilib.RepTargetPost{endPoint, addTargetName, adminName, adminPwd} + updateRepTargets := &apilib.RepTargetPost{Endpoint: endPoint, Name: addTargetName, Username: adminName, Password: adminPwd} id := strconv.Itoa(addTargetID) fmt.Println("Testing Target Put API") diff --git a/src/core/api/user_test.go b/src/core/api/user_test.go index 20fc8dc19..e309a9560 100644 --- a/src/core/api/user_test.go +++ b/src/core/api/user_test.go @@ -528,47 +528,47 @@ func TestModifiable(t *testing.T) { t.Log("Test modifiable.") assert := assert.New(t) base := BaseController{ - api.BaseAPI{ - beego.Controller{}, + BaseAPI: api.BaseAPI{ + Controller: beego.Controller{}, }, - nil, - nil, + SecurityCtx: nil, + ProjectMgr: nil, } ua1 := &UserAPI{ - base, - 3, - 4, - false, - false, - "db_auth", + BaseController: base, + currentUserID: 3, + userID: 4, + SelfRegistration: false, + IsAdmin: false, + AuthMode: "db_auth", } assert.False(ua1.modifiable()) ua2 := &UserAPI{ - base, - 3, - 4, - false, - true, - "db_auth", + BaseController: base, + currentUserID: 3, + userID: 4, + SelfRegistration: false, + IsAdmin: true, + AuthMode: "db_auth", } assert.True(ua2.modifiable()) ua3 := &UserAPI{ - base, - 3, - 4, - false, - true, - "ldap_auth", + BaseController: base, + currentUserID: 3, + userID: 4, + SelfRegistration: false, + IsAdmin: true, + AuthMode: "ldap_auth", } assert.False(ua3.modifiable()) ua4 := &UserAPI{ - base, - 1, - 1, - false, - true, - "ldap_auth", + BaseController: base, + currentUserID: 1, + userID: 1, + SelfRegistration: false, + IsAdmin: true, + AuthMode: "ldap_auth", } assert.True(ua4.modifiable()) } diff --git a/src/core/config/config.go b/src/core/config/config.go index 0d503b71a..7f00a40ce 100644 --- a/src/core/config/config.go +++ b/src/core/config/config.go @@ -317,7 +317,7 @@ func RegistryURL() (string, error) { func InternalJobServiceURL() string { cfg, err := mg.Get() if err != nil { - log.Warningf("Failed to Get job service URL from backend, error: %v, will return default value.") + log.Warningf("Failed to Get job service URL from backend, error: %v, will return default value.", err) return common.DefaultJobserviceEndpoint } @@ -331,7 +331,7 @@ func InternalJobServiceURL() string { func InternalCoreURL() string { cfg, err := mg.Get() if err != nil { - log.Warningf("Failed to Get job service Core URL from backend, error: %v, will return default value.") + log.Warningf("Failed to Get job service Core URL from backend, error: %v, will return default value.", err) return common.DefaultCoreEndpoint } return strings.TrimSuffix(utils.SafeCastString(cfg[common.CoreURL]), "/") @@ -348,7 +348,7 @@ func InternalTokenServiceEndpoint() string { func InternalNotaryEndpoint() string { cfg, err := mg.Get() if err != nil { - log.Warningf("Failed to get Notary endpoint from backend, error: %v, will use default value.") + log.Warningf("Failed to get Notary endpoint from backend, error: %v, will use default value.", err) return common.DefaultNotaryEndpoint } if cfg[common.NotaryURL] == nil { diff --git a/src/core/filter/security.go b/src/core/filter/security.go index 78ec48ba3..2374bdc65 100644 --- a/src/core/filter/security.go +++ b/src/core/filter/security.go @@ -240,7 +240,7 @@ func (s *sessionReqCtxModifier) Modify(ctx *beegoctx.Context) bool { log.Info("can not get user information from session") return false } - log.Debug("Getting user %+v", user) + log.Debugf("Getting user %+v", user) log.Debug("using local database project manager") pm := config.GlobalProjectMgr log.Debug("creating local database security context...") diff --git a/src/core/service/notifications/registry/handler.go b/src/core/service/notifications/registry/handler.go index cada29d85..1591ecae6 100644 --- a/src/core/service/notifications/registry/handler.go +++ b/src/core/service/notifications/registry/handler.go @@ -128,7 +128,7 @@ func (n *NotificationHandler) Post() { if err != nil { log.Errorf("Failed to get last update from Clair DB, error: %v, the auto scan will be skipped.", err) } else if last == 0 { - log.Infof("The Vulnerability data is not ready in Clair DB, the auto scan will be skipped.", err) + log.Infof("The Vulnerability data is not ready in Clair DB, the auto scan will be skipped.") } else if err := coreutils.TriggerImageScan(repository, tag); err != nil { log.Warningf("Failed to scan image, repository: %s, tag: %s, error: %v", repository, tag, err) } diff --git a/src/core/systeminfo/imagestorage/filesystem/driver_test.go b/src/core/systeminfo/imagestorage/filesystem/driver_test.go index 2e53dee3d..a9bd32b5b 100644 --- a/src/core/systeminfo/imagestorage/filesystem/driver_test.go +++ b/src/core/systeminfo/imagestorage/filesystem/driver_test.go @@ -39,5 +39,5 @@ func TestCapNonExistPath(t *testing.T) { driver := NewDriver(path) c, err := driver.Cap() assert.Nil(t, err, "unexpected error") - assert.Equal(t, storage.Capacity{0, 0}, *c) + assert.Equal(t, storage.Capacity{Total: 0, Free: 0}, *c) } diff --git a/src/core/utils/job.go b/src/core/utils/job.go index b157c49a1..735b33723 100644 --- a/src/core/utils/job.go +++ b/src/core/utils/job.go @@ -129,7 +129,7 @@ func triggerImageScan(repository, tag, digest string, client job.Client) error { } err = dao.SetScanJobUUID(id, uuid) if err != nil { - log.Warningf("Failed to set UUID for scan job, ID: %d, repository: %s, tag: %s", id, uuid, repository, tag) + log.Warningf("Failed to set UUID for scan job, ID: %d, repository: %s, tag: %s", id, repository, tag) } return nil } diff --git a/src/replication/trigger/manager.go b/src/replication/trigger/manager.go index 40bed8491..addeb7179 100644 --- a/src/replication/trigger/manager.go +++ b/src/replication/trigger/manager.go @@ -20,7 +20,7 @@ type Manager struct { // capacity is the max number of trigger references manager can keep in memory func NewManager(capacity int) *Manager { return &Manager{ - // cache: NewCache(capacity), + // cache: NewCache(capacity), } } diff --git a/tests/e2e-image/Dockerfile b/tests/e2e-image/Dockerfile index a1060fd4c..7345cc68f 100644 --- a/tests/e2e-image/Dockerfile +++ b/tests/e2e-image/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.8 +FROM golang:1.11.2 RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - RUN sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google.list' diff --git a/tests/travis/api_common_install.sh b/tests/travis/api_common_install.sh index 156e75cb5..a81629e65 100644 --- a/tests/travis/api_common_install.sh +++ b/tests/travis/api_common_install.sh @@ -25,5 +25,5 @@ sudo curl -o /home/travis/gopath/src/github.com/goharbor/harbor/tests/apitests/p sudo apt-get update && sudo apt-get install -y --no-install-recommends python-dev openjdk-7-jdk libssl-dev && sudo apt-get autoremove -y && sudo rm -rf /var/lib/apt/lists/* sudo wget https://bootstrap.pypa.io/get-pip.py && sudo python ./get-pip.py && sudo pip install --ignore-installed urllib3 chardet requests && sudo pip install robotframework==3.0.4 robotframework-httplibrary requests dbbot robotframework-pabot --upgrade sudo make swagger_client -sudo make install GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true -sleep 10 \ No newline at end of file +sudo make install GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true +sleep 10 diff --git a/tests/travis/distro_installer.sh b/tests/travis/distro_installer.sh index 06c81be49..f9a192a18 100755 --- a/tests/travis/distro_installer.sh +++ b/tests/travis/distro_installer.sh @@ -2,5 +2,5 @@ set -e -sudo make package_online VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= -sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.9.2 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= \ No newline at end of file +sudo make package_online VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY= +sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.11.2 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true HTTPPROXY=