store/cockpitApi: use existing blueprint converter

Use the blueprint existing blueprint converter to convert
the on-prem blueprint to the hosted blueprint
This commit is contained in:
Gianluca Zuccarelli 2024-12-18 21:29:33 +00:00 committed by Lucas Garfield
parent a9ebfb7e2e
commit 47156c4e95

View file

@ -17,6 +17,7 @@ import {
BlueprintItem,
} from './imageBuilderApi';
import { mapOnPremToHosted } from '../Components/Blueprints/helpers/onPremToHostedBlueprintMapper';
import { BLUEPRINTS_DIR } from '../constants';
const getBlueprintsPath = async () => {
@ -61,12 +62,12 @@ export const cockpitApi = emptyCockpitApi.injectEndpoints({
const parsed = toml.parse(contents);
file.close();
// TODO: using the existing blueprint converter
const blueprint = mapOnPremToHosted(parsed);
const version = (parsed.version as number) ?? 1;
return {
name: parsed.name as string,
...blueprint,
id: filename as string,
version: parsed.version as number,
description: parsed.description as string,
version: Math.floor(version),
last_modified_at: Date.now().toString(),
};
})