Skip to content

Commit

Permalink
bump go1.20.7 on release-1.10.0 base on ph4 (#19206)
Browse files Browse the repository at this point in the history
Signed-off-by: yminer <yminer@vmware.com>

add GOFLAGS=-buildvcs=false

upadate GO111MODULE=auto

Signed-off-by: yminer <yminer@vmware.com>

update ut_install set +e

fix gofmt

Signed-off-by: yminer <yminer@vmware.com>

update ut_run.sh
  • Loading branch information
MinerYang authored Aug 17, 2023
1 parent 31547ec commit 1788f8b
Show file tree
Hide file tree
Showing 52 changed files with 149 additions and 122 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions docs/compile_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions docs/use_make.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion make/photon/registry/Dockerfile.binary
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/chartserver/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/api/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/common/config/store/driver/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
34 changes: 17 additions & 17 deletions src/common/dao/dao_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
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 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)
}
}
}
*/
func TestGetProjectById(t *testing.T) {
id := currentProject.ProjectID
Expand Down
2 changes: 1 addition & 1 deletion src/common/utils/notary/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/log_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/models/admin_job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/project_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 21 additions & 17 deletions src/core/api/reg_gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
38 changes: 21 additions & 17 deletions src/core/api/scan_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/core/api/scanners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/core/api/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 1788f8b

Please sign in to comment.