diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 94245934c..edce7125e 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -29,10 +29,10 @@ jobs: - ubuntu-latest timeout-minutes: 60 steps: - - name: Set up Go 1.17 + - name: Set up Go 1.20 uses: actions/setup-go@v1 with: - go-version: 1.17.9 + go-version: 1.20.7 id: go - name: setup Docker uses: docker-practice/actions-setup-docker@master @@ -95,10 +95,10 @@ jobs: - ubuntu-latest timeout-minutes: 60 steps: - - name: Set up Go 1.17 + - name: Set up Go 1.20 uses: actions/setup-go@v1 with: - go-version: 1.17.9 + go-version: 1.20.7 id: go - name: setup Docker uses: docker-practice/actions-setup-docker@master @@ -155,10 +155,10 @@ jobs: - ubuntu-latest timeout-minutes: 60 steps: - - name: Set up Go 1.17 + - name: Set up Go 1.20 uses: actions/setup-go@v1 with: - go-version: 1.17.9 + go-version: 1.20.7 id: go - name: setup Docker uses: docker-practice/actions-setup-docker@master @@ -213,10 +213,10 @@ jobs: - ubuntu-latest timeout-minutes: 60 steps: - - name: Set up Go 1.17 + - name: Set up Go 1.20 uses: actions/setup-go@v1 with: - go-version: 1.17.9 + go-version: 1.20.7 id: go - name: setup Docker uses: docker-practice/actions-setup-docker@master diff --git a/.github/workflows/build-package.yml b/.github/workflows/build-package.yml index ec54c61d1..b5daa78fd 100644 --- a/.github/workflows/build-package.yml +++ b/.github/workflows/build-package.yml @@ -28,7 +28,7 @@ jobs: - name: Set up Go 1.17 uses: actions/setup-go@v1 with: - go-version: 1.17.9 + go-version: 1.20.7 id: go - name: Setup Docker uses: docker-practice/actions-setup-docker@master diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 77d59bc4c..0adf724f2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -128,7 +128,7 @@ Harbor backend is written in [Go](http://golang.org/). If you don't have a Harbo | 1.7 | 1.9.2 | | 1.8 | 1.11.2 | | 1.9 | 1.12.12 | -| 1.10 | 1.17.9 | +| 1.10 | 1.20.7 | Ensure your GOPATH and PATH have been configured in accordance with the Go environment instructions. diff --git a/Makefile b/Makefile index 8118a3131..87b948389 100644 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ # compile_golangimage: # compile from golang image # for example: make compile_golangimage -e GOBUILDIMAGE= \ -# golang:1.17.9 +# golang:1.20.7 # compile_core, compile_jobservice: compile specific binary # # build: build Harbor docker images from photon baseimage @@ -137,14 +137,16 @@ GOINSTALL=$(GOCMD) install GOTEST=$(GOCMD) test GODEP=$(GOTEST) -i GOFMT=gofmt -w -GOBUILDIMAGE=golang:1.17.9 +GOVERSION=1.20.7 +GOBUILDIMAGE=goharbor/golang:$(GOVERSION) +PUSHGOIMAGE=false GOBUILDPATH=/harbor # go build PKG_PATH=github.com/goharbor/harbor/src/pkg GITCOMMIT := $(shell git rev-parse --short=8 HEAD) RELEASEVERSION := $(shell cat VERSION) -GOFLAGS= +GOFLAGS="-buildvcs=false" GOTAGS=$(if $(GOBUILDTAGS),-tags "$(GOBUILDTAGS)",) GOLDFLAGS=$(if $(GOBUILDLDFLAGS),--ldflags "-w -s $(GOBUILDLDFLAGS)",) CORE_LDFLAGS=-X $(PKG_PATH)/version.GitCommit=$(GITCOMMIT) -X $(PKG_PATH)/version.ReleaseVersion=$(RELEASEVERSION) @@ -384,6 +386,15 @@ package_offline: update_prepare_version compile build @rm -rf $(HARBORPKG) @echo "Done." +build_golang: + @echo "build goharbor/golang image" + $(DOCKERBUILD) --build-arg GOVERSION=$(GOVERSION) -f $(MAKEPATH)/photon/golang/Dockerfile -t $(GOBUILDIMAGE) . + @if [ "$(PUSHGOIMAGE)" = "true" ] ; then \ + echo "push goharbor/golang image"; \ + docker login -u $(REGISTRYUSER) -p $(REGISTRYPASSWORD) ; \ + docker push $(GOBUILDIMAGE); \ + fi; \ + gosec: #go get github.com/securego/gosec/cmd/gosec #go get github.com/dghubble/sling diff --git a/docs/compile_guide.md b/docs/compile_guide.md index 144bb8724..d2e920a3f 100644 --- a/docs/compile_guide.md +++ b/docs/compile_guide.md @@ -43,13 +43,13 @@ You can compile the code by one of the three approaches: - Get official Golang image from docker hub: ```sh - $ docker pull golang:1.17.9 + $ docker pull goharbor/golang:1.20.7 ``` - Build, install and bring up Harbor without Notary: ```sh - $ make install GOBUILDIMAGE=golang:1.17.9 COMPILETAG=compile_golangimage + $ make install GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage ``` - Build, install and bring up Harbor with Notary: diff --git a/docs/use_make.md b/docs/use_make.md index 8f84ad4ff..55c30db4f 100644 --- a/docs/use_make.md +++ b/docs/use_make.md @@ -36,10 +36,10 @@ version | set harbor version #### EXAMPLE: #### Build and run harbor from source code. -make install GOBUILDIMAGE=golang:1.17.9 COMPILETAG=compile_golangimage NOTARYFLAG=true +make install GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Package offline installer -make package_offline GOBUILDIMAGE=golang:1.17.9 COMPILETAG=compile_golangimage NOTARYFLAG=true +make package_offline GOBUILDIMAGE=golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true ### Start harbor with notary make -e NOTARYFLAG=true start diff --git a/make/photon/registry/Dockerfile.binary b/make/photon/registry/Dockerfile.binary index 71c6b6484..b3a05c1f8 100644 --- a/make/photon/registry/Dockerfile.binary +++ b/make/photon/registry/Dockerfile.binary @@ -1,4 +1,4 @@ -FROM golang:1.17.9 +FROM goharbor/golang:1.20.7 ENV DISTRIBUTION_DIR /go/src/github.com/docker/distribution ENV BUILDTAGS include_oss include_gcs diff --git a/src/chartserver/cache.go b/src/chartserver/cache.go index 065614ee6..1c622bacb 100644 --- a/src/chartserver/cache.go +++ b/src/chartserver/cache.go @@ -84,8 +84,9 @@ func NewChartCache(config *ChartCacheConfig) *ChartCache { // IsEnabled to indicate if the chart cache is successfully enabled // The cache may be disabled if -// user does not set -// wrong configurations +// +// user does not set +// wrong configurations func (chc *ChartCache) IsEnabled() bool { return chc.isEnabled } diff --git a/src/common/api/base_test.go b/src/common/api/base_test.go index 1fb2b69fc..24d91bb64 100644 --- a/src/common/api/base_test.go +++ b/src/common/api/base_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/common/config/store/driver/db_test.go b/src/common/config/store/driver/db_test.go index 44f313107..8839f0d9d 100644 --- a/src/common/config/store/driver/db_test.go +++ b/src/common/config/store/driver/db_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/common/dao/dao_test.go b/src/common/dao/dao_test.go index 6374fbb4f..c86398154 100644 --- a/src/common/dao/dao_test.go +++ b/src/common/dao/dao_test.go @@ -539,24 +539,24 @@ func TestCountPull(t *testing.T) { } /* -func TestProjectExists(t *testing.T) { - var exists bool - var err error - exists, err = ProjectExists(currentProject.ProjectID) - if err != nil { - t.Errorf("Error occurred in ProjectExists: %v", err) + func TestProjectExists(t *testing.T) { + var exists bool + var err error + exists, err = ProjectExists(currentProject.ProjectID) + if err != nil { + t.Errorf("Error occurred in ProjectExists: %v", err) + } + if !exists { + t.Errorf("The project with id: %d, does not exist", currentProject.ProjectID) + } + exists, err = ProjectExists(currentProject.Name) + if err != nil { + t.Errorf("Error occurred in ProjectExists: %v", err) + } + if !exists { + t.Errorf("The project with name: %s, does not exist", currentProject.Name) + } } - if !exists { - t.Errorf("The project with id: %d, does not exist", currentProject.ProjectID) - } - exists, err = ProjectExists(currentProject.Name) - if err != nil { - t.Errorf("Error occurred in ProjectExists: %v", err) - } - if !exists { - t.Errorf("The project with name: %s, does not exist", currentProject.Name) - } -} */ func TestGetProjectById(t *testing.T) { id := currentProject.ProjectID diff --git a/src/common/utils/notary/helper_test.go b/src/common/utils/notary/helper_test.go index 8a2a069ae..16ff0198b 100644 --- a/src/common/utils/notary/helper_test.go +++ b/src/common/utils/notary/helper_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/api_test.go b/src/core/api/api_test.go index 30730ae7a..274ef226e 100644 --- a/src/core/api/api_test.go +++ b/src/core/api/api_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/log_test.go b/src/core/api/log_test.go index 62837ec5c..d1646eab5 100644 --- a/src/core/api/log_test.go +++ b/src/core/api/log_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/models/admin_job_test.go b/src/core/api/models/admin_job_test.go index 3a149fe12..79d223741 100644 --- a/src/core/api/models/admin_job_test.go +++ b/src/core/api/models/admin_job_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/project_test.go b/src/core/api/project_test.go index f673466c0..f2dd45f05 100644 --- a/src/core/api/project_test.go +++ b/src/core/api/project_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/reg_gc.go b/src/core/api/reg_gc.go index 031d7249d..28953e9e6 100644 --- a/src/core/api/reg_gc.go +++ b/src/core/api/reg_gc.go @@ -44,18 +44,21 @@ func (gc *GCAPI) Prepare() { // Post according to the request, it creates a cron schedule or a manual trigger for GC. // create a daily schedule for GC -// { -// "schedule": { -// "type": "Daily", -// "cron": "0 0 0 * * *" -// } -// } +// +// { +// "schedule": { +// "type": "Daily", +// "cron": "0 0 0 * * *" +// } +// } +// // create a manual trigger for GC -// { -// "schedule": { -// "type": "Manual" -// } -// } +// +// { +// "schedule": { +// "type": "Manual" +// } +// } func (gc *GCAPI) Post() { ajr := models.AdminJobReq{} isValid, err := gc.DecodeJSONReqAndValidate(&ajr) @@ -73,12 +76,13 @@ func (gc *GCAPI) Post() { // Put handles GC cron schedule update/delete. // Request: delete the schedule of GC -// { -// "schedule": { -// "type": "None", -// "cron": "" -// } -// } +// +// { +// "schedule": { +// "type": "None", +// "cron": "" +// } +// } func (gc *GCAPI) Put() { ajr := models.AdminJobReq{} isValid, err := gc.DecodeJSONReqAndValidate(&ajr) diff --git a/src/core/api/repository_test.go b/src/core/api/repository_test.go index 6acc27b35..9a55d6808 100644 --- a/src/core/api/repository_test.go +++ b/src/core/api/repository_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/scan_all.go b/src/core/api/scan_all.go index 31d4d76fa..11a99f9ac 100644 --- a/src/core/api/scan_all.go +++ b/src/core/api/scan_all.go @@ -49,18 +49,21 @@ func (sc *ScanAllAPI) Prepare() { // Post according to the request, it creates a cron schedule or a manual trigger for scan all. // create a daily schedule for scan all -// { -// "schedule": { -// "type": "Daily", -// "cron": "0 0 0 * * *" -// } -// } +// +// { +// "schedule": { +// "type": "Daily", +// "cron": "0 0 0 * * *" +// } +// } +// // create a manual trigger for scan all -// { -// "schedule": { -// "type": "Manual" -// } -// } +// +// { +// "schedule": { +// "type": "Manual" +// } +// } func (sc *ScanAllAPI) Post() { ajr := models.AdminJobReq{} isValid, err := sc.DecodeJSONReqAndValidate(&ajr) @@ -75,12 +78,13 @@ func (sc *ScanAllAPI) Post() { // Put handles scan all cron schedule update/delete. // Request: delete the schedule of scan all -// { -// "schedule": { -// "type": "None", -// "cron": "" -// } -// } +// +// { +// "schedule": { +// "type": "None", +// "cron": "" +// } +// } func (sc *ScanAllAPI) Put() { ajr := models.AdminJobReq{} isValid, err := sc.DecodeJSONReqAndValidate(&ajr) diff --git a/src/core/api/scanners_test.go b/src/core/api/scanners_test.go index 231403c2a..3dd1ff95a 100644 --- a/src/core/api/scanners_test.go +++ b/src/core/api/scanners_test.go @@ -217,7 +217,6 @@ func (suite *ScannerAPITestSuite) TestScannerAPIUpdate() { assert.Equal(suite.T(), updated.UUID, rr.UUID) } -// func (suite *ScannerAPITestSuite) TestScannerAPIDelete() { r := &scanner.Registration{ ID: 1003, diff --git a/src/core/api/search_test.go b/src/core/api/search_test.go index 9f6a32d27..c288fefb0 100644 --- a/src/core/api/search_test.go +++ b/src/core/api/search_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/statistic_test.go b/src/core/api/statistic_test.go index 5c9be4229..fe4fe49d8 100644 --- a/src/core/api/statistic_test.go +++ b/src/core/api/statistic_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/sys_cve_whitelist_test.go b/src/core/api/sys_cve_whitelist_test.go index 6580721e1..62c191e72 100644 --- a/src/core/api/sys_cve_whitelist_test.go +++ b/src/core/api/sys_cve_whitelist_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/systeminfo_test.go b/src/core/api/systeminfo_test.go index 72327f6b3..bb70dc455 100644 --- a/src/core/api/systeminfo_test.go +++ b/src/core/api/systeminfo_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/api/user_test.go b/src/core/api/user_test.go index 8ff9c2d55..b5301854d 100644 --- a/src/core/api/user_test.go +++ b/src/core/api/user_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/auth/auth_test.go b/src/core/auth/auth_test.go index 3b8b27ee5..7abf0b640 100644 --- a/src/core/auth/auth_test.go +++ b/src/core/auth/auth_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/auth/db/db_test.go b/src/core/auth/db/db_test.go index ec3ffd2b4..d360c60c9 100644 --- a/src/core/auth/db/db_test.go +++ b/src/core/auth/db/db_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/auth/ldap/ldap_test.go b/src/core/auth/ldap/ldap_test.go index fb086a88b..4b656f2d3 100644 --- a/src/core/auth/ldap/ldap_test.go +++ b/src/core/auth/ldap/ldap_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/config/config_test.go b/src/core/config/config_test.go index 4e0e233c1..26c4f4007 100644 --- a/src/core/config/config_test.go +++ b/src/core/config/config_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/controllers/controllers_test.go b/src/core/controllers/controllers_test.go index fbe5befd1..05b0b1711 100644 --- a/src/core/controllers/controllers_test.go +++ b/src/core/controllers/controllers_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/middlewares/util/util.go b/src/core/middlewares/util/util.go index 80ccacb7e..2f87fa734 100644 --- a/src/core/middlewares/util/util.go +++ b/src/core/middlewares/util/util.go @@ -333,7 +333,8 @@ func CopyResp(rec *httptest.ResponseRecorder, rw http.ResponseWriter) { // PolicyChecker checks the policy of a project by project name, to determine if it's needed to check the image's status under this project. // TODO: The policy check related things should be moved to pkg package later -// and refactored to include the `check` capabilities, not just property getters. +// +// and refactored to include the `check` capabilities, not just property getters. type PolicyChecker interface { // contentTrustEnabled returns whether a project has enabled content trust. ContentTrustEnabled(name string) bool diff --git a/src/core/service/token/token_test.go b/src/core/service/token/token_test.go index 24ce6064d..2162af057 100644 --- a/src/core/service/token/token_test.go +++ b/src/core/service/token/token_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/utils/response_handlers_test.go b/src/core/utils/response_handlers_test.go index b501a495d..e46841339 100644 --- a/src/core/utils/response_handlers_test.go +++ b/src/core/utils/response_handlers_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/core/utils/utils_test.go b/src/core/utils/utils_test.go index 4988722f7..b5277a5ce 100644 --- a/src/core/utils/utils_test.go +++ b/src/core/utils/utils_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/api/handler_test.go b/src/jobservice/api/handler_test.go index f0adc3a47..2497123d8 100644 --- a/src/jobservice/api/handler_test.go +++ b/src/jobservice/api/handler_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/config/config_test.go b/src/jobservice/config/config_test.go index d6676b2e6..f356fe984 100644 --- a/src/jobservice/config/config_test.go +++ b/src/jobservice/config/config_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/core/controller_test.go b/src/jobservice/core/controller_test.go index d8bc11bb9..8ad0afc83 100644 --- a/src/jobservice/core/controller_test.go +++ b/src/jobservice/core/controller_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/hook/hook_client_test.go b/src/jobservice/hook/hook_client_test.go index 91bdc004e..5aaa1e0de 100644 --- a/src/jobservice/hook/hook_client_test.go +++ b/src/jobservice/hook/hook_client_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/job/impl/utils/utils_test.go b/src/jobservice/job/impl/utils/utils_test.go index a950ea228..b02049ee3 100644 --- a/src/jobservice/job/impl/utils/utils_test.go +++ b/src/jobservice/job/impl/utils/utils_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/logger/base.go b/src/jobservice/logger/base.go index fc114826f..d4e858c4b 100644 --- a/src/jobservice/logger/base.go +++ b/src/jobservice/logger/base.go @@ -22,7 +22,7 @@ var singletons sync.Map // GetLogger gets an unified logger entry for logging per the passed settings. // The logger may built based on the multiple registered logger backends. // -// loggerOptions ...Option : logger options +// loggerOptions ...Option : logger options // // If failed, a nil logger and a non-nil error will be returned. // Otherwise, a non nil logger is returned with nil error. @@ -125,11 +125,13 @@ func GetSweeper(context context.Context, sweeperOptions ...Option) (sweeper.Inte // GetLogDataGetter return the 1st matched log data getter interface // -// loggerOptions ...Option : logger options +// loggerOptions ...Option : logger options // // If failed, -// configured but initialize failed: a nil log data getter and a non-nil error will be returned. -// no getter configured: a nil log data getter with a nil error are returned +// +// configured but initialize failed: a nil log data getter and a non-nil error will be returned. +// no getter configured: a nil log data getter with a nil error are returned +// // Otherwise, a non nil log data getter is returned with nil error. func GetLogDataGetter(loggerOptions ...Option) (getter.Interface, error) { if len(loggerOptions) == 0 { diff --git a/src/jobservice/period/basic_scheduler_test.go b/src/jobservice/period/basic_scheduler_test.go index 7beaecea3..9cf568dc5 100644 --- a/src/jobservice/period/basic_scheduler_test.go +++ b/src/jobservice/period/basic_scheduler_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/period/enqueuer_test.go b/src/jobservice/period/enqueuer_test.go index 8b38bde22..6445e82e6 100644 --- a/src/jobservice/period/enqueuer_test.go +++ b/src/jobservice/period/enqueuer_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/period/policy_store_test.go b/src/jobservice/period/policy_store_test.go index c696b0b20..f50556ab4 100644 --- a/src/jobservice/period/policy_store_test.go +++ b/src/jobservice/period/policy_store_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/runner/redis_test.go b/src/jobservice/runner/redis_test.go index 9566692d4..60039f5cf 100644 --- a/src/jobservice/runner/redis_test.go +++ b/src/jobservice/runner/redis_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/jobservice/worker/cworker/c_worker_test.go b/src/jobservice/worker/cworker/c_worker_test.go index be7931c17..26008e9f9 100644 --- a/src/jobservice/worker/cworker/c_worker_test.go +++ b/src/jobservice/worker/cworker/c_worker_test.go @@ -4,7 +4,7 @@ // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // -// http://www.apache.org/licenses/LICENSE-2.0 +// http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, diff --git a/src/pkg/scan/api/scan/controller.go b/src/pkg/scan/api/scan/controller.go index 38c3fff5a..ec1a572d2 100644 --- a/src/pkg/scan/api/scan/controller.go +++ b/src/pkg/scan/api/scan/controller.go @@ -24,7 +24,8 @@ import ( // Controller provides the related operations for triggering scan. // TODO: Here the artifact object is reused the v1 one which is sent to the adapter, -// it should be pointed to the general artifact object in future once it's ready. +// +// it should be pointed to the general artifact object in future once it's ready. type Controller interface { // Scan the given artifact // diff --git a/src/pkg/scan/rest/v1/models.go b/src/pkg/scan/rest/v1/models.go index 4156fee50..d69bdd2fb 100644 --- a/src/pkg/scan/rest/v1/models.go +++ b/src/pkg/scan/rest/v1/models.go @@ -37,12 +37,12 @@ type Scanner struct { // report MIME types. For example, a scanner capable of analyzing Docker images and producing // a vulnerabilities report recognizable by Harbor web console might be represented with the // following capability: -// - consumes MIME types: -// -- application/vnd.oci.image.manifest.v1+json -// -- application/vnd.docker.distribution.manifest.v2+json -// - produces MIME types -// -- application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0 -// -- application/vnd.scanner.adapter.vuln.report.raw +// - consumes MIME types: +// -- application/vnd.oci.image.manifest.v1+json +// -- application/vnd.docker.distribution.manifest.v2+json +// - produces MIME types +// -- application/vnd.scanner.adapter.vuln.report.harbor+json; version=1.0 +// -- application/vnd.scanner.adapter.vuln.report.raw type ScannerCapability struct { // The set of MIME types of the artifacts supported by the scanner to produce the reports // specified in the "produces_mime_types". A given mime type should only be present in one diff --git a/src/replication/dao/execution.go b/src/replication/dao/execution.go index c1ff85490..2c5c0970e 100644 --- a/src/replication/dao/execution.go +++ b/src/replication/dao/execution.go @@ -319,9 +319,11 @@ func UpdateTask(task *models.Task, props ...string) (int64, error) { // UpdateTaskStatus updates the status of task. // The implementation uses raw sql rather than QuerySetter.Filter... as QuerySetter // will generate sql like: -// `UPDATE "replication_task" SET "end_time" = $1, "status" = $2 -// WHERE "id" IN ( SELECT T0."id" FROM "replication_task" T0 WHERE T0."id" = $3 -// AND T0."status" IN ($4, $5, $6))]` +// +// `UPDATE "replication_task" SET "end_time" = $1, "status" = $2 +// WHERE "id" IN ( SELECT T0."id" FROM "replication_task" T0 WHERE T0."id" = $3 +// AND T0."status" IN ($4, $5, $6))]` +// // which is not a "single" sql statement, this will cause issues when running in concurrency func UpdateTaskStatus(id int64, status string, statusRevision int64, statusCondition ...string) (int64, error) { params := []interface{}{} diff --git a/tests/ci/api_common_install.sh b/tests/ci/api_common_install.sh index 1daf8ffad..355fed84c 100755 --- a/tests/ci/api_common_install.sh +++ b/tests/ci/api_common_install.sh @@ -57,5 +57,5 @@ pip -V #sudo apt-get update && sudo apt-get install -y --no-install-recommends 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 --upgrade sudo make build_base_images -e BASEIMAGETAG=dev -sudo make install GOBUILDIMAGE=golang:1.17.9 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true BUILDBIN=true PULL_BASE_FROM_DOCKERHUB=false +sudo make install GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage CLARITYIMAGE=goharbor/harbor-clarity-ui-builder:1.6.0 NOTARYFLAG=true CLAIRFLAG=true CHARTFLAG=true BUILDBIN=true PULL_BASE_FROM_DOCKERHUB=false sleep 10 diff --git a/tests/ci/distro_installer.sh b/tests/ci/distro_installer.sh index 5c7d7dc97..3c9fa8b5d 100755 --- a/tests/ci/distro_installer.sh +++ b/tests/ci/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.17.9 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true BUILDBIN=true HTTPPROXY= -sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=golang:1.17.9 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true BUILDBIN=true HTTPPROXY= +sudo make package_online VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true BUILDBIN=true HTTPPROXY= +sudo make package_offline VERSIONTAG=dev-travis PKGVERSIONTAG=dev-travis UIVERSIONTAG=dev-travis GOBUILDIMAGE=goharbor/golang:1.20.7 COMPILETAG=compile_golangimage NOTARYFLAG=true CLAIRFLAG=true MIGRATORFLAG=false CHARTFLAG=true BUILDBIN=true HTTPPROXY= diff --git a/tests/ci/ut_install.sh b/tests/ci/ut_install.sh index 4ee841337..79b4fe062 100755 --- a/tests/ci/ut_install.sh +++ b/tests/ci/ut_install.sh @@ -3,15 +3,18 @@ set -ex sudo apt-get update && sudo apt-get install -y libldap2-dev +sudo go env -w GO111MODULE=auto go get -d github.com/docker/distribution go get -d github.com/docker/libtrust go get -d github.com/lib/pq go get golang.org/x/lint/golint go get github.com/GeertJohan/fgt go get github.com/dghubble/sling +set +e go get golang.org/x/tools/cmd/cover go get github.com/mattn/goveralls go get -u github.com/client9/misspell/cmd/misspell +set -e sudo service postgresql stop || echo no postgresql need to be stopped sleep 2 diff --git a/tests/ci/ut_run.sh b/tests/ci/ut_run.sh index f224a6c46..09c7289c8 100755 --- a/tests/ci/ut_run.sh +++ b/tests/ci/ut_run.sh @@ -14,6 +14,5 @@ sleep 10 docker ps DIR="$(cd "$(dirname "$0")" && pwd)" -go test -race -i ./src/core ./src/jobservice sudo -E env "PATH=$PATH" "POSTGRES_MIGRATION_SCRIPTS_PATH=$DIR/../../make/migrations/postgresql/" ./tests/coverage4gotest.sh #goveralls -coverprofile=profile.cov -service=travis-ci || true \ No newline at end of file