New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@eclipse-che/che-code-devworkspace-handler

Package Overview
Dependencies
Maintainers
5
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@eclipse-che/che-code-devworkspace-handler - npm Package Compare versions

Comparing version 1.64.0-dev-cd9b148 to 1.64.0-dev-d133772

12

lib/devfile/dev-container-component-updater.js

@@ -137,7 +137,7 @@ "use strict";

// memory
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryLimit');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryRequest');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryLimit', 'memory');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryRequest', 'memory');
// cpu
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuLimit');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuRequest');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuLimit', 'cpu');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuRequest', 'cpu');
}

@@ -190,3 +190,3 @@ else {

*/
DevContainerComponentUpdater.prototype.addOrSum = function (from, toContainer, toAttributes, attributeName) {
DevContainerComponentUpdater.prototype.addOrSum = function (from, toContainer, toAttributes, attributeName, metrics) {
if (from[attributeName]) {

@@ -199,3 +199,3 @@ toAttributes["" + DevContainerComponentUpdater_1.CONTRIBUTE_PREFIX + attributeName] = true;

// add sum
toContainer[attributeName] = this.k8SUnits.sumUnits(from[attributeName], toContainer[attributeName]);
toContainer[attributeName] = this.k8SUnits.sumUnits(from[attributeName], toContainer[attributeName], metrics);
}

@@ -202,0 +202,0 @@ else {

@@ -66,8 +66,13 @@ "use strict";

};
K8SUnits.prototype.sumUnits = function (unit1, unit2) {
K8SUnits.prototype.sumUnits = function (unit1, unit2, metrics) {
// convert unit to simple unit
var sum = this.unitToNumber(unit1) + this.unitToNumber(unit2);
return this.format(sum);
if (metrics === 'memory') {
return this.formatMemory(sum);
}
else {
return this.formatCpu(sum);
}
};
K8SUnits.prototype.format = function (value, decimals) {
K8SUnits.prototype.formatMemory = function (value, decimals) {
if (decimals === void 0) { decimals = 2; }

@@ -91,2 +96,20 @@ if (value === 0) {

};
K8SUnits.prototype.formatCpu = function (value, decimals) {
if (decimals === void 0) { decimals = 2; }
if (value === 0) {
return '0';
}
var k = 1000;
var sizes;
sizes = ['', 'k', 'm'];
var dm = decimals < 0 ? 0 : decimals;
var i = Math.floor(Math.log(value) / Math.log(k));
var computedValue = parseFloat((value / Math.pow(k, i)).toFixed(dm));
if (i > 2) {
return computedValue * (i - 2) * 1000 + "m";
}
else {
return "" + parseFloat((value / Math.pow(k, i)).toFixed(dm)) + sizes[i];
}
};
K8SUnits.prototype.isBinaryUnit = function (value) {

@@ -93,0 +116,0 @@ var i = Math.floor(Math.log(value) / Math.log(1024));

{
"name": "@eclipse-che/che-code-devworkspace-handler",
"version": "1.64.0-dev-cd9b148",
"version": "1.64.0-dev-d133772",
"private": false,

@@ -77,2 +77,10 @@ "description": "Handle management of devWorkspace templates for che-code",

],
"coverageThreshold": {
"global": {
"branches": 100,
"functions": 100,
"lines": 100,
"statements": 100
}
},
"coverageDirectory": "coverage",

@@ -79,0 +87,0 @@ "modulePathIgnorePatterns": [

@@ -145,7 +145,19 @@ /**********************************************************************

// memory
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryLimit');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'memoryRequest');
this.addOrSum(
cheCodeDescriptionComponentContainer,
devContainer,
devContainerAttributes,
'memoryLimit',
'memory'
);
this.addOrSum(
cheCodeDescriptionComponentContainer,
devContainer,
devContainerAttributes,
'memoryRequest',
'memory'
);
// cpu
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuLimit');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuRequest');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuLimit', 'cpu');
this.addOrSum(cheCodeDescriptionComponentContainer, devContainer, devContainerAttributes, 'cpuRequest', 'cpu');
} else {

@@ -205,3 +217,4 @@ // add attributes with original memory

toAttributes: any,
attributeName: string
attributeName: string,
metrics: 'memory' | 'cpu'
) {

@@ -215,3 +228,3 @@ if (from[attributeName]) {

// add sum
toContainer[attributeName] = this.k8SUnits.sumUnits(from[attributeName], toContainer[attributeName]);
toContainer[attributeName] = this.k8SUnits.sumUnits(from[attributeName], toContainer[attributeName], metrics);
} else {

@@ -218,0 +231,0 @@ // use value

@@ -63,9 +63,13 @@ /**********************************************************************

sumUnits(unit1: string, unit2: string): string {
sumUnits(unit1: string, unit2: string, metrics: 'memory' | 'cpu'): string {
// convert unit to simple unit
const sum = this.unitToNumber(unit1) + this.unitToNumber(unit2);
return this.format(sum);
if (metrics === 'memory') {
return this.formatMemory(sum);
} else {
return this.formatCpu(sum);
}
}
format(value: number, decimals = 2) {
formatMemory(value: number, decimals = 2) {
if (value === 0) {

@@ -89,2 +93,20 @@ return '0';

formatCpu(value: number, decimals = 2) {
if (value === 0) {
return '0';
}
const k = 1000;
let sizes: string[];
sizes = ['', 'k', 'm'];
const dm = decimals < 0 ? 0 : decimals;
const i = Math.floor(Math.log(value) / Math.log(k));
let computedValue = parseFloat((value / Math.pow(k, i)).toFixed(dm));
if (i > 2) {
return `${computedValue * (i - 2) * 1000}m`;
} else {
return `${parseFloat((value / Math.pow(k, i)).toFixed(dm))}${sizes[i]}`;
}
}
isBinaryUnit(value: number) {

@@ -91,0 +113,0 @@ const i = Math.floor(Math.log(value) / Math.log(1024));

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc