Skip to content

Commit

Permalink
Res Req specDesc field CPU injec empty str YAML
Browse files Browse the repository at this point in the history
  • Loading branch information
cyril-ui-developer committed Sep 2, 2020
1 parent dadba1c commit 7280d92
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,13 @@ export const ResourceRequirements: React.FC<ResourceRequirementsProps> = (props)

export const ResourceRequirementsModal = withHandlePromise(
(props: ResourceRequirementsModalProps) => {
const { obj, path, type, model } = props;
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`, ''));
const [memory, setMemory] = React.useState<string>(
_.get(obj.spec, `${path}.${type}.memory`, ''),
);
const { obj, path, type, model, close, handlePromise } = props;
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`));
const [memory, setMemory] = React.useState<string>(_.get(obj.spec, `${path}.${type}.memory`));
const [storage, setStorage] = React.useState<string>(
_.get(obj.spec, `${path}.${type}.ephemeral-storage`),
);
const unsetObj = (object, property) => _.unset(object, `spec.${path}.${type}.${property}`);

const submit = (e) => {
e.preventDefault();
Expand All @@ -99,7 +98,17 @@ export const ResourceRequirementsModal = withHandlePromise(
});
}

return props.handlePromise(k8sUpdate(model, newObj), props.close);
if (cpu === '') {
unsetObj(newObj, 'cpu');
}
if (memory === '') {
unsetObj(newObj, 'memory');
}
if (storage === '') {
unsetObj(newObj, 'ephemeral-storage');
}

return handlePromise(k8sUpdate(model, newObj), close);
};

return (
Expand Down

0 comments on commit 7280d92

Please sign in to comment.