Skip to content

Commit

Permalink
Merge pull request #2879 from richard-cox/fix-container-resource-limit
Browse files Browse the repository at this point in the history
Fix create/edit of resources that use ContainerResourceLimit
  • Loading branch information
richard-cox authored Apr 30, 2021
2 parents 60f49bc + 421179d commit ea2d4c0
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions components/ContainerResourceLimit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ export default {
this.$emit('input', cleanUp(out));
},
applyUnits(out, key, value, unit) {
if (value) {
out[key] = typeof value === 'string' ? value : `${ value }${ unit }`;
}
},
updateBeforeSave(value) {
const {
limitsCpu,
Expand All @@ -116,12 +122,13 @@ export default {
requestsMemory,
} = this;
const namespace = this.namespace; // no deep copy in destructure proxy yet
const out = {
limitsCpu: `${ limitsCpu }m`,
limitsMemory: `${ limitsMemory }Mi`,
requestsCpu: `${ requestsCpu }m`,
requestsMemory: `${ requestsMemory }Mi`,
};
const out = {};
this.applyUnits(out, 'limitsCpu', limitsCpu, 'm');
this.applyUnits(out, 'limitsMemory', limitsMemory, 'Mi');
this.applyUnits(out, 'requestsCpu', requestsCpu, 'Mi');
this.applyUnits(out, 'requestsMemory', requestsMemory, 'Mi');
if (namespace) {
namespace.setAnnotation(CONTAINER_DEFAULT_RESOURCE_LIMIT, JSON.stringify(out));
Expand Down

0 comments on commit ea2d4c0

Please sign in to comment.