scaffolder: rename dry-run contents -> directoryContents
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -36,12 +36,12 @@ import { resolveSafeChildPath } from '@backstage/backend-common';
|
||||
interface DryRunInput {
|
||||
spec: TaskSpec;
|
||||
secrets?: TaskSecrets;
|
||||
content: SerializedFile[];
|
||||
directoryContents: SerializedFile[];
|
||||
}
|
||||
|
||||
interface DryRunResult {
|
||||
log: JsonObject[];
|
||||
content: SerializedFile[];
|
||||
directoryContents: SerializedFile[];
|
||||
output: JsonObject;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ export function createDryRunner(options: TemplateTesterCreateOptions) {
|
||||
);
|
||||
|
||||
try {
|
||||
await deserializeDirectoryContents(contentsPath, input.content);
|
||||
await deserializeDirectoryContents(contentsPath, input.directoryContents);
|
||||
|
||||
const result = await workflowRunner.execute({
|
||||
spec: {
|
||||
@@ -130,11 +130,11 @@ export function createDryRunner(options: TemplateTesterCreateOptions) {
|
||||
if (!contentPromise) {
|
||||
throw new Error('Content extraction step was skipped');
|
||||
}
|
||||
const content = await contentPromise;
|
||||
const directoryContents = await contentPromise;
|
||||
|
||||
return {
|
||||
log,
|
||||
content,
|
||||
directoryContents,
|
||||
output: result.output,
|
||||
};
|
||||
} finally {
|
||||
|
||||
@@ -341,7 +341,7 @@ export async function createRouter(
|
||||
template: z.unknown(),
|
||||
values: z.record(z.unknown()),
|
||||
secrets: z.record(z.string()),
|
||||
content: z.array(
|
||||
directoryContents: z.array(
|
||||
z.object({ path: z.string(), base64Content: z.string() }),
|
||||
),
|
||||
});
|
||||
@@ -377,7 +377,7 @@ export async function createRouter(
|
||||
output: template.spec.output ?? {},
|
||||
parameters: body.values as JsonObject,
|
||||
},
|
||||
content: (body.content ?? []).map(file => ({
|
||||
directoryContents: (body.directoryContents ?? []).map(file => ({
|
||||
path: file.path,
|
||||
content: Buffer.from(file.base64Content, 'base64'),
|
||||
})),
|
||||
@@ -390,7 +390,7 @@ export async function createRouter(
|
||||
res.status(200).json({
|
||||
...result,
|
||||
steps,
|
||||
content: result.content.map(file => ({
|
||||
directoryContents: result.directoryContents.map(file => ({
|
||||
path: file.path,
|
||||
executable: file.executable,
|
||||
base64Content: file.content.toString('base64'),
|
||||
|
||||
@@ -187,7 +187,7 @@ export class ScaffolderClient implements ScaffolderApi {
|
||||
template: options.template,
|
||||
values: options.values,
|
||||
secrets: options.secrets,
|
||||
content: options.content,
|
||||
directoryContents: options.directoryContents,
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ export function DryRunProvider(props: DryRunProviderProps) {
|
||||
template: parsed,
|
||||
values: options.values,
|
||||
secrets: {},
|
||||
content: options.files.map(file => ({
|
||||
directoryContents: options.files.map(file => ({
|
||||
path: file.path,
|
||||
base64Content: btoa(file.content),
|
||||
})),
|
||||
|
||||
+6
-1
@@ -51,7 +51,12 @@ function DryRunRemote({
|
||||
}
|
||||
|
||||
const mockScaffolderApi = {
|
||||
dryRun: async () => ({ content: [], log: [], output: {}, steps: [] }),
|
||||
dryRun: async () => ({
|
||||
directoryContents: [],
|
||||
log: [],
|
||||
output: {},
|
||||
steps: [],
|
||||
}),
|
||||
};
|
||||
|
||||
describe('DryRunResults', () => {
|
||||
|
||||
+6
-1
@@ -40,7 +40,12 @@ function DryRunRemote({ execute }: { execute?: number }) {
|
||||
}
|
||||
|
||||
const mockScaffolderApi = {
|
||||
dryRun: async () => ({ content: [], log: [], output: {}, steps: [] }),
|
||||
dryRun: async () => ({
|
||||
directoryContents: [],
|
||||
log: [],
|
||||
output: {},
|
||||
steps: [],
|
||||
}),
|
||||
};
|
||||
|
||||
describe('DryRunResultsList', () => {
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ describe('DryRunResultsView', () => {
|
||||
scaffolderApiRef,
|
||||
{
|
||||
dryRun: async () => ({
|
||||
content: [
|
||||
directoryContents: [
|
||||
{
|
||||
path: 'foo.txt',
|
||||
base64Content: btoa('Foo Content'),
|
||||
|
||||
+3
-3
@@ -61,13 +61,13 @@ function FilesContent() {
|
||||
const classes = useStyles();
|
||||
const { selectedResult } = useDryRun();
|
||||
const [selectedPath, setSelectedPath] = useState<string>('');
|
||||
const selectedFile = selectedResult?.content.find(
|
||||
const selectedFile = selectedResult?.directoryContents.find(
|
||||
f => f.path === selectedPath,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedResult) {
|
||||
const [firstFile] = selectedResult.content;
|
||||
const [firstFile] = selectedResult.directoryContents;
|
||||
if (firstFile) {
|
||||
setSelectedPath(firstFile.path);
|
||||
} else {
|
||||
@@ -85,7 +85,7 @@ function FilesContent() {
|
||||
<FileBrowser
|
||||
selected={selectedPath}
|
||||
onSelect={setSelectedPath}
|
||||
filePaths={selectedResult.content.map(file => file.path)}
|
||||
filePaths={selectedResult.directoryContents.map(file => file.path)}
|
||||
/>
|
||||
<CodeMirror
|
||||
className={classes.codeMirror}
|
||||
|
||||
@@ -155,12 +155,12 @@ export interface ScaffolderDryRunOptions {
|
||||
template: JsonValue;
|
||||
values: JsonObject;
|
||||
secrets: JsonObject;
|
||||
content: { path: string; base64Content: string }[];
|
||||
directoryContents: { path: string; base64Content: string }[];
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface ScaffolderDryRunResponse {
|
||||
content: Array<{
|
||||
directoryContents: Array<{
|
||||
path: string;
|
||||
base64Content: string;
|
||||
executable: boolean;
|
||||
|
||||
Reference in New Issue
Block a user