Skip to content

Commit

Permalink
bugfixes/save-template-error (#79)
Browse files Browse the repository at this point in the history
* fix error when saving template with empty env

* fix persistent storage sdl import
  • Loading branch information
baktun14 authored Jan 18, 2024
1 parent 6ffcba5 commit d644be8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { Alert, Box, Button, CircularProgress } from "@mui/material";
import { SimpleServiceFormControl } from "../sdl/SimpleServiceFormControl";
import { useProviderAttributesSchema } from "@src/queries/useProvidersQuery";
import { importSimpleSdl } from "@src/utils/sdl/sdlImport";
import { Subscription } from "react-hook-form/dist/utils/createSubject";

interface Props {
sdlString: string;
Expand Down
2 changes: 1 addition & 1 deletion deploy-web/src/hooks/useShortText.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const getShortText = (text: string, length: number) => {
export const getShortText = (text: string = "", length: number) => {
return text.length < length ? text : `${text.substring(0, length - 3)}...`;
};

Expand Down
9 changes: 5 additions & 4 deletions deploy-web/src/utils/sdl/sdlImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ export const importSimpleSdl = (yamlStr: string, providerAttributesSchema: Provi

const compute = yamlJson.profiles.compute[svcName];
const storages = compute.resources.storage.map ? compute.resources.storage : [compute.resources.storage];
const hasPersistentStorage = storages.some(s => s.attributes?.persistent === true);
const persistentStorage = storages.find(s => s.attributes?.persistent === true);
const hasPersistentStorage = !!persistentStorage;
const ephStorage = storages.find(s => !s.attributes);
const persistentStorageName = hasPersistentStorage ? persistentStorage.name : "data";

// TODO validation
// Service compute profile
Expand All @@ -43,10 +44,10 @@ export const importSimpleSdl = (yamlStr: string, providerAttributesSchema: Provi
persistentStorage: hasPersistentStorage ? getResourceDigit(persistentStorage?.size) : 10,
persistentStorageUnit: hasPersistentStorage ? getResourceUnit(persistentStorage?.size) : "Gi",
persistentStorageParam: {
name: hasPersistentStorage ? persistentStorage?.name : "data",
name: persistentStorageName,
type: hasPersistentStorage ? persistentStorage?.attributes?.class : "beta2",
mount: hasPersistentStorage ? svc.params?.storage?.data?.mount : "",
readOnly: hasPersistentStorage ? svc.params?.storage?.data?.readOnly : false
mount: hasPersistentStorage ? svc.params?.storage[persistentStorageName]?.mount : "",
readOnly: hasPersistentStorage ? svc.params?.storage[persistentStorageName]?.readOnly : false
}
};

Expand Down

0 comments on commit d644be8

Please sign in to comment.