removed wait-action

Signed-off-by: Hao Luo <howlowck@gmail.com>
This commit is contained in:
Hao Luo
2022-10-17 17:01:19 -05:00
parent a0d7fc3965
commit 57f61203bc
5 changed files with 0 additions and 165 deletions
@@ -6,7 +6,6 @@ metadata:
spec:
targets:
- ./remote-templates.yaml
- ./longrunning-demo/wait-action.yaml
# For local development of a template, you can reference your local templates here.
# Examples:
#
@@ -1,43 +0,0 @@
apiVersion: scaffolder.backstage.io/v1beta3
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
kind: Template
metadata:
name: wait-action
title: wait-action
description: template with a waiting task for a long running action
spec:
owner: user:guest
type: service
# These parameters are used to generate the input form in the frontend, and are
# used to gather input data for the execution of the template.
parameters:
- title: Fill in some steps
required:
- name
properties:
name:
title: Name
type: string
description: Unique name of the component
default: some value
ui:autofocus: true
ui:options:
rows: 5
# These steps are executed in the scaffolder backend, using data that we gathered
# via the parameters above.
steps:
- id: someAsyncCall
name: Some Async Call
action: debug:log
input:
message: Some async call that return a tickedId (guid, for instance, that identifies a process)
- id: waitWorkflow
name: Wait Creation
action: stress:waitWorkflow
input:
name: 'test' #${{ steps.someAsyncCall.output.ticketId }}
delayMilliseconds: 1000
maxCalls: 30
@@ -55,7 +55,6 @@ import {
createPublishGitlabAction,
createPublishGitlabMergeRequestAction,
} from './publish';
import { waitWorkflow } from './stress';
/**
* The options passed to {@link createBuiltinActions}
@@ -185,7 +184,6 @@ export const createBuiltinActions = (
config,
githubCredentialsProvider,
}),
waitWorkflow(),
];
return actions as TemplateAction<JsonObject>[];
@@ -1,17 +0,0 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
export { waitWorkflow } from './waitWorkflow';
@@ -1,102 +0,0 @@
/*
* Copyright 2021 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { createTemplateAction } from '../../createTemplateAction';
export function waitWorkflow() {
type InputParameters = {
name: string;
delayMilliseconds: number;
maxCalls: number;
};
return createTemplateAction<InputParameters>({
id: 'stress:waitWorkflow',
schema: {
input: {
required: ['name'],
type: 'object',
properties: {
name: {
type: 'string',
title: 'Name',
description:
'The Ticket Number used to check the status of the Workflow.',
},
delayMilliseconds: {
type: 'number',
title: 'Delay',
description:
'The amount of milliseconds to delay before the next checkStatus call.',
},
maxCalls: {
type: 'number',
title: 'Max Calls',
description:
'The amount of maximum calls allowed to check a status before stopping.',
},
},
},
output: {
type: 'object',
properties: {
status: {
title: 'Status',
type: 'object',
properties: {
message: {
title: 'Status Message',
type: 'string',
},
},
},
results: {
title: 'Results from Ticket execution',
type: 'object',
},
},
},
},
async handler(ctx) {
const { name, maxCalls, delayMilliseconds } = getParameters(ctx.input);
ctx.logger.info(`Running the long running workflow: ${name}...`);
let i = 1;
for (;;) {
ctx.logger.info(`waiting... [${i}/${maxCalls}]`);
if (i++ >= maxCalls) {
break;
}
await new Promise(res => setTimeout(res, delayMilliseconds));
}
ctx.output('status.message', 'Workflow completed');
},
});
function getParameters(input: InputParameters) {
const { name, delayMilliseconds, maxCalls } = input;
return {
name,
maxCalls: maxCalls ?? 30,
delayMilliseconds: delayMilliseconds ?? 2000,
};
}
}