Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use static lists instead of dynamic for quarkus versions and extensions #52

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions qshift/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
369 changes: 369 additions & 0 deletions qshift/templates/quarkus-application/template-static.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,369 @@
# 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: '21'
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

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 <REGISTRY>/<IMAGE_URL>/<REPO_NAME>

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 }}
Loading