From b8d8662bd9406b98220c420e37050f1a7e70a666 Mon Sep 17 00:00:00 2001 From: Sofia Papagiannaki <1632407+papagian@users.noreply.github.com> Date: Thu, 7 Mar 2024 12:07:35 +0200 Subject: [PATCH] Swagger: Re-generate the enterprise specification if enterprise is cloned (#81730) * Swagger: Re-generate the enterprise specification if enterprise is cloned successfully * API change to trigger the swagger CI step execution * Swagger: Silence logs --- .drone.yml | 14 +++++++++----- Makefile | 8 ++++---- pkg/api/folder.go | 2 +- public/api-merged.json | 2 +- public/openapi3.json | 2 +- scripts/drone/pipelines/swagger_gen.star | 4 ++-- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6af8a77378b..9e247315b4c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1234,11 +1234,15 @@ steps: | jq .head.repo.fork) - if [ "$is_fork" != false ]; then return 1; fi - git clone "https://$${GITHUB_TOKEN}@github.com/grafana/grafana-enterprise.git" - grafana-enterprise - - cd grafana-enterprise + ../grafana-enterprise + - cd ../grafana-enterprise - if git checkout ${DRONE_SOURCE_BRANCH}; then echo "checked out ${DRONE_SOURCE_BRANCH}"; - elif git checkout main; then echo "git checkout main"; else git checkout main; - fi + elif git checkout ${DRONE_TARGET_BRANCH}; then echo "git checkout ${DRONE_TARGET_BRANCH}"; + else git checkout main; fi + - cd ../ + - ln -s src grafana + - cd ./grafana-enterprise + - ./build.sh environment: GITHUB_TOKEN: from_secret: github_token @@ -4920,6 +4924,6 @@ kind: secret name: gcr_credentials --- kind: signature -hmac: 2f4a5620d00189804c2facf65fa2a17b75883cf330cd32e5612a2f36d3712847 +hmac: 3fa4360bd3c21fbc95bd3c2b63130541f9ea7c0aa56eb95dfe49c4f579aac4bb ... diff --git a/Makefile b/Makefile index b39cf4b5627..896493bc40e 100644 --- a/Makefile +++ b/Makefile @@ -45,12 +45,12 @@ $(NGALERT_SPEC_TARGET): $(MERGED_SPEC_TARGET): swagger-oss-gen swagger-enterprise-gen $(NGALERT_SPEC_TARGET) $(SWAGGER) ## Merge generated and ngalert API specs # known conflicts DsPermissionType, AddApiKeyCommand, Json, Duration (identical models referenced by both specs) - $(SWAGGER) mixin $(SPEC_TARGET) $(ENTERPRISE_SPEC_TARGET) $(NGALERT_SPEC_TARGET) --ignore-conflicts -o $(MERGED_SPEC_TARGET) + $(SWAGGER) mixin -q $(SPEC_TARGET) $(ENTERPRISE_SPEC_TARGET) $(NGALERT_SPEC_TARGET) --ignore-conflicts -o $(MERGED_SPEC_TARGET) swagger-oss-gen: $(SWAGGER) ## Generate API Swagger specification @echo "re-generating swagger for OSS" rm -f $(SPEC_TARGET) - SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -m -w pkg/server -o $(SPEC_TARGET) \ + SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -q -m -w pkg/server -o $(SPEC_TARGET) \ -x "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" \ -x "github.com/prometheus/alertmanager" \ -i pkg/api/swagger_tags.json \ @@ -66,7 +66,7 @@ else swagger-enterprise-gen: $(SWAGGER) ## Generate API Swagger specification @echo "re-generating swagger for enterprise" rm -f $(ENTERPRISE_SPEC_TARGET) - SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -m -w pkg/server -o $(ENTERPRISE_SPEC_TARGET) \ + SWAGGER_GENERATE_EXTENSION=false $(SWAGGER) generate spec -q -m -w pkg/server -o $(ENTERPRISE_SPEC_TARGET) \ -x "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions" \ -x "github.com/prometheus/alertmanager" \ -i pkg/api/swagger_tags.json \ @@ -77,7 +77,7 @@ endif swagger-gen: gen-go $(MERGED_SPEC_TARGET) swagger-validate swagger-validate: $(MERGED_SPEC_TARGET) $(SWAGGER) ## Validate API spec - $(SWAGGER) validate $(<) + $(SWAGGER) validate --skip-warnings $(<) swagger-clean: rm -f $(SPEC_TARGET) $(MERGED_SPEC_TARGET) $(OAPI_SPEC_TARGET) diff --git a/pkg/api/folder.go b/pkg/api/folder.go index fbb63f4d985..719eb6dfd25 100644 --- a/pkg/api/folder.go +++ b/pkg/api/folder.go @@ -31,7 +31,7 @@ const REDACTED = "redacted" // // Get all folders. // -// Returns all folders that the authenticated user has permission to view. +// It returns all folders that the authenticated user has permission to view. // If nested folders are enabled, it expects an additional query parameter with the parent folder UID // and returns the immediate subfolders that the authenticated user has permission to view. // If the parameter is not supplied then it returns immediate subfolders under the root diff --git a/public/api-merged.json b/public/api-merged.json index 9ad7eef2739..8a7250ee215 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -4926,7 +4926,7 @@ }, "/folders": { "get": { - "description": "Returns all folders that the authenticated user has permission to view.\nIf nested folders are enabled, it expects an additional query parameter with the parent folder UID\nand returns the immediate subfolders that the authenticated user has permission to view.\nIf the parameter is not supplied then it returns immediate subfolders under the root\nthat the authenticated user has permission to view.", + "description": "It returns all folders that the authenticated user has permission to view.\nIf nested folders are enabled, it expects an additional query parameter with the parent folder UID\nand returns the immediate subfolders that the authenticated user has permission to view.\nIf the parameter is not supplied then it returns immediate subfolders under the root\nthat the authenticated user has permission to view.", "tags": [ "folders" ], diff --git a/public/openapi3.json b/public/openapi3.json index 3bd8efd4f2f..6337fe79008 100644 --- a/public/openapi3.json +++ b/public/openapi3.json @@ -18284,7 +18284,7 @@ }, "/folders": { "get": { - "description": "Returns all folders that the authenticated user has permission to view.\nIf nested folders are enabled, it expects an additional query parameter with the parent folder UID\nand returns the immediate subfolders that the authenticated user has permission to view.\nIf the parameter is not supplied then it returns immediate subfolders under the root\nthat the authenticated user has permission to view.", + "description": "It returns all folders that the authenticated user has permission to view.\nIf nested folders are enabled, it expects an additional query parameter with the parent folder UID\nand returns the immediate subfolders that the authenticated user has permission to view.\nIf the parameter is not supplied then it returns immediate subfolders under the root\nthat the authenticated user has permission to view.", "operationId": "getFolders", "parameters": [ { diff --git a/scripts/drone/pipelines/swagger_gen.star b/scripts/drone/pipelines/swagger_gen.star index 7275f405bf2..41018250cd2 100644 --- a/scripts/drone/pipelines/swagger_gen.star +++ b/scripts/drone/pipelines/swagger_gen.star @@ -4,7 +4,7 @@ This module returns all pipelines used in OpenAPI specification generation of Gr load( "scripts/drone/steps/lib.star", - "clone_enterprise_step_pr", + "enterprise_setup_step", ) load( "scripts/drone/utils/images.star", @@ -42,7 +42,7 @@ def swagger_gen_step(ver_mode): def swagger_gen(ver_mode, source = "${DRONE_SOURCE_BRANCH}"): test_steps = [ - clone_enterprise_step_pr(source = source, canFail = True), + enterprise_setup_step(source = source, canFail = True), swagger_gen_step(ver_mode = ver_mode), ]