Skip to content

Commit

Permalink
fix: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gajus committed Dec 12, 2019
1 parent f7ce704 commit 9845737
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 56 deletions.
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,26 @@
"dependencies": {
"bytes-iec": "^3.1.0",
"got": "^9.6.0",
"roarr": "^2.13.2"
"roarr": "^2.14.6"
},
"description": "Retrieves & observes Kubernetes Pod resource (CPU, memory) utilisation.",
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/node": "^7.4.5",
"@babel/plugin-transform-flow-strip-types": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/register": "^7.4.4",
"ava": "^2.1.0",
"babel-plugin-istanbul": "^5.1.4",
"coveralls": "^3.0.4",
"delay": "^4.2.0",
"eslint": "^5.16.0",
"eslint-config-canonical": "^17.1.0",
"flow-bin": "^0.100.0",
"flow-copy-source": "^2.0.6",
"@babel/cli": "^7.7.5",
"@babel/core": "^7.7.5",
"@babel/node": "^7.7.4",
"@babel/plugin-transform-flow-strip-types": "^7.7.4",
"@babel/preset-env": "^7.7.6",
"@babel/register": "^7.7.4",
"ava": "^2.4.0",
"babel-plugin-istanbul": "^5.2.0",
"coveralls": "^3.0.9",
"delay": "^4.3.0",
"eslint": "^6.7.2",
"eslint-config-canonical": "^18.1.0",
"flow-bin": "^0.113.0",
"flow-copy-source": "^2.0.9",
"nyc": "^14.1.1",
"semantic-release": "^15.13.12"
"semantic-release": "^15.13.31"
},
"engines": {
"node": ">6"
Expand Down
2 changes: 1 addition & 1 deletion src/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
import Roarr from 'roarr';

export default Roarr.child({
package: 'preoom'
package: 'preoom',
});
8 changes: 4 additions & 4 deletions src/factories/createHttpClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

import got from 'got';
import type {
HttpClientType
HttpClientType,
} from '../types';

export default (certificateAuthority: string, serviceAccountToken: string): HttpClientType => {
return async (url: string) => {
const response = await got(url, {
agent: false,
ca: [
certificateAuthority
certificateAuthority,
],
headers: {
Authorization: 'Bearer ' + serviceAccountToken
Authorization: 'Bearer ' + serviceAccountToken,
},
json: true,
rejectUnauthorized: true,
requestCert: true
requestCert: true,
});

return response.body;
Expand Down
20 changes: 10 additions & 10 deletions src/factories/createResourceObserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,39 @@
import {
getCredentials,
getPodResourceSpecification,
getPodResourceUsage as getUnboundPodResourceUsage
getPodResourceUsage as getUnboundPodResourceUsage,
} from '../services';
import Logger from '../Logger';
import type {
IntervalCallbackType
IntervalCallbackType,
} from '../types';
import createHttpClient from './createHttpClient';

const log = Logger.child({
namespace: 'createResourceObserver'
namespace: 'createResourceObserver',
});

const createContext = async () => {
const credentials = await getCredentials();
const httpClient = await createHttpClient(
credentials.serviceCertificateAuthority,
credentials.serviceAccountToken
credentials.serviceAccountToken,
);
const podResourceSpecification = await getPodResourceSpecification(
httpClient,
credentials.serviceUrl,
credentials.podNamespace,
credentials.podName
credentials.podName,
);

log.debug({
podResourceSpecification
podResourceSpecification,
}, 'pod resource specification');

return {
credentials,
httpClient,
podResourceSpecification
podResourceSpecification,
};
};

Expand All @@ -49,7 +49,7 @@ export default () => {
context.httpClient,
context.credentials.serviceUrl,
context.credentials.podNamespace,
context.credentials.podName
context.credentials.podName,
);

return podResourceUsage;
Expand All @@ -73,7 +73,7 @@ export default () => {

log.debug({
podResourceSpecification,
podResourceUsage
podResourceUsage,
}, 'observed resource usage');

// eslint-disable-next-line callback-return
Expand All @@ -92,6 +92,6 @@ export default () => {
return () => {
clearTimeout(timeout);
};
}
},
};
};
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @flow

export {
createResourceObserver
createResourceObserver,
} from './factories';
export {
isKubernetesCredentialsPresent
isKubernetesCredentialsPresent,
} from './utilities';
6 changes: 3 additions & 3 deletions src/services/getCredentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
/* eslint-disable no-process-env */

import {
read
read,
} from '../utilities';

type CredentialsType = {|
+podName: string,
+podNamespace: string,
+serviceAccountToken: string,
+serviceCertificateAuthority: string,
+serviceUrl: string
+serviceUrl: string,
|};

export default (): CredentialsType => {
Expand Down Expand Up @@ -54,6 +54,6 @@ export default (): CredentialsType => {
podNamespace,
serviceAccountToken,
serviceCertificateAuthority,
serviceUrl
serviceUrl,
};
};
14 changes: 7 additions & 7 deletions src/services/getPodResourceSpecification.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import {
parseBytes,
parseCpu
parseCpu,
} from '../utilities';
import type {
PodResourceSpecificationType,
HttpClientType
HttpClientType,
} from '../types';

export default async (httpClient: HttpClientType, serviceUrl: string, podNamespace: string, podName: string): Promise<PodResourceSpecificationType> => {
Expand All @@ -21,28 +21,28 @@ export default async (httpClient: HttpClientType, serviceUrl: string, podNamespa
if (container.resources.limits) {
limits = {
cpu: container.resources.limits.cpu ? parseCpu(container.resources.limits.cpu) : null,
memory: container.resources.limits.memory ? parseBytes(container.resources.limits.memory) : null
memory: container.resources.limits.memory ? parseBytes(container.resources.limits.memory) : null,
};
}

if (container.resources.requests) {
requests = {
cpu: container.resources.requests.cpu ? parseCpu(container.resources.requests.cpu) : null,
memory: container.resources.requests.memory ? parseBytes(container.resources.requests.memory) : null
memory: container.resources.requests.memory ? parseBytes(container.resources.requests.memory) : null,
};
}

containers.push({
name: container.name,
resources: {
limits,
requests
}
requests,
},
});
}

return {
containers,
name: podName
name: podName,
};
};
10 changes: 5 additions & 5 deletions src/services/getPodResourceUsage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import {
parseBytes,
parseCpu
parseCpu,
} from '../utilities';
import type {
PodResourceUsageType,
HttpClientType
HttpClientType,
} from '../types';

