Skip to content

Commit c05b920

Browse files
committed
Fix deprecated packages
1 parent 7254eeb commit c05b920

File tree

9 files changed

+6078
-5808
lines changed

9 files changed

+6078
-5808
lines changed

package-lock.json

Lines changed: 3928 additions & 3529 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
"prepare": "npx husky install",
4242
"download:refapps": "cd packages && wget -q 'https://api.github.com/repos/scramjetorg/reference-apps/releases/latest' -O - | jq -r '.assets[].browser_download_url' | xargs -n 4 -P ${MAX_PARALLEL:-$(sysctl -n hw.ncpu 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || echo 1)} wget -q -nc",
4343
"test": "yarn test:packages",
44-
"test:packages": "scripts/run-script.js -S test",
45-
"test:packages-no-concurrent": "scripts/run-script.js -S -j 1 test",
44+
"test:packages": "scripts/run-script.js test",
45+
"test:packages-no-concurrent": "scripts/run-script.js -j 1 test",
4646
"test:bdd-ci-hub": "NO_HOST=true yarn --cwd=./bdd run test:bdd --format=@cucumber/pretty-formatter -t @ci-hub",
4747
"test:bdd-ci-api": "yarn test:bdd-ci-api-node",
4848
"test:bdd-ci-api-node": "yarn --cwd=./bdd run test:bdd --format=@cucumber/pretty-formatter -t @ci-api",
@@ -79,14 +79,13 @@
7979
"cloc": "^2.10.0",
8080
"eslint": "^8.55.0",
8181
"eslint-plugin-import": "^2.29.1",
82-
"eslint-to-editorconfig": "^2.0.0",
8382
"fs-extra": "^9.1.0",
8483
"glob": "^7.2.3",
8584
"globrex": "^0.1.2",
8685
"husky": "^6.0.0",
8786
"nyc": "^15.1.0",
88-
"semver": "^7.5.2",
89-
"tar": "^6.1.11",
87+
"semver": "^7.6.3",
88+
"tar": "^6.2.1",
9089
"toposort": "^2.0.2",
9190
"ts-node": "^10.9.1",
9291
"typescript": "~4.7.4",

