diff --git a/examples/typescript/apply/apply-from-file-example.ts b/examples/typescript/apply/apply-from-file-example.ts index bda15da027..a2eec70d2c 100644 --- a/examples/typescript/apply/apply-from-file-example.ts +++ b/examples/typescript/apply/apply-from-file-example.ts @@ -1,7 +1,7 @@ // in a real program use require('@kubernetes/client-node') import * as k8s from '../../../dist'; import * as yaml from 'js-yaml'; -import { promises as fs } from 'fs'; +import * as fs from 'node:fs/promises'; /** * Replicate the functionality of `kubectl apply`. That is, create the resources defined in the `specFile` if they do @@ -51,4 +51,4 @@ export async function apply(specPath: string): Promise { } return created; -} \ No newline at end of file +} diff --git a/examples/typescript/exec/exec-example.ts b/examples/typescript/exec/exec-example.ts index 6b1d72d655..ed1767dc04 100644 --- a/examples/typescript/exec/exec-example.ts +++ b/examples/typescript/exec/exec-example.ts @@ -1,6 +1,6 @@ // in a real program use require('@kubernetes/client-node') import * as k8s from '../../../dist'; -import * as stream from 'stream'; +import * as stream from 'node:stream'; const command = process.argv[2]; diff --git a/examples/typescript/port-forward/port-forward.ts b/examples/typescript/port-forward/port-forward.ts index 459dc486af..18ed1ea1d9 100644 --- a/examples/typescript/port-forward/port-forward.ts +++ b/examples/typescript/port-forward/port-forward.ts @@ -1,6 +1,6 @@ // in a real program use require('@kubernetes/client-node') import * as k8s from '../../../dist'; -import * as net from 'net'; +import * as net from 'node:net'; const kc = new k8s.KubeConfig(); kc.loadFromDefault(); diff --git a/src/attach.ts b/src/attach.ts index a49e6de460..fc119bcf69 100644 --- a/src/attach.ts +++ b/src/attach.ts @@ -1,6 +1,6 @@ import WebSocket = require('isomorphic-ws'); -import querystring = require('querystring'); -import stream = require('stream'); +import querystring = require('node:querystring'); +import stream = require('node:stream'); import { KubeConfig } from './config'; import { isResizable, ResizableStream, TerminalSizeQueue } from './terminal-size-queue'; diff --git a/src/auth.ts b/src/auth.ts index f33cad6c67..2d1e8fd9fa 100644 --- a/src/auth.ts +++ b/src/auth.ts @@ -1,4 +1,4 @@ -import https = require('https'); +import https = require('node:https'); import { User } from './config_types'; import WebSocket = require('isomorphic-ws'); diff --git a/src/azure_auth.ts b/src/azure_auth.ts index 0b571ea16e..6b7355d417 100644 --- a/src/azure_auth.ts +++ b/src/azure_auth.ts @@ -1,5 +1,5 @@ -import * as proc from 'child_process'; -import https = require('https'); +import * as proc from 'node:child_process'; +import https = require('node:https'); import * as jsonpath from 'jsonpath-plus'; import { Authenticator } from './auth'; diff --git a/src/azure_auth_test.ts b/src/azure_auth_test.ts index 9cd7942b77..48d0598c96 100644 --- a/src/azure_auth_test.ts +++ b/src/azure_auth_test.ts @@ -1,6 +1,6 @@ import { use, expect } from 'chai'; import chaiAsPromised from 'chai-as-promised'; -import { join } from 'path'; +import { join } from 'node:path'; import { User, Cluster } from './config_types'; import { AzureAuth } from './azure_auth'; diff --git a/src/cache_test.ts b/src/cache_test.ts index a4eaee11c2..113353af4a 100644 --- a/src/cache_test.ts +++ b/src/cache_test.ts @@ -3,8 +3,6 @@ import chaiAsPromised = require('chai-as-promised'); import * as mock from 'ts-mockito'; -import http = require('http'); - import { V1ListMeta, V1Namespace, V1NamespaceList, V1ObjectMeta, V1Pod } from './api'; import { deleteItems, deleteObject, ListWatch } from './cache'; import { KubeConfig } from './config'; diff --git a/src/config.ts b/src/config.ts index 3cd331fdc9..97d9cab546 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,8 @@ -import fs = require('fs'); -import https = require('https'); +import fs = require('node:fs'); +import https = require('node:https'); import yaml = require('js-yaml'); -import net = require('net'); -import path = require('path'); +import net = require('node:net'); +import path = require('node:path'); import { Headers, RequestInit } from 'node-fetch'; import * as api from './api'; @@ -32,7 +32,7 @@ import { } from './gen'; import { OpenIDConnectAuth } from './oidc_auth'; import WebSocket = require('isomorphic-ws'); -import child_process = require('child_process'); +import child_process = require('node:child_process'); const SERVICEACCOUNT_ROOT: string = '/var/run/secrets/kubernetes.io/serviceaccount'; const SERVICEACCOUNT_CA_PATH: string = SERVICEACCOUNT_ROOT + '/ca.crt'; diff --git a/src/config_test.ts b/src/config_test.ts index 262d52dd3c..0b22693b58 100644 --- a/src/config_test.ts +++ b/src/config_test.ts @@ -1,12 +1,12 @@ -import { readFileSync } from 'fs'; -import * as https from 'https'; -import { Agent, RequestOptions } from 'https'; -import { join } from 'path'; +import { readFileSync } from 'node:fs'; +import * as https from 'node:https'; +import { Agent, RequestOptions } from 'node:https'; +import { join } from 'node:path'; import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; import mockfs = require('mock-fs'); -import * as path from 'path'; +import * as path from 'node:path'; import { Headers } from 'node-fetch'; import { HttpMethod } from '.'; diff --git a/src/config_types.ts b/src/config_types.ts index b94bb13265..793f594574 100644 --- a/src/config_types.ts +++ b/src/config_types.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs'; +import * as fs from 'node:fs'; export enum ActionOnInvalid { THROW = 'throw', diff --git a/src/cp.ts b/src/cp.ts index c13dcecae2..925589b2af 100644 --- a/src/cp.ts +++ b/src/cp.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs'; +import * as fs from 'node:fs'; import { WritableStreamBuffer } from 'stream-buffers'; import * as tar from 'tar'; import * as tmp from 'tmp-promise'; diff --git a/src/cp_test.ts b/src/cp_test.ts index 7c1bb70585..5ef7361d0f 100644 --- a/src/cp_test.ts +++ b/src/cp_test.ts @@ -1,5 +1,5 @@ import { anything, anyFunction, instance, mock, verify, when } from 'ts-mockito'; -import * as querystring from 'querystring'; +import * as querystring from 'node:querystring'; import WebSocket = require('isomorphic-ws'); import { CallAwaiter } from '../test'; diff --git a/src/exec.ts b/src/exec.ts index defbb56c76..ee1cddc3aa 100644 --- a/src/exec.ts +++ b/src/exec.ts @@ -1,5 +1,5 @@ import WebSocket = require('isomorphic-ws'); -import querystring = require('querystring'); +import querystring = require('node:querystring'); import stream = require('stream'); import { V1Status } from './api'; diff --git a/src/exec_auth.ts b/src/exec_auth.ts index 78df99439b..c2d4b6b7c0 100644 --- a/src/exec_auth.ts +++ b/src/exec_auth.ts @@ -1,10 +1,10 @@ -import { OutgoingHttpHeaders } from 'http'; -import https = require('https'); +import { OutgoingHttpHeaders } from 'node:http'; +import https = require('node:https'); import { Authenticator } from './auth'; import { User } from './config_types'; -import child_process = require('child_process'); +import child_process = require('node:child_process'); export interface CredentialStatus { readonly token: string; diff --git a/src/exec_auth_test.ts b/src/exec_auth_test.ts index fc4607be7b..9622d1542a 100644 --- a/src/exec_auth_test.ts +++ b/src/exec_auth_test.ts @@ -2,14 +2,14 @@ import { expect, use } from 'chai'; import chaiAsPromised from 'chai-as-promised'; use(chaiAsPromised); -import https from 'https'; -import { OutgoingHttpHeaders } from 'http'; +import https from 'node:https'; +import { OutgoingHttpHeaders } from 'node:http'; import { ExecAuth } from './exec_auth'; import { User } from './config_types'; -import { fail } from 'assert'; +import { fail } from 'node:assert'; -import child_process = require('child_process'); +import child_process = require('node:child_process'); describe('ExecAuth', () => { it('should claim correctly', () => { diff --git a/src/file_auth.ts b/src/file_auth.ts index d24034eb54..2623c4fb6f 100644 --- a/src/file_auth.ts +++ b/src/file_auth.ts @@ -1,5 +1,5 @@ -import fs = require('fs'); -import https = require('https'); +import fs = require('node:fs'); +import https = require('node:https'); import { Authenticator } from './auth'; import { User } from './config_types'; diff --git a/src/file_auth_test.ts b/src/file_auth_test.ts index 9e335b257c..2cd4a6d164 100644 --- a/src/file_auth_test.ts +++ b/src/file_auth_test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; -import { OutgoingHttpHeaders } from 'http'; -import https from 'https'; +import { OutgoingHttpHeaders } from 'node:http'; +import https from 'node:https'; import mockfs from 'mock-fs'; import { User } from './config_types'; diff --git a/src/gcp_auth.ts b/src/gcp_auth.ts index a01df0c5e9..7eac957ef9 100644 --- a/src/gcp_auth.ts +++ b/src/gcp_auth.ts @@ -1,5 +1,5 @@ -import * as proc from 'child_process'; -import https = require('https'); +import * as proc from 'node:child_process'; +import https = require('node:https'); import * as jsonpath from 'jsonpath-plus'; import { Authenticator } from './auth'; diff --git a/src/gcp_auth_test.ts b/src/gcp_auth_test.ts index 7fdcd9854e..f6dfc012e6 100644 --- a/src/gcp_auth_test.ts +++ b/src/gcp_auth_test.ts @@ -1,11 +1,11 @@ import { expect } from 'chai'; -import { join } from 'path'; +import { join } from 'node:path'; import { User, Cluster } from './config_types'; import { GoogleCloudPlatformAuth } from './gcp_auth'; import { KubeConfig } from './config'; import { HttpMethod, RequestContext } from './gen'; -import { Agent } from 'https'; +import { Agent } from 'node:https'; describe('GoogleCloudPlatformAuth', () => { const testUrl1 = 'https://test-gcp.com'; diff --git a/src/log.ts b/src/log.ts index d6f18115c8..84c99a6ec5 100644 --- a/src/log.ts +++ b/src/log.ts @@ -1,7 +1,6 @@ import fetch from 'node-fetch'; import { AbortSignal } from 'node-fetch/externals'; -import { Writable } from 'stream'; -import { URL, URLSearchParams } from 'url'; +import { Writable } from 'node:stream'; import { ApiException } from './api'; import { KubeConfig } from './config'; import { V1Status } from './gen'; diff --git a/src/log_test.ts b/src/log_test.ts index 22b3548961..4e2223ab9a 100644 --- a/src/log_test.ts +++ b/src/log_test.ts @@ -1,6 +1,5 @@ import { expect } from 'chai'; import { AddOptionsToSearchParams, LogOptions } from './log'; -import { URLSearchParams } from 'url'; describe('Log', () => { describe('AddOptionsToSearchParams', () => { diff --git a/src/metrics_test.ts b/src/metrics_test.ts index 1a07b91c1b..7da08f9938 100644 --- a/src/metrics_test.ts +++ b/src/metrics_test.ts @@ -1,8 +1,8 @@ -import { fail } from 'assert'; +import { fail } from 'node:assert'; import { expect } from 'chai'; import nock = require('nock'); import { KubeConfig } from './config'; -import { V1Status, HttpException, ApiException } from './gen'; +import { V1Status, ApiException } from './gen'; import { Metrics, NodeMetricsList, PodMetricsList } from './metrics'; const emptyPodMetrics: PodMetricsList = { diff --git a/src/object_test.ts b/src/object_test.ts index ba735611b0..d6ea3e050d 100644 --- a/src/object_test.ts +++ b/src/object_test.ts @@ -1,4 +1,4 @@ -import { fail } from 'assert'; +import { fail } from 'node:assert'; import { expect } from 'chai'; import nock = require('nock'); import { Configuration, V1APIResource, V1APIResourceList, V1Secret } from './api'; diff --git a/src/oidc_auth.ts b/src/oidc_auth.ts index 2fd5c4bbdf..c41ab859c3 100644 --- a/src/oidc_auth.ts +++ b/src/oidc_auth.ts @@ -1,7 +1,6 @@ -import https from 'https'; +import https from 'node:https'; import { Client, Issuer } from 'openid-client'; import { base64url } from 'rfc4648'; -import { TextDecoder } from 'util'; import { Authenticator } from './auth'; import { User } from './config_types'; diff --git a/src/oidc_auth_test.ts b/src/oidc_auth_test.ts index e2d7160acd..e93622f93d 100644 --- a/src/oidc_auth_test.ts +++ b/src/oidc_auth_test.ts @@ -1,8 +1,7 @@ import { expect } from 'chai'; -import { OutgoingHttpHeaders } from 'http'; -import https from 'https'; +import { OutgoingHttpHeaders } from 'node:http'; +import https from 'node:https'; import { base64url } from 'rfc4648'; -import { TextEncoder } from 'util'; import { User } from './config_types'; import { OpenIDConnectAuth } from './oidc_auth'; diff --git a/src/package_test.ts b/src/package_test.ts index a161a8fdf9..77f3056fef 100644 --- a/src/package_test.ts +++ b/src/package_test.ts @@ -1,5 +1,4 @@ import { expect } from 'chai'; -import { URL } from 'url'; // Generic set of tests to verify the package is built and configured correctly describe('package', () => { diff --git a/src/portforward.ts b/src/portforward.ts index fcae80137f..09f3b519a6 100644 --- a/src/portforward.ts +++ b/src/portforward.ts @@ -1,6 +1,6 @@ import WebSocket = require('isomorphic-ws'); -import querystring = require('querystring'); -import stream = require('stream'); +import querystring = require('node:querystring'); +import stream = require('node:stream'); import { KubeConfig } from './config'; import { WebSocketHandler, WebSocketInterface } from './web-socket-handler'; diff --git a/src/portforward_test.ts b/src/portforward_test.ts index 8e27e04af1..a7b7877bca 100644 --- a/src/portforward_test.ts +++ b/src/portforward_test.ts @@ -1,6 +1,6 @@ import { expect } from 'chai'; import { ReadableStreamBuffer, WritableStreamBuffer } from 'stream-buffers'; -import { anyFunction, capture, instance, mock, reset, verify } from 'ts-mockito'; +import { anyFunction, capture, instance, mock, verify } from 'ts-mockito'; import { KubeConfig } from './config'; import { PortForward } from './portforward'; diff --git a/src/proto-client.ts b/src/proto-client.ts index e726f339b1..c607e2a62f 100644 --- a/src/proto-client.ts +++ b/src/proto-client.ts @@ -1,5 +1,4 @@ -import http = require('http'); -import url = require('url'); +import http = require('node:http'); import { KubeConfig } from './config'; @@ -8,7 +7,7 @@ export class ProtoClient { public async get(msgType: any, requestPath: string): Promise { const server = this.config.getCurrentCluster()!.server; - const u = new url.URL(server); + const u = new URL(server); const options = { path: requestPath, hostname: u.hostname, diff --git a/src/terminal-size-queue.ts b/src/terminal-size-queue.ts index c6c6cdee5a..1a41a937b3 100644 --- a/src/terminal-size-queue.ts +++ b/src/terminal-size-queue.ts @@ -1,4 +1,4 @@ -import { Readable, ReadableOptions } from 'stream'; +import { Readable, ReadableOptions } from 'node:stream'; export interface ResizableStream { columns: number; diff --git a/src/watch.ts b/src/watch.ts index dc95564ca9..86f24ab6cc 100644 --- a/src/watch.ts +++ b/src/watch.ts @@ -1,7 +1,6 @@ import { createInterface } from 'node:readline'; import fetch from 'node-fetch'; import { AbortSignal } from 'node-fetch/externals'; -import { URL } from 'url'; import { KubeConfig } from './config'; export class Watch { diff --git a/src/watch_test.ts b/src/watch_test.ts index 117f5a6e9f..1545a70a8e 100644 --- a/src/watch_test.ts +++ b/src/watch_test.ts @@ -1,12 +1,10 @@ import { expect } from 'chai'; -// import { anything, capture, instance, mock, spy, verify, when } from 'ts-mockito'; - import nock = require('nock'); -import { PassThrough } from 'stream'; +import { PassThrough } from 'node:stream'; import { KubeConfig } from './config'; import { Cluster, Context, User } from './config_types'; import { Watch } from './watch'; -import { IncomingMessage } from 'http'; +import { IncomingMessage } from 'node:http'; const server = 'http://foo.company.com'; diff --git a/src/web-socket-handler.ts b/src/web-socket-handler.ts index b1c04c550f..79fba98ab8 100644 --- a/src/web-socket-handler.ts +++ b/src/web-socket-handler.ts @@ -1,5 +1,5 @@ import WebSocket = require('isomorphic-ws'); -import stream = require('stream'); +import stream = require('node:stream'); import { V1Status } from './api'; import { KubeConfig } from './config'; diff --git a/src/web-socket-handler_test.ts b/src/web-socket-handler_test.ts index fc97405c0d..c490f8579b 100644 --- a/src/web-socket-handler_test.ts +++ b/src/web-socket-handler_test.ts @@ -1,5 +1,5 @@ import { Readable } from 'node:stream'; -import { promisify } from 'util'; +import { setImmediate as setImmediatePromise } from 'node:timers/promises'; import { expect } from 'chai'; import WebSocket = require('isomorphic-ws'); import { WritableStreamBuffer } from 'stream-buffers'; @@ -9,8 +9,6 @@ import { KubeConfig } from './config'; import { Cluster, Context, User } from './config_types'; import { WebSocketHandler } from './web-socket-handler'; -const setImmediatePromise = promisify(setImmediate); - describe('WebSocket', () => { it('should throw on unknown code', () => { const osStream = new WritableStreamBuffer(); diff --git a/test/call-awaiter.ts b/test/call-awaiter.ts index e42048c7c7..dd165207f0 100644 --- a/test/call-awaiter.ts +++ b/test/call-awaiter.ts @@ -1,4 +1,4 @@ -import { EventEmitter } from 'events'; +import { EventEmitter } from 'node:events'; export class CallAwaiter extends EventEmitter { public awaitCall(event: string) { diff --git a/test/match-buffer.ts b/test/match-buffer.ts index 986816edfa..0136ad9ea9 100644 --- a/test/match-buffer.ts +++ b/test/match-buffer.ts @@ -1,6 +1,5 @@ -import { deepStrictEqual } from 'assert'; import { expect } from 'chai'; -import { RequestOptions, Agent } from 'https'; +import { RequestOptions, Agent } from 'node:https'; import { Matcher } from 'ts-mockito/lib/matcher/type/Matcher'; export function matchBuffer(channel: number, contents: string): StringBufferMatcher {