Skip to content

Commit 2f1b5cd

Browse files
authored
KubernetesV1 task Node 24 migration (#21714)
* fix(KubernetesV1): Update TestSetup.ts for Node 24 compatibility - Replace deprecated fs.Stats constructor with plain object to avoid DEP0180 deprecation warning in Node 24 - Fix writeFileSync mock to use flexible path matching instead of exact match, resolving path format mismatches across platforms These changes fix test failures when running under Node 24. * Bumped the task version * chore(KubernetesV1): Update dependencies for Node 24 support - Update @types/node from ^20.3.1 to ^24.10.0 - Update azure-pipelines-task-lib from ^4.16.0 to ^5.2.4 - Update azure-pipelines-tasks-kubernetes-common from ^2.252.0 to ^2.267.0 - Update typescript from 5.1.6 to ^5.7.2 These dependency updates enable Node 24 runtime support and address security vulnerabilities in transitive dependencies. * chore(KubernetesV1): Add rm entries for nested kubernetes-common dependencies - Remove nested azure-pipelines-tool-lib from kubernetes-common - Remove nested azure-devops-node-api from kubernetes-common Prevents singleton conflicts when running with Node 24. * chore(KubernetesV1): Regenerate package-lock.json with Azure DevOps registry Regenerated package-lock.json to resolve dependencies from the correct Azure DevOps registry (pkgs.dev.azure.com/mseng/PipelineTools) instead of registry.npmjs.org. This ensures CI pipeline compatibility and proper dependency resolution.
1 parent 977a359 commit 2f1b5cd

File tree

6 files changed

+1049
-261
lines changed

6 files changed

+1049
-261
lines changed

Tasks/KubernetesV1/Tests/TestSetup.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import * as shared from './TestShared';
55
const querystring = require("querystring");
66

77
var nock = require("nock");
8-
var Stats = require('fs').Stats;
98

109
const DefaultWorkingDirectory: string = shared.formatPath("a/w");
1110
const ConfigurationFilePath = shared.formatPath("dir/deployment.yaml");
@@ -275,13 +274,15 @@ fsClone.existsSync = function(filePath) {
275274
};
276275

277276
fsClone.writeFileSync = function(fileName, data) {
278-
switch (fileName) {
279-
case KubconfigFile:
280-
console.log("Content of kubeconfig file : " + data);
281-
break;
282-
default:
283-
return fs.writeFileSync(fileName, data);
277+
// Normalize paths for comparison (handle both Windows and Unix style paths)
278+
const normalizedFileName = path.normalize(fileName);
279+
const normalizedKubconfigFile = path.normalize(KubconfigFile);
280+
281+
if (normalizedFileName.endsWith('config') || normalizedFileName === normalizedKubconfigFile) {
282+
console.log("Content of kubeconfig file : " + data);
283+
return;
284284
}
285+
return fs.writeFileSync(fileName, data);
285286
};
286287

287288
fsClone.chmodSync = function (path, mode) {
@@ -298,25 +299,24 @@ fsClone.chmodSync = function (path, mode) {
298299
};
299300

300301
fsClone.statSync = (s: string) => {
301-
let stat = new Stats;
302-
303-
stat.isFile = () => {
304-
if (s.endsWith('.properties')) {
305-
return true;
306-
} else {
307-
return false;
308-
}
309-
}
310-
311-
stat.isDirectory = () => {
312-
if (s.endsWith('.properties')) {
313-
return false;
314-
} else {
315-
return true;
316-
}
317-
}
318-
319-
stat.size = 100;
302+
// Create a mock stats object instead of using deprecated Stats constructor
303+
const stat = {
304+
isFile: () => {
305+
if (s.endsWith('.properties')) {
306+
return true;
307+
} else {
308+
return false;
309+
}
310+
},
311+
isDirectory: () => {
312+
if (s.endsWith('.properties')) {
313+
return false;
314+
} else {
315+
return true;
316+
}
317+
},
318+
size: 100
319+
};
320320

321321
return stat;
322322
}

Tasks/KubernetesV1/make.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
"node_modules/azure-pipelines-tasks-utility-common/node_modules/azure-pipelines-task-lib",
99
"node_modules/azure-pipelines-tool-lib/node_modules/azure-pipelines-task-lib",
1010
"node_modules/azure-pipelines-tasks-azure-arm-rest/node_modules/agent-base",
11-
"node_modules/https-proxy-agent/node_modules/agent-base"
11+
"node_modules/https-proxy-agent/node_modules/agent-base",
12+
"node_modules/azure-pipelines-tasks-kubernetes-common/node_modules/azure-pipelines-tool-lib",
13+
"node_modules/azure-pipelines-tasks-kubernetes-common/node_modules/azure-devops-node-api"
1214
],
1315
"options": "-Rf"
1416
}

0 commit comments

Comments
 (0)