scaffolder-backend: move actions to separate actions dir
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
committed by
Johan Haals
parent
8b003875a8
commit
e0c8c6c164
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2021 Spotify AB
|
||||
*
|
||||
* 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 {
|
||||
createCatalogRegisterAction,
|
||||
createFetchCookiecutterAction,
|
||||
createFetchPlainAction,
|
||||
createPublishGithubAction,
|
||||
} from './builtin';
|
||||
export { TemplateActionRegistry } from './TemplateActionRegistry';
|
||||
export type { ActionContext, TemplateAction } from './types';
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2021 Spotify AB
|
||||
*
|
||||
* 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 { Logger } from 'winston';
|
||||
import { Writable } from 'stream';
|
||||
import { JsonValue } from '@backstage/config';
|
||||
|
||||
export type ActionContext = {
|
||||
/**
|
||||
* Base URL for the location of the task spec, typically the url of the source entity file.
|
||||
*/
|
||||
baseUrl?: string;
|
||||
|
||||
logger: Logger;
|
||||
logStream: Writable;
|
||||
|
||||
workspacePath: string;
|
||||
parameters: { [name: string]: JsonValue };
|
||||
output(name: string, value: JsonValue): void;
|
||||
|
||||
/**
|
||||
* Creates a temporary directory for use by the action, which is then cleaned up automatically.
|
||||
*/
|
||||
createTemporaryDirectory(): Promise<string>;
|
||||
};
|
||||
|
||||
export type TemplateAction = {
|
||||
id: string;
|
||||
handler: (ctx: ActionContext) => Promise<void>;
|
||||
};
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { TemplateActionRegistry } from '../tasks/TemplateActionRegistry';
|
||||
import { TemplateActionRegistry } from '../actions/TemplateActionRegistry';
|
||||
import { FilePreparer, PreparerBuilder } from './prepare';
|
||||
import Docker from 'dockerode';
|
||||
import { TemplaterBuilder, TemplaterValues } from './templater';
|
||||
|
||||
@@ -21,7 +21,7 @@ import { JsonValue, JsonObject } from '@backstage/config';
|
||||
import { TaskBroker, Task } from './types';
|
||||
import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import { TemplateActionRegistry } from './TemplateActionRegistry';
|
||||
import { TemplateActionRegistry } from '../actions/TemplateActionRegistry';
|
||||
import * as handlebars from 'handlebars';
|
||||
|
||||
type Options = {
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
|
||||
import { JsonValue, JsonObject } from '@backstage/config';
|
||||
import { Logger } from 'winston';
|
||||
import { Writable } from 'stream';
|
||||
|
||||
export type Status =
|
||||
| 'open'
|
||||
@@ -93,6 +91,7 @@ export type TaskStoreGetEventsOptions = {
|
||||
taskId: string;
|
||||
after?: number | undefined;
|
||||
};
|
||||
|
||||
export interface TaskStore {
|
||||
createTask(task: TaskSpec): Promise<{ taskId: string }>;
|
||||
getTask(taskId: string): Promise<DbTaskRow>;
|
||||
@@ -115,27 +114,3 @@ export interface TaskStore {
|
||||
after,
|
||||
}: TaskStoreGetEventsOptions): Promise<{ events: DbTaskEventRow[] }>;
|
||||
}
|
||||
|
||||
export type ActionContext = {
|
||||
/**
|
||||
* Base URL for the location of the task spec, typically the url of the source entity file.
|
||||
*/
|
||||
baseUrl?: string;
|
||||
|
||||
logger: Logger;
|
||||
logStream: Writable;
|
||||
|
||||
workspacePath: string;
|
||||
parameters: { [name: string]: JsonValue };
|
||||
output(name: string, value: JsonValue): void;
|
||||
|
||||
/**
|
||||
* Creates a temporary directory for use by the action, which is then cleaned up automatically.
|
||||
*/
|
||||
createTemporaryDirectory(): Promise<string>;
|
||||
};
|
||||
|
||||
export type TemplateAction = {
|
||||
id: string;
|
||||
handler: (ctx: ActionContext) => Promise<void>;
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ import {
|
||||
TaskWorker,
|
||||
} from '../scaffolder/tasks';
|
||||
import { templateEntityToSpec } from '../scaffolder/tasks/TemplateConverter';
|
||||
import { TemplateActionRegistry } from '../scaffolder/tasks/TemplateActionRegistry';
|
||||
import { TemplateActionRegistry } from '../scaffolder/actions/TemplateActionRegistry';
|
||||
import { registerLegacyActions } from '../scaffolder/stages/legacy';
|
||||
import { getEntityBaseUrl, getWorkingDirectory } from './helpers';
|
||||
import {
|
||||
@@ -59,7 +59,7 @@ import {
|
||||
createFetchCookiecutterAction,
|
||||
createPublishGithubAction,
|
||||
createCatalogRegisterAction,
|
||||
} from '../scaffolder/tasks/builtin';
|
||||
} from '../scaffolder/actions/builtin';
|
||||
import { ScmIntegrations } from '@backstage/integration';
|
||||
|
||||
export interface RouterOptions {
|
||||
|
||||
Reference in New Issue
Block a user