From 922b80d77cb3f6ae2981ee5df65f7befc54a909a Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 19 Feb 2024 12:04:11 +0100 Subject: [PATCH 1/6] Add the missing break within the while statement to exit when the gitea repository exists. #23049 Signed-off-by: cmoulliard --- .../templates/quarkus-application/skeletons/hello-world/pom.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 qshift/templates/quarkus-application/skeletons/hello-world/pom.xml diff --git a/qshift/templates/quarkus-application/skeletons/hello-world/pom.xml b/qshift/templates/quarkus-application/skeletons/hello-world/pom.xml new file mode 100644 index 0000000000..e69de29bb2 From ef0f44e423c89d721d9b5c22e3b085810ce8572e Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 19 Feb 2024 12:11:02 +0100 Subject: [PATCH 2/6] Add change set and code change Signed-off-by: cmoulliard --- .changeset/weak-flowers-repeat.md | 5 +++++ plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts | 3 +++ 2 files changed, 8 insertions(+) create mode 100644 .changeset/weak-flowers-repeat.md diff --git a/.changeset/weak-flowers-repeat.md b/.changeset/weak-flowers-repeat.md new file mode 100644 index 0000000000..4d0d4ce2b7 --- /dev/null +++ b/.changeset/weak-flowers-repeat.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-scaffolder-backend-module-gitea': patch +--- + +Add missing break within the while statement to exit from the while maxDuration statement when the gitea repository has been created and exists diff --git a/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts b/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts index e7f62f51da..875e6188a9 100644 --- a/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts +++ b/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts @@ -178,6 +178,9 @@ async function checkAvailabilityGiteaRepository( if (response.status !== 200) { // Repository is not yet available/accessible ... await sleep(1000); + } else { + // Gitea repository exists ! + break; } } } From 40de43d14d1295ff99e63cb0632c9eb8c7cd299e Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 19 Feb 2024 12:50:14 +0100 Subject: [PATCH 3/6] Changed the wording to warn the user to get a certificate when using gitea locally and clean the template example Signed-off-by: cmoulliard --- .../scaffolder-backend-module-gitea/README.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/plugins/scaffolder-backend-module-gitea/README.md b/plugins/scaffolder-backend-module-gitea/README.md index f13602f2d8..a1282634e0 100644 --- a/plugins/scaffolder-backend-module-gitea/README.md +++ b/plugins/scaffolder-backend-module-gitea/README.md @@ -28,8 +28,8 @@ integrations: password: '' ``` -**NOTE**: As backstage will issue HTTPS/TLS requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a -self-signed certificate `gitea cert --host localhost -ca`. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage ! +**Important**: As backstage will issue HTTPS/TLS requests to the gitea instance, it is needed to configure `gitea` with a valid certificate or at least with a +self-signed certificate `gitea cert --host localhost -ca` trusted by a CA authority. Don't forget to set the env var `NODE_EXTRA_CA_CERTS` to point to the CA file before launching backstage ! When done, you can create a template which: @@ -69,18 +69,8 @@ spec: action: fetch:template input: url: ./skeleton - copyWithoutTemplating: - - .github/workflows/* values: - component_id: ${{ parameters.component_id }} - namespace: ${{ parameters.component_id }}-dev - description: ${{ parameters.description }} - group_id: ${{ parameters.group_id }} - artifact_id: ${{ parameters.artifact_id }} - java_package_name: ${{ parameters.java_package_name }} - owner: ${{ parameters.owner }} - destination: ${{ (parameters.repoUrl | parseRepoUrl).owner }}/${{ (parameters.repoUrl | parseRepoUrl).repo } - port: 8080 + name: ${{ parameters.name }} - id: publish name: Publishing to a gitea git repository From 72ab2dcd58b9883113722e6ec893db9450acef93 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 19 Feb 2024 14:13:34 +0100 Subject: [PATCH 4/6] Reviewing the change wording. Add the root cause of the error of: checkGiteaOrg to allow to know if there is a certificate error Signed-off-by: cmoulliard --- .changeset/weak-flowers-repeat.md | 3 ++- plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.changeset/weak-flowers-repeat.md b/.changeset/weak-flowers-repeat.md index 4d0d4ce2b7..ed71acd332 100644 --- a/.changeset/weak-flowers-repeat.md +++ b/.changeset/weak-flowers-repeat.md @@ -2,4 +2,5 @@ '@backstage/plugin-scaffolder-backend-module-gitea': patch --- -Add missing break within the while statement to exit from the while maxDuration statement when the gitea repository has been created and exists +Fix issue for infinite loop when repository already exists +Log the root cause of error reported by checkGiteaOrg diff --git a/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts b/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts index 875e6188a9..089f9b2669 100644 --- a/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts +++ b/plugins/scaffolder-backend-module-gitea/src/actions/gitea.ts @@ -80,7 +80,9 @@ const checkGiteaOrg = async ( getOptions, ); } catch (e) { - throw new Error(`Unable to get the Organization: ${owner}, ${e}`); + throw new Error( + `Unable to get the Organization: ${owner}; Error cause: ${e.cause.message}`, + ); } if (response.status !== 200) { throw new Error( From be0202bc8d850cc27bca7b5c9bbd6b98c8d5e630 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 19 Feb 2024 16:39:48 +0100 Subject: [PATCH 5/6] Remove file pushed BUT non needed Signed-off-by: cmoulliard --- .../templates/quarkus-application/skeletons/hello-world/pom.xml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 qshift/templates/quarkus-application/skeletons/hello-world/pom.xml diff --git a/qshift/templates/quarkus-application/skeletons/hello-world/pom.xml b/qshift/templates/quarkus-application/skeletons/hello-world/pom.xml deleted file mode 100644 index e69de29bb2..0000000000 From 6a670a4e167c5811f993239c6d99df94a05c9b36 Mon Sep 17 00:00:00 2001 From: Charles Moulliard Date: Mon, 19 Feb 2024 16:40:36 +0100 Subject: [PATCH 6/6] Update .changeset/weak-flowers-repeat.md Co-authored-by: Ben Lambert Signed-off-by: Charles Moulliard --- .changeset/weak-flowers-repeat.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.changeset/weak-flowers-repeat.md b/.changeset/weak-flowers-repeat.md index ed71acd332..d1705343bc 100644 --- a/.changeset/weak-flowers-repeat.md +++ b/.changeset/weak-flowers-repeat.md @@ -2,5 +2,5 @@ '@backstage/plugin-scaffolder-backend-module-gitea': patch --- -Fix issue for infinite loop when repository already exists -Log the root cause of error reported by checkGiteaOrg +- Fix issue for infinite loop when repository already exists +- Log the root cause of error reported by `checkGiteaOrg`