Skip to content
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
27 changes: 23 additions & 4 deletions src/components/PipelineRun/components/ClonePipelineButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import useToastNotification from "@/hooks/useToastNotification";
import { useExecutionDataOptional } from "@/providers/ExecutionDataProvider";
import { copyRunToPipeline } from "@/services/pipelineRunService";
import { extractCanonicalName } from "@/utils/canonicalPipelineName";
import type { ComponentSpec } from "@/utils/componentSpec";
import {
type ArgumentType,
type ComponentSpec,
isSecretArgument,
} from "@/utils/componentSpec";
import { getInitialName } from "@/utils/getComponentName";
import { extractTaskArguments } from "@/utils/nodes/taskArguments";

Expand Down Expand Up @@ -53,11 +57,26 @@ export const ClonePipelineButton = ({
});

const handleClone = useCallback(() => {
const taskArguments = extractTaskArguments(
runDetails?.rootDetails?.task_spec.arguments,
/**
* We cannnot convert SecretArguments into strings compatible with inputs,
* so we need to override them with undefined.
*/
const secretArgumentsOverrides = Object.fromEntries(
Object.entries(runDetails?.rootDetails?.task_spec.arguments ?? {})
.filter(([_, value]) => isSecretArgument(value as ArgumentType))
.map(([key, _]) => [key, undefined] as const),
);

clonePipeline({ taskArguments });
const plainTaskArguments = extractTaskArguments(
runDetails?.rootDetails?.task_spec.arguments ?? {},
);

const taskArguments = {
...plainTaskArguments,
...secretArgumentsOverrides,
};

clonePipeline({ taskArguments: taskArguments as Record<string, string> });
}, [clonePipeline, runDetails]);

return (
Expand Down
13 changes: 11 additions & 2 deletions src/utils/nodes/taskArguments.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import type { TaskSpecOutput } from "@/api/types.gen";

import type { ComponentSpec } from "../componentSpec";
import {
type ArgumentType,
type ComponentSpec,
isSecretArgument,
} from "../componentSpec";

/**
* Gets the string value of a task argument.
Expand All @@ -17,11 +21,16 @@ export function getArgumentValue(
return undefined;
}

const argument = taskArguments?.[inputName];
const argument = taskArguments?.[inputName] as ArgumentType;

if (typeof argument === "string") {
return argument;
}

if (isSecretArgument(argument)) {
return `🔒 ${argument.dynamicData.secret.name}`;
}

return undefined;
}

Expand Down
Loading