-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(orchestrator): resolve mismatch between execution data and compos…
…ed schema (#1217) fix(orchestrator): resolve mismatch between workflow data and composed schemas
- Loading branch information
Showing
17 changed files
with
1,674 additions
and
839 deletions.
There are no files selected for viewing
132 changes: 132 additions & 0 deletions
132
plugins/orchestrator-backend/__fixtures__/mockComposedGreetingWorfklow.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
import { JsonObject } from '@backstage/types'; | ||
|
||
import { JSONSchema7 } from 'json-schema'; | ||
|
||
import { WorkflowItem } from '@janus-idp/backstage-plugin-orchestrator-common'; | ||
|
||
const schema = { | ||
$id: 'classpath:/schemas/yamlgreet__main-schema.json', | ||
title: 'Data Input Schema', | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
type: 'object', | ||
properties: { | ||
language: { | ||
type: 'object', | ||
properties: { | ||
language: { | ||
title: 'Language', | ||
description: 'Language to greet', | ||
type: 'string', | ||
enum: ['English', 'Spanish'], | ||
default: 'English', | ||
}, | ||
}, | ||
title: 'Language', | ||
}, | ||
name: { | ||
type: 'object', | ||
properties: { | ||
name: { | ||
title: 'Name', | ||
description: 'Name of the person', | ||
type: 'string', | ||
default: 'John Doe', | ||
}, | ||
}, | ||
}, | ||
}, | ||
required: ['name'], | ||
} as JSONSchema7; | ||
|
||
const workflowItem = { | ||
uri: 'yamlgreet.sw.yaml', | ||
definition: { | ||
id: 'yamlgreet', | ||
version: '1.0', | ||
specVersion: '0.8', | ||
name: 'Greeting workflow', | ||
description: 'YAML based greeting workflow', | ||
dataInputSchema: 'schemas/yamlgreet__main-schema.json', | ||
start: 'ChooseOnLanguage', | ||
functions: [ | ||
{ | ||
name: 'greetFunction', | ||
type: 'custom', | ||
operation: 'sysout', | ||
}, | ||
], | ||
states: [ | ||
{ | ||
name: 'ChooseOnLanguage', | ||
type: 'switch', | ||
dataConditions: [ | ||
{ | ||
condition: '${ .language.language == "English" }', | ||
transition: 'GreetInEnglish', | ||
}, | ||
{ | ||
condition: '${ .language.language == "Spanish" }', | ||
transition: 'GreetInSpanish', | ||
}, | ||
], | ||
defaultCondition: { | ||
transition: 'GreetInEnglish', | ||
}, | ||
}, | ||
{ | ||
name: 'GreetInEnglish', | ||
type: 'inject', | ||
data: { | ||
greeting: 'Hello from YAML Workflow, ', | ||
}, | ||
transition: 'GreetPerson', | ||
}, | ||
{ | ||
name: 'GreetInSpanish', | ||
type: 'inject', | ||
data: { | ||
greeting: 'Saludos desde YAML Workflow, ', | ||
}, | ||
transition: 'GreetPerson', | ||
}, | ||
{ | ||
name: 'GreetPerson', | ||
type: 'operation', | ||
actions: [ | ||
{ | ||
name: 'greetAction', | ||
functionRef: { | ||
refName: 'greetFunction', | ||
arguments: { | ||
message: '.greeting+.name.name', | ||
}, | ||
}, | ||
}, | ||
], | ||
end: { | ||
terminate: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
} as WorkflowItem; | ||
|
||
const variables = { | ||
workflowdata: { | ||
name: { | ||
name: 'John Doe', | ||
}, | ||
language: { | ||
language: 'Spanish', | ||
}, | ||
greeting: 'hello', | ||
}, | ||
}; | ||
|
||
const mockData: { | ||
schema: JSONSchema7; | ||
workflowItem: WorkflowItem; | ||
variables: JsonObject; | ||
} = { schema, workflowItem, variables }; | ||
|
||
export default mockData; |
117 changes: 117 additions & 0 deletions
117
plugins/orchestrator-backend/__fixtures__/mockGreetingWorkflowData.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
import { JsonObject } from '@backstage/types'; | ||
|
||
import { JSONSchema7 } from 'json-schema'; | ||
|
||
import { WorkflowItem } from '@janus-idp/backstage-plugin-orchestrator-common'; | ||
|
||
const schema = { | ||
$id: 'classpath:/schemas/yamlgreet__main-schema.json', | ||
title: 'Data Input Schema', | ||
$schema: 'http://json-schema.org/draft-07/schema#', | ||
type: 'object', | ||
properties: { | ||
language: { | ||
title: 'Language', | ||
description: 'Language to greet', | ||
type: 'string', | ||
enum: ['English', 'Spanish'], | ||
default: 'English', | ||
}, | ||
name: { | ||
title: 'Name', | ||
description: 'Name of the person', | ||
type: 'string', | ||
default: 'John Doe', | ||
}, | ||
}, | ||
required: ['name'], | ||
} as JSONSchema7; | ||
|
||
const workflowItem = { | ||
uri: 'yamlgreet.sw.yaml', | ||
definition: { | ||
id: 'yamlgreet', | ||
version: '1.0', | ||
specVersion: '0.8', | ||
name: 'Greeting workflow', | ||
description: 'YAML based greeting workflow', | ||
dataInputSchema: 'schemas/yamlgreet__main-schema.json', | ||
start: 'ChooseOnLanguage', | ||
functions: [ | ||
{ | ||
name: 'greetFunction', | ||
type: 'custom', | ||
operation: 'sysout', | ||
}, | ||
], | ||
states: [ | ||
{ | ||
name: 'ChooseOnLanguage', | ||
type: 'switch', | ||
dataConditions: [ | ||
{ | ||
condition: '${ .language == "English" }', | ||
transition: 'GreetInEnglish', | ||
}, | ||
{ | ||
condition: '${ .language == "Spanish" }', | ||
transition: 'GreetInSpanish', | ||
}, | ||
], | ||
defaultCondition: { | ||
transition: 'GreetInEnglish', | ||
}, | ||
}, | ||
{ | ||
name: 'GreetInEnglish', | ||
type: 'inject', | ||
data: { | ||
greeting: 'Hello from YAML Workflow, ', | ||
}, | ||
transition: 'GreetPerson', | ||
}, | ||
{ | ||
name: 'GreetInSpanish', | ||
type: 'inject', | ||
data: { | ||
greeting: 'Saludos desde YAML Workflow, ', | ||
}, | ||
transition: 'GreetPerson', | ||
}, | ||
{ | ||
name: 'GreetPerson', | ||
type: 'operation', | ||
actions: [ | ||
{ | ||
name: 'greetAction', | ||
functionRef: { | ||
refName: 'greetFunction', | ||
arguments: { | ||
message: '.greeting+.name', | ||
}, | ||
}, | ||
}, | ||
], | ||
end: { | ||
terminate: true, | ||
}, | ||
}, | ||
], | ||
}, | ||
} as WorkflowItem; | ||
|
||
const variables = { | ||
workflowdata: { | ||
name: 'John Doe', | ||
greeting: 'Saludos desde YAML Workflow, ', | ||
language: 'Spanish', | ||
}, | ||
}; | ||
|
||
const mockData: { | ||
schema: JSONSchema7; | ||
workflowItem: WorkflowItem; | ||
variables: JsonObject; | ||
} = { schema, workflowItem, variables }; | ||
|
||
export default mockData; |
Oops, something went wrong.