diff --git a/charts/rpj/Chart.yaml b/charts/rpj/Chart.yaml index 271288d5..1577429d 100644 --- a/charts/rpj/Chart.yaml +++ b/charts/rpj/Chart.yaml @@ -6,7 +6,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 1.3.0-rc1 +version: 1.3.0-rc2 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/rpj/templates/00-secret_rpj.yaml b/charts/rpj/templates/00-secret_rpj.yaml new file mode 100644 index 00000000..84174744 --- /dev/null +++ b/charts/rpj/templates/00-secret_rpj.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +data: + NOTIFICATIONS_BEARER_TOKEN: "" +kind: Secret +metadata: + creationTimestamp: null + name: rpj-creds diff --git a/charts/rpj/templates/01-configmap_rpj-props.yaml b/charts/rpj/templates/01-configmap_rpj-props.yaml new file mode 100755 index 00000000..3643ca8d --- /dev/null +++ b/charts/rpj/templates/01-configmap_rpj-props.yaml @@ -0,0 +1,25 @@ +apiVersion: v1 +data: + application.properties: | + # RPJ + rpj.url = ${RPJ_URL} + quarkus.rest-client.rpj_json.url = ${rpj.url} + + # Backstage Notifications service + quarkus.rest-client.notifications.url=${BACKSTAGE_NOTIFICATIONS_URL} + quarkus.openapi-generator.notifications.auth.BearerToken.bearer-token=${NOTIFICATIONS_BEARER_TOKEN} + + # This property is used to select the log level, which controls the amount + # of information logged on HTTP requests based on the severity of the events. + # Possible values: OFF, FATAL, ERROR, WARN, INFO, DEBUG, ALL. + # and see https://quarkus.io/guides/logging for documentation + quarkus.log.category."org.apache.http".level=INFO + quarkus.log.level=INFO + quarkus.flyway.migrate-at-start=true +kind: ConfigMap +metadata: + creationTimestamp: null + labels: + app: rpj + sonataflow.org/workflow-app: rpj + name: rpj-props diff --git a/charts/rpj/templates/02-configmap_01-rpj-resources-schemas.yaml b/charts/rpj/templates/02-configmap_01-rpj-resources-schemas.yaml new file mode 100755 index 00000000..b1c994e7 --- /dev/null +++ b/charts/rpj/templates/02-configmap_01-rpj-resources-schemas.yaml @@ -0,0 +1,50 @@ +apiVersion: v1 +data: + rpj-input.json: |+ + { + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "object", + "properties": { + "launchId": { + "title": "Launch ID", + "type": "string" + }, + "epicCode": { + "title": "Epic code", + "type": "string" + }, + "recipients": { + "title": "Recipients", + "type": "array", + "description": "A list of recipients for the notification in the format of 'user:/' or 'group:/', i.e. 'user:default/jsmith'", + "items": { + "title": "Recipient", + "type": "string", + "pattern": "^(user|group):[a-z0-9]([-a-z0-9]*[a-z0-9])?/([a-z0-9]([-a-z0-9]*[a-z0-9])?)$" + }, + "minItems": 1 + } + }, + "required": [ + "launchId", + "recipients" + ] + } + + workflow-output-schema.json: |- + { + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "WorkflowResult", + "description": "Schema of workflow output", + "type": "object", + "properties": { + "result": { + "$ref": "../shared/schemas/workflow-result-schema.json", + "type": "object" + } + } + } +kind: ConfigMap +metadata: + creationTimestamp: null + name: 01-rpj-resources-schemas diff --git a/charts/rpj/templates/03-configmap_02-rpj-resources-specs.yaml b/charts/rpj/templates/03-configmap_02-rpj-resources-specs.yaml new file mode 100755 index 00000000..04b789fa --- /dev/null +++ b/charts/rpj/templates/03-configmap_02-rpj-resources-specs.yaml @@ -0,0 +1,104 @@ +apiVersion: v1 +data: + rpj.json: |- + { + "openapi": "3.0.1", + "info": { + "title": "RPJ API", + "contact": {}, + "license": { + "name": "Apache 2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0.html" + }, + "version": "0.3.z" + }, + "servers": [ + { + "url": "/" + } + ], + "paths": { + "/{launch_id}": { + "get": { + "operationId": "run", + "tags": [ + "run" + ], + "summary": "Create Jira tickets from a launch in Report Portal.", + "description": "create Jira tickets from a launch in Report Portal.", + "parameters": [ + { + "name": "launch_id", + "in": "path", + "description": "ID of the launch for which Jira ticket shall be created.", + "required": true, + "example": "1234", + "schema": { + "$ref": "#/components/schemas/ID" + } + }, + { + "name": "epic", + "in": "query", + "description": "Epic code in which include the created Jira ticket.", + "required": false, + "example": "XX-11", + "schema": { + "$ref": "#/components/schemas/EpicCode" + } + } + ], + "responses": { + "200": { + "description": "OK", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/StartResponse" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "ID": { + "type": "string", + "description": "A unique ID.", + "example": "1234" + }, + "EpicCode": { + "pattern": "^[a-zA-Z0-9-_]+$", + "type": "string", + "description": "Epic code.", + "example": "id-1234" + }, + "StartResponse": { + "required": [ + "success", + "message", + "data" + ], + "type": "object", + "properties": { + "success": { + "type": "boolean" + }, + "message": { + "type": "string" + }, + "data": { + "type": "string" + } + } + } + } + } + } +kind: ConfigMap +metadata: + creationTimestamp: null + name: 02-rpj-resources-specs diff --git a/charts/rpj/templates/04-sonataflow_rpj.yaml b/charts/rpj/templates/04-sonataflow_rpj.yaml new file mode 100755 index 00000000..46caf859 --- /dev/null +++ b/charts/rpj/templates/04-sonataflow_rpj.yaml @@ -0,0 +1,169 @@ +apiVersion: sonataflow.org/v1alpha08 +kind: SonataFlow +metadata: + annotations: + sonataflow.org/description: Workflow to execute RPJ + sonataflow.org/expressionLang: jq + sonataflow.org/profile: gitops + sonataflow.org/version: "1.0" + creationTimestamp: null + labels: + app: rpj + sonataflow.org/workflow-app: rpj + name: rpj +spec: + flow: + annotations: + - workflow-type/infrastructure + dataInputSchema: + failOnValidationErrors: true + schema: schemas/rpj-input.json + functions: + - name: run + operation: specs/rpj.json#run + type: rest + - name: createNotification + operation: notifications#createNotification + type: rest + - name: systemOut + operation: sysout + type: custom + - name: successResult + operation: '{ "result": { "completedWith":"success", "message": "RPJ workflow " + $WORKFLOW.instanceId + " was successful", "outputs": [ { "key":"Launch ID", "value": .launchId }, { "key":"Epic code", "value": (if .epicCode == null then "None provided" else .epicCode end) } ] } }' + type: expression + - name: errorResult + operation: '{ "result": { "completedWith":"error", "message": "RPJ workflow " + $WORKFLOW.instanceId + " failed", "outputs": [ { "key":"Launch ID", "value": .launchId }, { "key":"Epic code", "value": (if .epicCode == null then "None provided" else .epicCode end) }, { "key":"Run result message", "value": .runResults.message } ] } }' + type: expression + start: + stateName: Run + states: + - actionMode: sequential + actions: + - actionDataFilter: + toStateData: .runResults + useResults: true + functionRef: + arguments: + epic: .epicCode + launch_id: .launchId + invoke: sync + refName: run + name: getApp + name: Run + transition: + nextState: CheckResults + type: operation + - dataConditions: + - condition: .runResults.success == true + name: success + transition: + nextState: NotifyBackstage + - condition: .runResults.success == false + name: failure + transition: + nextState: NotifyFailureBackstage + defaultCondition: + transition: + nextState: NotifyFailureBackstage + name: CheckResults + type: switch + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '"RPJ run results for launch " + .launchId + ": " + (.runResults|tostring)' + invoke: sync + refName: systemOut + name: printSystemOut + - actionDataFilter: + useResults: true + functionRef: + arguments: + payload: + description: '"RPJ result for launch " + .launchId + ": Message: " + .runResults.message ' + title: RPJ run results + topic: RPJ Workflow + recipients: + entityRef: .recipients + type: entity + invoke: sync + refName: createNotification + name: createNotification + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: successResult + name: setOutput + end: + terminate: true + name: NotifyBackstage + type: operation + - actionMode: sequential + actions: + - actionDataFilter: + useResults: true + functionRef: + arguments: + message: '"RPJ run failed with results for launch " + .launchId + ": " + (.runResults|tostring)' + invoke: sync + refName: systemOut + name: printSystemOut + - actionDataFilter: + useResults: true + functionRef: + arguments: + payload: + description: '"RPJ run failed for launch " + .launchId + ". Message: " + .runResults.message ' + title: RPJ run failed + topic: RPJ Workflow + recipients: + entityRef: .recipients + type: entity + invoke: sync + refName: createNotification + name: createFailureNotification + - actionDataFilter: + useResults: true + functionRef: + invoke: sync + refName: errorResult + name: setOutput + end: + terminate: true + name: NotifyFailureBackstage + type: operation + timeouts: + workflowExecTimeout: + duration: PT1H + podTemplate: + container: + resources: {} + image: quay.io/orchestrator/serverless-workflow-rpj:dc65c75164b156422bd157aaab5a55eca2e8f869 + envFrom: + - secretRef: + name: rpj-creds + resources: + configMaps: + - configMap: + name: 01-rpj-resources-schemas + workflowPath: schemas + - configMap: + name: 02-rpj-resources-specs + workflowPath: specs + persistence: + postgresql: + secretRef: + name: sonataflow-psql-postgresql + userKey: postgres-username + passwordKey: postgres-password + serviceRef: + name: sonataflow-psql-postgresql + port: 5432 + databaseName: sonataflow + databaseSchema: rpj +status: + address: {} + lastTimeRecoverAttempt: null