diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index bd065163..8a6c865e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,10 +1,10 @@ name: Bug report description: File a bug report -title: "[Bug]: " -labels: bug +title: "[Bug]: " +labels: ["bug"] body: - type: input - attributes: + attributes: label: "zot version" placeholder: "v1.4.3 or commit hash" validations: @@ -23,12 +23,12 @@ body: 1. Configuration 2. Client tool used 3. Seen error - + - type: textarea attributes: label: "Expected behavior" description: "A clear and concise description of what you expected to happen." - + - type: textarea attributes: label: "Screenshots" diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index bb1ec435..4661396b 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -1,7 +1,7 @@ name: Feature request description: Request a feature title: "[Feat]: " -labels: feature +labels: ["feature"] body: - type: textarea attributes: diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7364d725..6ba2e597 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -88,11 +88,11 @@ jobs: pip install localstack # Install LocalStack cli docker pull localstack/localstack:1.3 # Make sure to pull the latest version of the image localstack start -d # Start LocalStack in the background - + echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container - localstack wait -t 30 # to become ready before timing out + localstack wait -t 30 # to become ready before timing out echo "Startup complete" - + aws --endpoint-url=http://localhost:4566 s3api create-bucket --bucket zot-storage --region us-east-2 --create-bucket-configuration="{\"LocationConstraint\": \"us-east-2\"}" aws dynamodb --endpoint-url http://localhost:4566 --region "us-east-2" create-table --table-name BlobTable --attribute-definitions AttributeName=Digest,AttributeType=S --key-schema AttributeName=Digest,KeyType=HASH --provisioned-throughput ReadCapacityUnits=10,WriteCapacityUnits=5 env: diff --git a/.github/workflows/cluster.yaml b/.github/workflows/cluster.yaml index 333d38d9..0e331cf4 100644 --- a/.github/workflows/cluster.yaml +++ b/.github/workflows/cluster.yaml @@ -35,7 +35,7 @@ jobs: - name: Install dependencies run: | cd $GITHUB_WORKSPACE - go install github.com/swaggo/swag/cmd/swag + go install github.com/swaggo/swag/cmd/swag@v1.8.12 go mod download sudo apt-get update sudo apt-get -y install rpm uidmap @@ -56,7 +56,7 @@ jobs: minio/minio:edge-cicd server /data - name: Install py minio run: pip3 install minio - + - name: Wait for minio to come up run: | curl --connect-timeout 5 \ @@ -64,7 +64,7 @@ jobs: --retry 12 \ --retry-max-time 120 \ 'http://localhost:9000/minio/health/live' - + - name: Create minio bucket run: | python3 - <<'EOF' @@ -88,7 +88,7 @@ jobs: run: | sudo haproxy -d -f examples/cluster/haproxy.cfg -D sleep 10 - + - name: Prepare configuration files run: | cp test/cluster/config-minio.json test/cluster/config-minio1.json @@ -96,7 +96,7 @@ jobs: cp test/cluster/config-minio.json test/cluster/config-minio2.json sed -i 's/8082/8083/g' test/cluster/config-minio.json cp test/cluster/config-minio.json test/cluster/config-minio3.json - + - name: Run push-pull tests run: | make binary @@ -124,7 +124,7 @@ jobs: env: AWS_ACCESS_KEY_ID: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin - + - name: Run benchmark with --src-cidr arg run: | make bench @@ -142,7 +142,7 @@ jobs: env: AWS_ACCESS_KEY_ID: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin - + - name: Run benchmark with --src-ips arg run: | make bench @@ -152,12 +152,12 @@ jobs: sleep 10 # run zb with --src-ips bin/zb-linux-amd64 -c 10 -n 50 -o ci-cd --src-ips 127.0.0.2,127.0.0.3,127.0.0.4,127.0.0.5,127.0.0.6,127.0.12.5,127.0.12.6 http://localhost:8080 - + killall -r zot-* env: AWS_ACCESS_KEY_ID: minioadmin AWS_SECRET_ACCESS_KEY: minioadmin - + # Download previous benchmark result from cache (if exists) - name: Download previous benchmark data uses: actions/cache@v3 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1939f9ff..832ab573 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -54,7 +54,7 @@ jobs: - name: Install dependencies run: | cd $GITHUB_WORKSPACE - go install github.com/swaggo/swag/cmd/swag@latest + go install github.com/swaggo/swag/cmd/swag@v1.8.12 go mod download go install github.com/wadey/gocovmerge@latest go get -u github.com/swaggo/swag/cmd/swag diff --git a/.github/workflows/ecosystem-tools.yaml b/.github/workflows/ecosystem-tools.yaml index 38724d73..1761ce06 100644 --- a/.github/workflows/ecosystem-tools.yaml +++ b/.github/workflows/ecosystem-tools.yaml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | cd $GITHUB_WORKSPACE - go install github.com/swaggo/swag/cmd/swag + go install github.com/swaggo/swag/cmd/swag@v1.8.12 go mod download sudo apt-get update sudo apt-get install libgpgme-dev libassuan-dev libbtrfs-dev libdevmapper-dev pkg-config rpm uidmap @@ -72,7 +72,7 @@ jobs: run: | make test-bats-referrers - name: Run metadata tests - run: | + run: | make test-bats-metadata - name: Run push-pull tests run: | @@ -101,10 +101,10 @@ jobs: pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal docker pull localstack/localstack # Make sure to pull the latest version of the image localstack start -d # Start LocalStack in the background - + echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container - localstack wait -t 30 # to become ready before timing out - echo "Startup complete" + localstack wait -t 30 # to become ready before timing out + echo "Startup complete" - name: Run cloud-only tests run: | make test-cloud-only diff --git a/.github/workflows/gc-stress-test.yaml b/.github/workflows/gc-stress-test.yaml index 0f62bc3c..fe80e987 100644 --- a/.github/workflows/gc-stress-test.yaml +++ b/.github/workflows/gc-stress-test.yaml @@ -22,7 +22,7 @@ jobs: with: cache: false go-version: 1.20.x - + - name: Run zb run: | make binary diff --git a/.github/workflows/nightly.yaml b/.github/workflows/nightly.yaml index 004bbaae..55458ac2 100644 --- a/.github/workflows/nightly.yaml +++ b/.github/workflows/nightly.yaml @@ -3,7 +3,7 @@ on: schedule: - cron: '30 1 * * *' workflow_dispatch: - + permissions: read-all # Here we are running two tests: @@ -40,10 +40,10 @@ jobs: pip install localstack awscli-local[ver1] # install LocalStack cli and awslocal docker pull localstack/localstack # Make sure to pull the latest version of the image localstack start -d # Start LocalStack in the background - + echo "Waiting for LocalStack startup..." # Wait 30 seconds for the LocalStack container - localstack wait -t 30 # to become ready before timing out - echo "Startup complete" + localstack wait -t 30 # to become ready before timing out + echo "Startup complete" - name: Run restore s3 blobs after cache is deleted run: | make test-restore-s3-blobs diff --git a/.github/workflows/oci-conformance-action.yml b/.github/workflows/oci-conformance-action.yml index 021dc6ef..371e35fc 100644 --- a/.github/workflows/oci-conformance-action.yml +++ b/.github/workflows/oci-conformance-action.yml @@ -6,7 +6,7 @@ name: conformance # or API. on: push: - branches: + branches: - main pull_request: branches: @@ -25,7 +25,7 @@ jobs: with: cache: false go-version: 1.20.x - - name: Checkout this PR + - name: Checkout this PR uses: actions/checkout@v3 - name: Start zot server run: | @@ -57,7 +57,7 @@ jobs: OCI_REFERRERS: 1 OCI_CROSSMOUNT_NAMESPACE: oci-conformance/crossmount-test run: | - ./conformance.test + ./conformance.test - run: mkdir -p .out/ && mv {report.html,junit.xml} .out/ if: always() - name: Upload test results zip as build artifact diff --git a/.github/workflows/scorecards.yml b/.github/workflows/scorecards.yml index 160248e2..4f78585d 100644 --- a/.github/workflows/scorecards.yml +++ b/.github/workflows/scorecards.yml @@ -22,7 +22,7 @@ jobs: # Needs for private repositories. contents: read actions: read - + steps: - name: "Checkout code" uses: actions/checkout@v3 # v3.0.0 @@ -41,8 +41,8 @@ jobs: # repo_token: ${{ secrets.SCORECARD_READ_TOKEN }} # Publish the results for public repositories to enable scorecard badges. For more details, see - # https://github.com/ossf/scorecard-action#publishing-results. - # For private repositories, `publish_results` will automatically be set to `false`, regardless + # https://github.com/ossf/scorecard-action#publishing-results. + # For private repositories, `publish_results` will automatically be set to `false`, regardless # of the value entered here. publish_results: true @@ -54,7 +54,7 @@ jobs: name: SARIF file path: results.sarif retention-days: 5 - + # Upload the results to GitHub's code scanning dashboard. - name: "Upload to code-scanning" uses: github/codeql-action/upload-sarif@v2.21.4 # v1.0.26 diff --git a/Makefile b/Makefile index aac5f6a4..5bc4a845 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ add-extensions = $(subst $(1),$(2),$(sort $(filter-valid))) BUILD_LABELS = $(call add-extensions,$(space),$(comma)) .PHONY: all -all: modcheck swagger binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml check check-gh-actions +all: modcheck swaggercheck binary binary-minimal binary-debug cli bench exporter-minimal verify-config test covhtml check check-gh-actions .PHONY: modtidy modtidy: @@ -70,6 +70,15 @@ modcheck: modtidy exit 1;\ fi +.PHONY: swaggercheck +swaggercheck: swagger + $(eval UNCOMMITED_FILES = $(shell git status --porcelain | grep -c swagger)) + @if [ $(UNCOMMITED_FILES) != 0 ]; then \ + echo "Updated swagger files uncommitted, make sure all swagger files are committed:";\ + git status;\ + exit 1;\ + fi + .PHONY: create-name create-name: ifdef BUILD_LABELS @@ -95,7 +104,7 @@ binary: modcheck create-name build-metadata .PHONY: binary-debug binary-debug: $(if $(findstring ui,$(BUILD_LABELS)), ui) -binary-debug: modcheck swagger create-name build-metadata +binary-debug: modcheck swaggercheck create-name build-metadata env CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -o bin/zot-$(OS)-$(ARCH)-debug $(BUILDMODE_FLAGS) -tags $(BUILD_LABELS),debug,containers_image_openpgp -v -gcflags all='-N -l' -ldflags "-X zotregistry.io/zot/pkg/api/config.ReleaseTag=${RELEASE_TAG} -X zotregistry.io/zot/pkg/api/config.Commit=${COMMIT} -X zotregistry.io/zot/pkg/api/config.BinaryType=$(extended-name) -X zotregistry.io/zot/pkg/api/config.GoVersion=${GO_VERSION}" ./cmd/zot .PHONY: cli diff --git a/pkg/api/routes.go b/pkg/api/routes.go index 4f955856..417cf3dd 100644 --- a/pkg/api/routes.go +++ b/pkg/api/routes.go @@ -452,7 +452,6 @@ func (rh *RouteHandler) CheckManifest(response http.ResponseWriter, request *htt response.WriteHeader(http.StatusOK) } -// NOTE: https://github.com/swaggo/swag/issues/387. type ImageManifest struct { ispec.Manifest } diff --git a/swagger/docs.go b/swagger/docs.go index cb96d84f..aacb6f3b 100644 --- a/swagger/docs.go +++ b/swagger/docs.go @@ -1399,7 +1399,7 @@ const docTemplate = `{ "description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.", "allOf": [ { - "$ref": "#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform" + "$ref": "#/definitions/v1.Platform" } ] }, @@ -1416,7 +1416,7 @@ const docTemplate = `{ } } }, - "github_com_opencontainers_image-spec_specs-go_v1.Platform": { + "v1.Platform": { "type": "object", "properties": { "architecture": { diff --git a/swagger/swagger.json b/swagger/swagger.json index a15a7443..958160f4 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1390,7 +1390,7 @@ "description": "Platform describes the platform which the image in the manifest runs on.\n\nThis should only be used when referring to a manifest.", "allOf": [ { - "$ref": "#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform" + "$ref": "#/definitions/v1.Platform" } ] }, @@ -1407,7 +1407,7 @@ } } }, - "github_com_opencontainers_image-spec_specs-go_v1.Platform": { + "v1.Platform": { "type": "object", "properties": { "architecture": { diff --git a/swagger/swagger.yaml b/swagger/swagger.yaml index 2affb4db..b1da99f5 100644 --- a/swagger/swagger.yaml +++ b/swagger/swagger.yaml @@ -185,7 +185,7 @@ definitions: type: string platform: allOf: - - $ref: '#/definitions/github_com_opencontainers_image-spec_specs-go_v1.Platform' + - $ref: '#/definitions/v1.Platform' description: |- Platform describes the platform which the image in the manifest runs on. @@ -199,7 +199,7 @@ definitions: type: string type: array type: object - github_com_opencontainers_image-spec_specs-go_v1.Platform: + v1.Platform: properties: architecture: description: |-