Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-farache committed Nov 14, 2024
1 parent 4a99dfa commit a25b171
Show file tree
Hide file tree
Showing 6 changed files with 356 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/rpj/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions charts/rpj/templates/00-secret_rpj.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
NOTIFICATIONS_BEARER_TOKEN: ""
kind: Secret
metadata:
creationTimestamp: null
name: rpj-creds
25 changes: 25 additions & 0 deletions charts/rpj/templates/01-configmap_rpj-props.yaml
Original file line number Diff line number Diff line change
@@ -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
50 changes: 50 additions & 0 deletions charts/rpj/templates/02-configmap_01-rpj-resources-schemas.yaml
Original file line number Diff line number Diff line change
@@ -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:<namespace>/<username>' or 'group:<namespace>/<groupname>', 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
104 changes: 104 additions & 0 deletions charts/rpj/templates/03-configmap_02-rpj-resources-specs.yaml
Original file line number Diff line number Diff line change
@@ -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
169 changes: 169 additions & 0 deletions charts/rpj/templates/04-sonataflow_rpj.yaml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit a25b171

Please sign in to comment.