Skip to content

Commit

Permalink
Merge pull request #30 from rgolangh/autopr-21489
Browse files Browse the repository at this point in the history
Automatic manifests generation from
  • Loading branch information
rgolangh authored Jan 24, 2024
2 parents 6585e67 + 585c256 commit f7f0564
Show file tree
Hide file tree
Showing 3 changed files with 214 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ data:
"properties": {
"repositoryURL": {
"type": "string"
},
"backstageUserOrGroup": {
"type": "string"
}
},
"required": [
Expand Down Expand Up @@ -698,6 +701,179 @@ data:
\"integer\"\n },\n \"unknown\": {\n \"type\": \"integer\"\n
\ },\n \"yellow\": {\n \"type\": \"integer\"\n }\n
\ }\n }\n }\n },\n \"x-original-swagger-version\": \"2.0\"\n}\n"
notifications.yaml: |
openapi: 3.0.3
info:
title: Backstage Notifications Plugin - OpenAPI Specs
description: |-
Backstage Notifications Plugin - OpenAPI Specs
version: 1.0.0
tags:
- name: notifications
description: Backstage notifications plugin
paths:
/notifications:
post:
tags:
- notifications
summary: Create notification
description: Create notification
operationId: createNotification
requestBody:
description: Create a new notification
content:
application/json:
schema:
$ref: '#/components/schemas/Notification'
responses:
'200':
description: Successful operation
content:
application/json:
schema:
type: object
properties:
messageId:
type: string
example: bc9f19de-8b7b-49a8-9262-c5036a1ed35e
get:
tags:
- notifications
summary: Gets notifications
description: Gets notifications
operationId: getNotifications
parameters:
- name: user
in: query
description: User for whom notifications will be fetched
required: true
schema:
type: string
- name: pageSize
in: query
description: Page size of the result
required: true
schema:
type: integer
- name: pageNumber
in: query
description: Page number of the result
required: true
schema:
type: integer
- name: read
in: query
description: Notifications read or not
required: true
schema:
type: boolean
responses:
'200':
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Notifications'
'500':
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResponse'
components:
schemas:
Notifications:
type: array
items:
$ref: '#/components/schemas/Notification'
Action:
properties:
id:
type: string
example: aaf2e18f-fa55-4dd4-8d71-58878b4398ad
url:
type: string
example: http://foo.bar
title:
type: string
example: my-title
Notification:
properties:
id:
type: string
example: 19d76846-4bce-4786-bdc0-e44c30756dec
created:
type: string
format: date-time
example: "2023-11-21T15:33:15.800Z"
isSystem:
type: boolean
example: false
readByUser:
type: boolean
example: false
origin:
type: string
example: my-origin
title:
type: string
example: My message title
message:
type: string
format: nullable
example: I have nothing to say
topic:
type: string
format: nullable
targetUsers: # Used in Post Notifications
type: array
format: nullable
items:
type: string
example: jdoe
targetGroups: # Used in Post Notifications
type: array
format: nullable
items:
type: string
example: jdoe
actions:
type: array
format: nullable
items:
$ref: '#/components/schemas/Action'
ErrorResponse:
type: object
properties:
error:
type: object
properties:
name:
type: string
example: Error
message:
type: string
example: pageSize and pageNumber must both be either 0 or greater than 0
stack:
type: string
example: >-
Error: "pageSize and pageNumber must both be either 0 or greater than 0"
request:
type: object
properties:
method:
type: string
example: GET
url:
type: string
example: /notifications?user=jdoe&read=false&pageNumber=-1&pageSize=1
response:
type: object
properties:
statusCode:
type: integer
format: int32
example: 500
kind: ConfigMap
metadata:
creationTimestamp: null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,11 @@ metadata:
spec:
flow:
annotations:
- workflow-type/infrastructure
- workflow-type/assessment
dataInputSchema:
failOnValidationErrors: false
schema: specs/mta-input.json
functions:
- name: debug
operation: sysout
type: custom
- name: filterApplication
operation: '{application: .applications|map(select(.repository.url == .repositoryURL))[0]}'
type: expression
Expand All @@ -40,6 +37,9 @@ spec:
- name: getTaskgroup
operation: specs/mta.json#getTaskgroup
type: rest
- name: createNotification
operation: specs/notifications.yaml#createNotification
type: rest
start:
stateName: GetApplication
states:
Expand Down Expand Up @@ -175,27 +175,57 @@ spec:
- dataConditions:
- condition: (.taskgroup.state == "Ready" and .taskgroup.tasks[0].state == "Succeeded")
transition:
nextState: report
nextState: NotifyBackstage
defaultCondition:
transition:
nextState: poll
name: checkReportDone
transition:
nextState: NotifyBackstage
type: switch
- actionMode: sequential
actions:
- actionDataFilter:
useResults: true
condition: .backstageUserOrGroup != null
functionRef:
arguments:
message: '"<a href=\"" + $SECRET.mta_url+ "/hub/applications/" + (.application.id|tostring)+ "/bucket/" + .data.output + "\">MTA Analysis Rerport</a>"'
origin: MTA Analysis Workflow
targetGroups:
- .backstageUserOrGroup
targetUsers:
- .backstageUserOrGroup
title: '"MTA analysis report for " + .application.repository.url'
invoke: sync
refName: createNotification
name: NotifyBackstage
transition:
nextState: report
type: operation
- actionMode: sequential
actions: null
name: report
stateDataFilter:
output: '{result: (.taskgroup.tasks[0]| "report will be ready here -> " + $SECRET.mta_url + "/hub/applications/" + (.application.id|tostring) + "/bucket" + .data.output), repositoryURL: .repositoryURL}'
transition:
nextState: GetWorkflowOptions
type: operation
- actionMode: sequential
actions: null
end:
terminate: true
name: report
name: GetWorkflowOptions
stateDataFilter:
output: '{result: (.taskgroup.tasks[0]| "report will be ready here -> " + $SECRET.mta_url + "/hub/applications" + "/" + (.application.id|tostring) + "/bucket" + .data.output)}'
output: '{workflowOptions: {migrationOptions: [{id: "m2k", name: "Move2Kube workflow"}]}, repositoryURL: .repositoryURL}'
type: operation
timeouts:
workflowExecTimeout:
duration: PT1H
podTemplate:
container:
resources: {}
image: quay.io/orchestrator/serverless-workflow-mta:6bd8b5d7650139053fa8cdcc83dd8045bfcb7d2a
image: quay.io/orchestrator/serverless-workflow-mta:ff5932bd129ca62057596d28584fa43c7212b687
resources:
configMaps:
- configMap:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ data:
#quarkus.rest-client.mta_json.auth.basicAuth.password = password
#quarkus.log.category.\"org.apache.http\".level = DEBUG
quarkus.kubernetes-client.devservices.enabled = false
kind: ConfigMap
metadata:
creationTimestamp: null
Expand Down

0 comments on commit f7f0564

Please sign in to comment.