From 354baa5bb93dd247a75f704af76c52747aad5faf Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:04:56 +0200 Subject: [PATCH 1/8] WIP. Switch to a static list for the Quarkus versions Signed-off-by: cmoulliard --- .../quarkus-application/template.yaml | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index aa823e8..9d0c667 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -30,7 +30,13 @@ spec: title: Quarkus version type: string description: The list of the quarkus supported/recommended - ui:field: QuarkusVersionList + default: '17' + enum: + - '17' + - '21' + enumNames: + - Java 17 + - Java 21 owner: title: Owner type: string @@ -80,13 +86,15 @@ spec: title: Java Version type: string description: Java version - default: '17' + default: '3.10' enum: - - '17' - - '21' + - '3.2' + - '3.8' + - '3.10' enumNames: - - Java 17 - - Java 21 + - '3.2' + - '3.8' + - '3.10 (RECOMMENDED)' buildTool: title: Build Tool type: string From 33606ed664c4bd39d1dbdb3fa063424436f5e272 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:08:13 +0200 Subject: [PATCH 2/8] WIP. Fix wrong list updated Signed-off-by: cmoulliard --- .../quarkus-application/template.yaml | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index 9d0c667..6d90555 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -30,13 +30,15 @@ spec: title: Quarkus version type: string description: The list of the quarkus supported/recommended - default: '17' + default: '3.10' enum: - - '17' - - '21' + - '3.2' + - '3.8' + - '3.10' enumNames: - - Java 17 - - Java 21 + - '3.2' + - '3.8' + - '3.10 (RECOMMENDED)' owner: title: Owner type: string @@ -86,15 +88,13 @@ spec: title: Java Version type: string description: Java version - default: '3.10' + default: '17' enum: - - '3.2' - - '3.8' - - '3.10' + - '17' + - '21' enumNames: - - '3.2' - - '3.8' - - '3.10 (RECOMMENDED)' + - Java 17 + - Java 21 buildTool: title: Build Tool type: string From 6b8d59e0d08951a03171ad9353656374ad827dae Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:12:48 +0200 Subject: [PATCH 3/8] WIP. Set the enums for the quarkus list Signed-off-by: cmoulliard --- qshift/templates/quarkus-application/template.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index 6d90555..8406323 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -32,9 +32,9 @@ spec: description: The list of the quarkus supported/recommended default: '3.10' enum: - - '3.2' - - '3.8' - - '3.10' + - 'io.quarkus.platform:3.2' + - 'io.quarkus.platform:3.8' + - 'io.quarkus.platform:3.10' enumNames: - '3.2' - '3.8' From 97d404b284839bf0e0450b1184f97ac1c6371b44 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:23:19 +0200 Subject: [PATCH 4/8] WIP. Fix wrong default value Signed-off-by: cmoulliard --- .../quarkus-application/template.yaml | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index 8406323..c793b1c 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -30,7 +30,7 @@ spec: title: Quarkus version type: string description: The list of the quarkus supported/recommended - default: '3.10' + default: '3.10 (RECOMMENDED)' enum: - 'io.quarkus.platform:3.2' - 'io.quarkus.platform:3.8' @@ -151,15 +151,25 @@ spec: title: Alternative Extensions type: array description: The list of alternative extensions - ui:field: QuarkusExtensionList - ui:options: - # codeQuarkusUrl: https://code.quarkus.io - filter: - extensions: - - io.quarkus:quarkus-rest-jackson - - io.quarkus:quarkus-smallrye-openapi - - io.quarkus:quarkus-smallrye-graphql - - io.quarkus:quarkus-hibernate-orm-rest-data-panache + items: + type: string + enum: + - io.quarkus:quarkus-rest-jackson + - io.quarkus:quarkus-smallrye-openapi + - io.quarkus:quarkus-smallrye-graphql + - io.quarkus:quarkus-hibernate-orm-rest-data-panache + uniqueItems: true + ui:widget: checkboxes + + #ui:field: QuarkusExtensionList + #ui:options: + # # codeQuarkusUrl: https://code.quarkus.io + # filter: + # extensions: + # - io.quarkus:quarkus-rest-jackson + # - io.quarkus:quarkus-smallrye-openapi + # - io.quarkus:quarkus-smallrye-graphql + # - io.quarkus:quarkus-hibernate-orm-rest-data-panache additionalProperties: title: Additional Properties From da57d1344f2dd086ad530f8a77eb5b03864a33d1 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:29:03 +0200 Subject: [PATCH 5/8] WIP. Adding the enumNames Signed-off-by: cmoulliard --- qshift/templates/quarkus-application/template.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index c793b1c..966d3f5 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -158,6 +158,11 @@ spec: - io.quarkus:quarkus-smallrye-openapi - io.quarkus:quarkus-smallrye-graphql - io.quarkus:quarkus-hibernate-orm-rest-data-panache + enumNames: + - REST + - SmallRye OpenApi + - SmallRye GraphQL + - REST resources for Hibernate ORM with Panache uniqueItems: true ui:widget: checkboxes From 1c4d415c9dcf7ecf3c40107a57ecca079f8b7c44 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:29:29 +0200 Subject: [PATCH 6/8] WIP. Fix wrong default value Signed-off-by: cmoulliard --- qshift/templates/quarkus-application/template.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index 966d3f5..5216353 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -30,7 +30,7 @@ spec: title: Quarkus version type: string description: The list of the quarkus supported/recommended - default: '3.10 (RECOMMENDED)' + default: 'io.quarkus.platform:3.10' enum: - 'io.quarkus.platform:3.2' - 'io.quarkus.platform:3.8' From 8746029e58a75d1d4532288e0511084be34c7ad9 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:43:16 +0200 Subject: [PATCH 7/8] Split the template into 2: static and using our plugin Signed-off-by: cmoulliard --- qshift/all.yaml | 1 + .../quarkus-application/template-static.yaml | 370 ++++++++++++++++++ .../quarkus-application/template.yaml | 50 +-- 3 files changed, 388 insertions(+), 33 deletions(-) create mode 100644 qshift/templates/quarkus-application/template-static.yaml diff --git a/qshift/all.yaml b/qshift/all.yaml index d3dfdaa..c0c1421 100644 --- a/qshift/all.yaml +++ b/qshift/all.yaml @@ -7,5 +7,6 @@ spec: targets: - ./org.yaml - ./entities.yaml + - ./templates/quarkus-application/template-static.yaml - ./templates/quarkus-application/template.yaml - ./templates/quarkus-quickstart/template.yaml \ No newline at end of file diff --git a/qshift/templates/quarkus-application/template-static.yaml b/qshift/templates/quarkus-application/template-static.yaml new file mode 100644 index 0000000..2d693fa --- /dev/null +++ b/qshift/templates/quarkus-application/template-static.yaml @@ -0,0 +1,370 @@ +# Backstage doc: https://backstage.io/docs/features/software-templates/writing-templates#the-templating-syntax +# builtin filters: https://mozilla.github.io/nunjucks/templating.html#builtin-filters +apiVersion: scaffolder.backstage.io/v1beta3 +kind: Template +metadata: + name: quarkus-application + title: Create a Quarkus Application (RHDH) + description: Create a Quarkus application for RHDH using https://code.quarkus.io + tags: + - quarkus + - java + - maven +spec: + owner: guests + type: service + + parameters: + - title: Provide information for the Quarkus Application + required: + - component_id + - owner + properties: + component_id: + title: Name + type: string + description: Unique name of the application + default: my-quarkus-app + ui:field: EntityNamePicker + quarkusVersion: + title: Quarkus version + type: string + description: The list of the quarkus supported/recommended + default: 'io.quarkus.platform:3.10' + enum: + - 'io.quarkus.platform:3.2' + - 'io.quarkus.platform:3.8' + - 'io.quarkus.platform:3.10' + enumNames: + - '3.2' + - '3.8' + - '3.10 (RECOMMENDED)' + owner: + title: Owner + type: string + default: user:guest + ui:field: EntityPicker + ui:options: + catalogFilter: + kind: + - Group + - User + native: + title: Quarkus native build + type: boolean + default: false + ui:widget: radio + + - title: Provide information about the Java metadata + required: + - java_package_name + properties: + groupId: + title: Group ID + type: string + default: io.quarkus + description: Maven Group ID eg (io.janus) + artifactId: + title: Artifact ID + type: string + default: my-quarkus-app + description: Maven Artifact ID + version: + title: Version + type: string + default: 1.0.0-SNAPSHOT + description: Maven Artifact Version + java_package_name: + title: Java Package Namespace + type: string + default: io.quarkus.demo + description: Name for the Java Package (e.g. io.quarkus.demo) + description: + title: Description + type: string + description: Help others understand what this website is for. + default: A cool quarkus app + javaVersion: + title: Java Version + type: string + description: Java version + default: '17' + enum: + - '17' + - '21' + enumNames: + - Java 17 + - Java 21 + buildTool: + title: Build Tool + type: string + description: The Build tool to use + default: MAVEN + enum: + - MAVEN + - GRADLE + - GRADLE_KOTLIN_DSL + enumNames: + - Maven + - Gradle + - Gradle Kotlin DSL + + - title: Select additional features such database, endpoints, etc + required: + - healthEndpoint + - metricsEndpoint + - infoEndpoint + properties: + database: + title: Select a database (optional) + type: string + default: none + enum: + - none + - quarkus-jdbc-postgresql + - quarkus-jdbc-mysql + - quarkus-jdbc-h2 + enumNames: + - '-' + - 'PostgreSQL' + - 'MySQL' + - 'H2' + healthEndpoint: + title: Enable health endpoint + type: boolean + default: true + ui:widget: radio + + metricsEndpoint: + title: Enable metrics endpoint + type: boolean + default: true + ui:widget: radio + + infoEndpoint: + title: Enable info endpoint + type: boolean + default: true + ui:widget: radio + + extensions: + title: Alternative Extensions + type: array + description: The list of alternative extensions + items: + type: string + enum: + - io.quarkus:quarkus-rest-jackson + - io.quarkus:quarkus-smallrye-openapi + - io.quarkus:quarkus-smallrye-graphql + - io.quarkus:quarkus-hibernate-orm-rest-data-panache + enumNames: + - REST + - SmallRye OpenApi + - SmallRye GraphQL + - REST resources for Hibernate ORM with Panache + uniqueItems: true + ui:widget: checkboxes + + #ui:field: QuarkusExtensionList + #ui:options: + # # codeQuarkusUrl: https://code.quarkus.io + # filter: + # extensions: + # - io.quarkus:quarkus-rest-jackson + # - io.quarkus:quarkus-smallrye-openapi + # - io.quarkus:quarkus-smallrye-graphql + # - io.quarkus:quarkus-hibernate-orm-rest-data-panache + + additionalProperties: + title: Additional Properties + type: string + description: Additional Properties (to be appended to src/main/application.properties) + ui:widget: textarea + ui:options: + rows: 5 + + - title: Configure the Git repository + required: + - repo + properties: + repo: + title: Repository Location + type: object + properties: + host: + title: Repo Host + type: string + default: github.com + org: + title: Repo Org Owner + type: string + description: Your SCM organization/group + default: ch007m + enum: + - ch007m + - iocanel + - aureamunoz + - tqvarnst + + - title: Provide Cloud information + required: + - imageUrl + - namespace + properties: + namespace: + title: Namespace + type: string + description: The openshift/kubernetes namespace for deploying resources + default: qshift + + imageRepository: + title: Select a registry + type: string + default: quay.io + enum: + - quay.io + - image-registry.openshift-image-registry.svc:5000 + enumNames: + - Quay + - Internal OpenShift Registry + + imageUrl: + title: Image URL + type: string + description: The Quay.io or OpenShift Image URL // + + virtualMachineName: + title: Virtual Machine Name + description: Name of the virtual machine running podman to use + type: string + default: quarkus-dev + + virtualMachineNamespace: + title: VMI Namespace + description: Namespace where the virtual machine runs + type: string + default: test1 + + steps: + - id: template + name: Generating the Source Code Component + action: quarkus:app:create + input: + values: + quarkusVersion: ${{ parameters.quarkusVersion }} + groupId: ${{ parameters.groupId }} + artifactId: ${{ parameters.artifactId }} + version: ${{ parameters.version }} + buildTool: ${{ parameters.buildTool }} + javaVersion: ${{ parameters.javaVersion }} + extensions: ${{ parameters.extensions }} + database: ${{ parameters.database }} + infoEndpoint: ${{ parameters.infoEndpoint }} + healthEndpoint: ${{ parameters.healthEndpoint }} + metricsEndpoint: ${{ parameters.metricsEndpoint }} + additionalProperties: ${{ parameters.additionalProperties }} + starterCode: true + + - id: hibernate-orm-rest-dataTemplate + name: Fetching additional files ... + if: ${{ 'io.quarkus:quarkus-hibernate-orm-rest-data-panache' in parameters.extensions }} + action: fetch:template + input: + url: skeletons/quarkus-orm-rest/ + replace: true + values: + java_package_name: ${{ parameters.java_package_name }} + java_package_path: ${{ parameters.java_package_name | replace(".", "/") }} + extensions: ${{ parameters.extensions }} + database: ${{ parameters.database }} + database_username: postgres + database_name: ${{ parameters.component_id}}-db + + - id: catalogTemplate + name: Generating the Catalog Info Component + action: fetch:template + input: + url: skeletons/catalog-info/ + values: + component_id: ${{ parameters.component_id }} + clusterDomainName: apps.qshift.snowdrop.dev #TODO: Find a way to configure it + orgName: ${{ parameters.repo.org }} + repoName: ${{ parameters.repo.name }} + owner: ${{ parameters.owner }} + system: ${{ parameters.system }} + applicationType: service + description: ${{ parameters.description }} + destination: ${{ parameters.repo.org }}/${{ parameters.component_id }} + host: ${{ parameters.repo.host }} + namespace: ${{ parameters.namespace }} + imageUrl: ${{ parameters.imageUrl }} + imageBuilder: s2i-java + imageRepository: ${{ parameters.imageRepository }} + port: 8080 + ci: ${{ parameters.ci }} + quarkusVersion: ${{ parameters.quarkusVersion }} + groupId: ${{ parameters.groupId }} + artifactId: ${{ parameters.artifactId }} + javaPackageName: ${{ parameters.javaPackageName}} + sourceControl: github.com + + - id: gitopsTemplate + name: Generating GitOps Resources + action: fetch:template + input: + url: manifests/ + copyWithoutTemplating: [] + values: + component_id: ${{ parameters.component_id }} + description: ${{ parameters.description }} + destination: https://${{ parameters.repo.host }}/${{ parameters.repo.org }}/${{ parameters.component_id }}.git + git_repo: ${{ parameters.repo.host }} # quay.io, ghcr.io, docker.io, etc + git_org: ${{ parameters.repo.org }} + git_repo_name: ${{ parameters.component_id }} + git_branch: main + image_url: ${{ parameters.imageUrl }} + appNamespace: ${{ parameters.namespace }} + virtualMachineName: ${{ parameters.virtualMachineName }} + virtualMachineNamespace: ${{ parameters.virtualMachineNamespace }} + native: ${{ parameters.native }} + database: ${{ parameters.database }} + database_username: postgres + database_name: ${{ parameters.component_id}}-db + + - id: publish + name: Publishing to Code Source Repository - Github + action: publish:github + input: + allowedHosts: ['github.com'] + description: This is ${{ parameters.component_id }} + repoUrl: "${{ parameters.repo.host }}?owner=${{ parameters.repo.org }}&repo=${{parameters.component_id}}" + defaultBranch: main + protectDefaultBranch: false + repoVisibility: public + + - id: register + name: Registering the Catalog Info Component + action: catalog:register + input: + repoContentsUrl: ${{ steps.publish.output.repoContentsUrl }} + catalogInfoPath: /catalog-info.yaml + + - id: create-argocd-resources + name: Create ArgoCD Resources + action: argocd:create-resources + input: + appName: ${{ parameters.component_id }}-bootstrap + argoInstance: argocdQShift # Match appconfig => argocd/appLocatorMethods/instances/name + projectName: ${{ parameters.component_id }} + namespace: ${{ parameters.namespace }} + repoUrl: https://${{ parameters.repo.host }}/${{ parameters.repo.org }}/${{parameters.component_id}}.git + path: 'argocd/' + + output: + links: + - title: Open the Source Code Repository + url: ${{ steps.publish.output.remoteUrl }} + - title: Open the Catalog Info Component + icon: catalog + entityRef: ${{ steps.register.output.entityRef }} diff --git a/qshift/templates/quarkus-application/template.yaml b/qshift/templates/quarkus-application/template.yaml index 5216353..e19a456 100644 --- a/qshift/templates/quarkus-application/template.yaml +++ b/qshift/templates/quarkus-application/template.yaml @@ -26,19 +26,13 @@ spec: description: Unique name of the application default: my-quarkus-app ui:field: EntityNamePicker + quarkusVersion: title: Quarkus version type: string description: The list of the quarkus supported/recommended - default: 'io.quarkus.platform:3.10' - enum: - - 'io.quarkus.platform:3.2' - - 'io.quarkus.platform:3.8' - - 'io.quarkus.platform:3.10' - enumNames: - - '3.2' - - '3.8' - - '3.10 (RECOMMENDED)' + ui:field: QuarkusVersionList + owner: title: Owner type: string @@ -64,6 +58,7 @@ spec: type: string default: io.quarkus description: Maven Group ID eg (io.janus) + artifactId: title: Artifact ID type: string @@ -74,6 +69,7 @@ spec: type: string default: 1.0.0-SNAPSHOT description: Maven Artifact Version + java_package_name: title: Java Package Namespace type: string @@ -84,6 +80,7 @@ spec: type: string description: Help others understand what this website is for. default: A cool quarkus app + javaVersion: title: Java Version type: string @@ -95,6 +92,7 @@ spec: enumNames: - Java 17 - Java 21 + buildTool: title: Build Tool type: string @@ -129,6 +127,7 @@ spec: - 'PostgreSQL' - 'MySQL' - 'H2' + healthEndpoint: title: Enable health endpoint type: boolean @@ -151,30 +150,15 @@ spec: title: Alternative Extensions type: array description: The list of alternative extensions - items: - type: string - enum: - - io.quarkus:quarkus-rest-jackson - - io.quarkus:quarkus-smallrye-openapi - - io.quarkus:quarkus-smallrye-graphql - - io.quarkus:quarkus-hibernate-orm-rest-data-panache - enumNames: - - REST - - SmallRye OpenApi - - SmallRye GraphQL - - REST resources for Hibernate ORM with Panache - uniqueItems: true - ui:widget: checkboxes - - #ui:field: QuarkusExtensionList - #ui:options: - # # codeQuarkusUrl: https://code.quarkus.io - # filter: - # extensions: - # - io.quarkus:quarkus-rest-jackson - # - io.quarkus:quarkus-smallrye-openapi - # - io.quarkus:quarkus-smallrye-graphql - # - io.quarkus:quarkus-hibernate-orm-rest-data-panache + ui:field: QuarkusExtensionList + ui:options: + # codeQuarkusUrl: https://code.quarkus.io + filter: + extensions: + - io.quarkus:quarkus-rest-jackson + - io.quarkus:quarkus-smallrye-openapi + - io.quarkus:quarkus-smallrye-graphql + - io.quarkus:quarkus-hibernate-orm-rest-data-panache additionalProperties: title: Additional Properties From 348504669e42e0f5caae14944e4fd33b5896efa9 Mon Sep 17 00:00:00 2001 From: cmoulliard Date: Mon, 6 May 2024 17:49:02 +0200 Subject: [PATCH 8/8] Changing the java default value and add spaces between fields Signed-off-by: cmoulliard --- .../quarkus-application/template-static.yaml | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/qshift/templates/quarkus-application/template-static.yaml b/qshift/templates/quarkus-application/template-static.yaml index 2d693fa..771b34b 100644 --- a/qshift/templates/quarkus-application/template-static.yaml +++ b/qshift/templates/quarkus-application/template-static.yaml @@ -26,6 +26,7 @@ spec: description: Unique name of the application default: my-quarkus-app ui:field: EntityNamePicker + quarkusVersion: title: Quarkus version type: string @@ -39,6 +40,7 @@ spec: - '3.2' - '3.8' - '3.10 (RECOMMENDED)' + owner: title: Owner type: string @@ -64,37 +66,43 @@ spec: type: string default: io.quarkus description: Maven Group ID eg (io.janus) + artifactId: title: Artifact ID type: string default: my-quarkus-app description: Maven Artifact ID + version: title: Version type: string default: 1.0.0-SNAPSHOT description: Maven Artifact Version + java_package_name: title: Java Package Namespace type: string default: io.quarkus.demo description: Name for the Java Package (e.g. io.quarkus.demo) + description: title: Description type: string description: Help others understand what this website is for. default: A cool quarkus app + javaVersion: title: Java Version type: string description: Java version - default: '17' + default: '21' enum: - '17' - '21' enumNames: - Java 17 - Java 21 + buildTool: title: Build Tool type: string @@ -129,6 +137,7 @@ spec: - 'PostgreSQL' - 'MySQL' - 'H2' + healthEndpoint: title: Enable health endpoint type: boolean @@ -166,16 +175,6 @@ spec: uniqueItems: true ui:widget: checkboxes - #ui:field: QuarkusExtensionList - #ui:options: - # # codeQuarkusUrl: https://code.quarkus.io - # filter: - # extensions: - # - io.quarkus:quarkus-rest-jackson - # - io.quarkus:quarkus-smallrye-openapi - # - io.quarkus:quarkus-smallrye-graphql - # - io.quarkus:quarkus-hibernate-orm-rest-data-panache - additionalProperties: title: Additional Properties type: string