packages/adapter-kubernetes/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"author": "Scramjet <[email protected]>",
1616
"license": "AGPL-3.0",
1717
"dependencies": {
18-
"@kubernetes/client-node": "^0.17.1",
18+
"@kubernetes/client-node": "^1.0.0",
1919
"@scramjet/adapters": "1.0.1",
2020
"@scramjet/obj-logger": "^1.0.1",
2121
"@scramjet/symbols": "^1.0.1",

packages/adapter-kubernetes/src/kubernetes-client-adapter.ts

Lines changed: 42 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ class KubernetesClientAdapter {
6363
const kubeApi = this.config.makeApiClient(k8s.CoreV1Api);
6464

6565
const result = await this.runWithRetries(retries, "Create Pod", () =>
66-
kubeApi.createNamespacedPod(this._namespace, {
67-
apiVersion: "v1",
68-
kind: "Pod",
69-
metadata,
70-
spec
66+
kubeApi.createNamespacedPod({
67+
namespace: this._namespace,
68+
body: {
69+
apiVersion: "v1",
70+
kind: "Pod",
71+
metadata,
72+
spec
73+
}
7174
})
7275
);
7376

@@ -81,7 +84,11 @@ class KubernetesClientAdapter {
8184
const kubeApi = this.config.makeApiClient(k8s.CoreV1Api);
8285

8386
const result = await this.runWithRetries(retries, "Delete Pod", () =>
84-
kubeApi.deleteNamespacedPod(podName, this._namespace, undefined, undefined, 0)
87+
kubeApi.deleteNamespacedPod({
88+
name: podName,
89+
namespace: this._namespace,
90+
gracePeriodSeconds: 0
91+
})
8592
);
8693

8794
return result as {
@@ -109,10 +116,13 @@ class KubernetesClientAdapter {
109116
// eslint-disable-next-line no-constant-condition
110117
while (true) {
111118
try {
112-
const response = await kubeApi.readNamespacedPodStatus(podName, this._namespace);
113-
const status = response.body.status?.phase || "";
119+
const response = await kubeApi.readNamespacedPodStatus({
120+
name: podName,
121+
namespace: this._namespace
122+
});
123+
const status = response.status?.phase || "";
114124

115-
const container = (response.body.status?.containerStatuses || []).find(c => c.name === podName);
125+
const container = (response.status?.containerStatuses || []).find(c => c.name === podName);
116126

117127
if (expectedStatuses.includes(status)) {
118128
return {
@@ -121,10 +131,10 @@ class KubernetesClientAdapter {
121131
};
122132
}
123133
} catch (err: any) {
124-
if (err instanceof k8s.HttpError) {
125-
this.logger.error(`Status for "${podName}" pod responded with error`, err?.body?.message);
134+
if (err instanceof k8s.FetchError) {
135+
this.logger.error(`Status for "${podName}" pod responded with error`, err?.message);
126136

127-
if (err.statusCode === 404) {
137+
if (err.errno === "404") {
128138
this.logger.error("Pod not found", podName);
129139
throw Error("Pod not found");
130140
}
@@ -145,31 +155,35 @@ class KubernetesClientAdapter {
145155

146156
async getPodLog(podName: string): Promise<string[]> {
147157
const kubeApi = this.config.makeApiClient(k8s.CoreV1Api);
148-
const response = await kubeApi.readNamespacedPodLog(
149-
podName, this._namespace,
150-
undefined, false, undefined, undefined,
151-
undefined, false, undefined,
152-
100, true
153-
);
154-
155-
return [response.body];
158+
const response = await kubeApi.readNamespacedPodLog({
159+
name: podName,
160+
namespace: this._namespace,
161+
follow: false,
162+
tailLines: 100
163+
});
164+
165+
return [response];
156166
}
157167

158168
async getPodTerminatedContainerReason(podName: string): Promise<string | undefined> {
159169
const kubeApi = this.config.makeApiClient(k8s.CoreV1Api);
160-
const response = await kubeApi.readNamespacedPod(podName, this._namespace);
170+
const response = await kubeApi.readNamespacedPod({
171+
name: podName,
172+
namespace: this._namespace
173+
});
161174

162-
return response.body.status?.containerStatuses?.[0].state?.terminated?.reason;
175+
return response.status?.containerStatuses?.[0].state?.terminated?.reason;
163176
}
164177

165178
async isPodsLimitReached(quotaName: string) {
166179
const kubeApi = this.config.makeApiClient(k8s.CoreV1Api);
167180

168181
try {
169-
const getQuotaPromise =
170-
await kubeApi.readNamespacedResourceQuota(quotaName, this._namespace);
171-
172-
const responseBody = getQuotaPromise.body;
182+
const responseBody =
183+
await kubeApi.readNamespacedResourceQuota({
184+
name: quotaName,
185+
namespace: this._namespace
186+
});
173187

174188
if (responseBody) {
175189
const used = parseInt(responseBody.status?.used?.pods || "", 10) || 0;
@@ -202,8 +216,8 @@ class KubernetesClientAdapter {
202216

203217
success = true;
204218
} catch (err: any) {
205-
if (err instanceof k8s.HttpError) {
206-
this.logger.error(`Running "${name}" responded with error`, err?.body?.message);
219+
if (err instanceof k8s.FetchError) {
220+
this.logger.error(`Running "${name}" responded with error`, err?.message);
207221
} else {
208222
this.logger.error(`Failed to run: ${name}.`, err);
209223
}

packages/cli/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@
3030
"find-package-json": "^1.2.0",
3131
"minimatch": "^3.1.2",
3232
"scramjet": "^4.37.0",
33-
"tar": "^6.1.11",
33+
"tar": "^6.2.1",
3434
"validator": "^13.7.0"
3535
},
3636
"devDependencies": {
3737
"@scramjet/types": "^1.0.1",
3838
"@types/find-package-json": "^1.2.3",
3939
"@types/minimatch": "^3.0.5",
4040
"@types/node": "15.12.5",
41-
"@types/tar": "^6.1.3",
41+
"@types/tar": "^6.1.13",
4242
"@types/validator": "^13.7.8",
4343
"ava": "^3.15.0",
4444
"ts-node": "^10.9.1",

packages/host/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
"@scramjet/utility": "^1.0.1",
3131
"@scramjet/verser": "^1.0.1",
3232
"bpmux": "^8.2.1",
33-
"ext-ip": "^0.3.9",
3433
"find-package-json": "^1.2.0",
3534
"http-status-codes": "^2.2.0",
3635
"minimist": "^1.2.6",

packages/host/src/lib/host.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,14 +1327,6 @@ export class Host implements IComponent {
13271327
this.telemetryAdapter = await getTelemetryAdapter(this.config.telemetry.adapter, this.config.telemetry);
13281328
this.telemetryAdapter.logger.pipe(this.logger);
13291329

1330-
const ipAddress = require("ext-ip")();
1331-
1332-
ipAddress.on("ip", (ip: any) => {
1333-
this.ipvAddress = ip;
1334-
});
1335-
1336-
await ipAddress();
1337-
13381330
this.logger.info(`Telemetry is active. Adapter: ${this.config.telemetry.adapter}`);
13391331

13401332
return;
@@ -1362,7 +1354,7 @@ export class Host implements IComponent {
13621354
version: this.version,
13631355
environment: this.telemetryEnvironmentName,
13641356
hostSize: this.hostSize,
1365-
ip: this.ipvAddress,
1357+
ip: "unsupported",
13661358
adapter: this.adapterName,
13671359
...labels
13681360
}

scripts/deps-update.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ if (opts.help || opts["long-help"]) {
168168
if (dep in localVersions) continue;
169169

170170
const [name, version] = dep;
171-
const newVersion = version.replace(/\d+\.\d+\.\d+[^\s]*/, lockFile.dependencies[dep[0]].version);
171+
const newVersion = version.replace(/\d+\.\d+\.\d+[^\s]*/, lockFile.packages[dep[0]].version);
172172

173173
newDeps[depType][name] = newVersion;
174174
}

0 commit comments

Comments
 (0)