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

fix(orchestrator): execute should allow no inputs #73

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions workspaces/orchestrator/.changeset/chilly-donkeys-design.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@red-hat-developer-hub/backstage-plugin-orchestrator-backend': patch
'@red-hat-developer-hub/backstage-plugin-orchestrator-common': patch
---

execute API should allow no inputs
3 changes: 3 additions & 0 deletions workspaces/orchestrator/app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ backend:
connection: ':memory:'
cache:
store: memory
# useful for debugging APIs via curl in dev env without requiring a auth:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be achieved by https://backstage.io/docs/auth/service-to-service-auth#static-tokens
Very easy to set up and use.

# auth:
# dangerouslyDisableDefaultAuthPolicy: true
# workingDirectory: /tmp # Use this to configure a working directory for the scaffolder, defaults to the OS temp-dir

integrations: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export class OrchestratorService {
public async executeWorkflow(args: {
definitionId: string;
serviceUrl: string;
inputData: ProcessInstanceVariables;
inputData?: ProcessInstanceVariables;
businessKey?: string;
cacheHandler?: CacheHandler;
}): Promise<WorkflowExecutionResponse | undefined> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export class SonataFlowService {
public async executeWorkflow(args: {
definitionId: string;
serviceUrl: string;
inputData: ProcessInstanceVariables;
inputData?: ProcessInstanceVariables;
businessKey?: string;
}): Promise<WorkflowExecutionResponse | undefined> {
const urlToFetch = args.businessKey
Expand All @@ -101,7 +101,7 @@ export class SonataFlowService {

const response = await fetch(urlToFetch, {
method: 'POST',
body: JSON.stringify(args.inputData),
body: JSON.stringify(args.inputData || {}),
headers: { 'content-type': 'application/json' },
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,6 @@ export class V2 {
workflowId: string,
businessKey: string | undefined,
): Promise<ExecuteWorkflowResponseDTO> {
if (Object.keys(executeWorkflowRequestDTO?.inputData).length === 0) {
throw new Error(
`ExecuteWorkflowRequestDTO.inputData is required for executing workflow with id ${workflowId}`,
);
}

const definition = await this.orchestratorService.fetchWorkflowInfo({
definitionId: workflowId,
cacheHandler: 'throw',
Expand All @@ -182,7 +176,7 @@ export class V2 {
const executionResponse = await this.orchestratorService.executeWorkflow({
definitionId: workflowId,
inputData:
executeWorkflowRequestDTO?.inputData as ProcessInstanceVariables,
executeWorkflowRequestDTO.inputData as ProcessInstanceVariables,
serviceUrl: definition.serviceUrl,
businessKey,
cacheHandler: 'throw',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export interface ExecuteWorkflowRequestDTO {
// Warning: (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@type" is not defined in this configuration
// Warning: (tsdoc-undefined-tag) The TSDoc tag "@memberof" is not defined in this configuration
'inputData': object;
'inputData'?: object;
}

// Warning: (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f4fd9f652a05159a3d506540493e275885d54dcd
fc8d7c1e837b67d3de9b235126aeb829972a98ce

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export interface ExecuteWorkflowRequestDTO {
* @type {object}
* @memberof ExecuteWorkflowRequestDTO
*/
'inputData': object;
'inputData'?: object;
}
/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,6 @@
"description" : "The ErrorResponse object represents a common structure for handling errors in API responses. It includes essential information about the error, such as the error message and additional optional details."
};
defs["ExecuteWorkflowRequestDTO"] = {
"required" : [ "inputData" ],
"properties" : {
"inputData" : {
"type" : "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

| Name | Type | Description | Notes |
|------------ | ------------- | ------------- | -------------|
| **inputData** | [**Object**](.md) | | [default to null] |
| **inputData** | [**Object**](.md) | | [optional] [default to null] |

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,6 @@ components:
inputData:
type: object
additionalProperties: true
required:
- inputData
ExecuteWorkflowResponseDTO:
type: object
properties:
Expand Down