export default async (httpClient: HttpClientType, serviceUrl: string, podNamespace: string, podName: string): Promise<PodResourceUsageType> => {
Expand All @@ -19,13 +19,13 @@ export default async (httpClient: HttpClientType, serviceUrl: string, podNamespa
name: container.name,
usage: {
cpu: parseCpu(container.usage.cpu),
memory: parseBytes(container.usage.memory)
}
memory: parseBytes(container.usage.memory),
},
});
}

return {
containers,
name: podName
name: podName,
};
};
14 changes: 7 additions & 7 deletions src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,31 @@ type ContainerResourceUsageType = {|
+name: string,
+usage: {|
+cpu: number,
+memory: number
|}
+memory: number,
|},
|};

export type PodResourceUsageType = {|
+name: string,
+containers: $ReadOnlyArray<ContainerResourceUsageType>
+containers: $ReadOnlyArray<ContainerResourceUsageType>,
|};

type ResourceType = {|
+cpu: number | null,
+memory: number | null
+memory: number | null,
|};

type ContainerResourceSpecificationType = {|
+name: string,
+resources: {|
+limits: ResourceType | null,
+requests: ResourceType | null
|}
+requests: ResourceType | null,
|},
|};

export type PodResourceSpecificationType = {|
+containers: $ReadOnlyArray<ContainerResourceSpecificationType>,
+name: string
+name: string,
|};

export type IntervalCallbackType = (podResourceSpecification: PodResourceSpecificationType, podResourceUsage: PodResourceUsageType) => void;
2 changes: 1 addition & 1 deletion src/utilities/parseBytes.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow

import {
parse as parseBytes
parse as parseBytes,
} from 'bytes-iec';

export default (iecBytes: string) => {
Expand Down

0 comments on commit 9845737

Please sign in to comment.