Skip to content

Commit

Permalink
fix: update kptfile editor function selection logic (#172)
Browse files Browse the repository at this point in the history
This change updates the function selection logic in the Kptfile resource editor to avoid selecting a catalog function when a custom function has a similar name and tag however exists in a different repository.
  • Loading branch information
ChristopherFry authored Oct 10, 2022
1 parent 42e76b8 commit a04c4b0
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,21 +119,19 @@ export const KptFunctionEditorAccordion = ({
setFunctionNames(allFunctionNames);

if (stateImage.current) {
const fnName = getFunctionNameFromImage(stateImage.current);
const fnVersion = getFunctionVersionFromImage(stateImage.current);
const kptKnownFunction = allKptFunctions.find(
fn => fn.spec.image === stateImage.current,
);

if (allFunctionNames.includes(fnName)) {
const allFunctionVersionsForFunction = allKptFunctionsGroupedByName[
fnName
].map(fn => getFunctionVersionFromImage(fn.spec.image));
if (kptKnownFunction) {
const fnName = getFunctionNameFromImage(stateImage.current);
const fnVersion = getFunctionVersionFromImage(stateImage.current);

if (allFunctionVersionsForFunction.includes(fnVersion)) {
setFunctionNameSelected(fnName);
setFunctionVersionSelected(fnVersion);
}
setFunctionNameSelected(fnName);
setFunctionVersionSelected(fnVersion);
}
}
}, [allKptFunctionsGroupedByName]);
}, [allKptFunctionsGroupedByName, allKptFunctions]);

useEffect(() => {
let imageValue = customImageName;
Expand Down

0 comments on commit a04c4b0

Please sign in to comment.