Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compatibility with node v22 #493

Merged
merged 3 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/awesome-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '20.x'
- name: Check awesome-list linter
# https://github.com/sindresorhus/awesome/blob/main/pull_request_template.md
run: npx --yes awesome-lint ./README.md
2 changes: 1 addition & 1 deletion .github/workflows/check-package-mismatches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 18
node-version: '20.x'
- name: Check mismatched dependencies in workspace
run: npx --yes [email protected] check-mismatches
2 changes: 1 addition & 1 deletion .github/workflows/gh-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
cache: yarn

- run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
cache: yarn

- run: yarn
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish-canary.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
cache: yarn

- run: yarn
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
cache: yarn

- run: yarn
Expand All @@ -31,7 +31,7 @@ jobs:

- uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
cache: yarn

- run: yarn
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@
"topicSeparator": " ",
"update": {
"node": {
"version": "18.19.0",
"version": "20.13.1",
"options": [
"--no-warnings=ExperimentalWarning",
"--disable-warning=ExperimentalWarning",
"--enable-source-maps"
]
},
Expand Down
4 changes: 2 additions & 2 deletions packages/driver-azure/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"@azure/arm-resources": "^5.2.0",
"@azure/arm-storage": "^18.2.0",
"@azure/arm-subscriptions": "^5.1.0",
"@azure/identity": "^3.2.2",
"@azure/identity": "^4.2.0",
"@azure/logger": "^1.0.4",
"@azure/storage-blob": "^12.17.0",
"@inquirer/prompts": "^3.3.0",
Expand Down Expand Up @@ -59,4 +59,4 @@
"prepack": "yarn clean && yarn build",
"prepare": "cd ../.. && husky install"
}
}
}
2 changes: 2 additions & 0 deletions packages/driver-kube-pod/src/driver/client/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ export const bodyOrUndefined = async <T, Response extends { body: T } = { body:
export type HasMetadata = { metadata?: k8s.V1ObjectMeta }
export type HasKind = { kind?: string }
export type Package = { version: string; name: string }

export const defaultPackage: Package = { name: 'preevy', version: 'unknown' } as const
6 changes: 3 additions & 3 deletions packages/driver-kube-pod/src/driver/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
addAllTypesAnnotation,
readAllTypesAnnotation,
} from './metadata.js'
import { Package } from './common.js'
import { Package, defaultPackage } from './common.js'
import { logError } from './log-error.js'

const stringify = stringifyModule.default
Expand Down Expand Up @@ -186,7 +186,7 @@ export const kubeCreationClient = ({
namespace: string
profileId: string
template: Buffer | string | Promise<Buffer | string>
package: Package | Promise<Package>
package: Package | undefined | Promise<Package | undefined>
storageClass: string | undefined
storageSize: number
}) => {
Expand Down Expand Up @@ -278,7 +278,7 @@ export const kubeCreationClient = ({
})
),
strategy: serverSideApply
? applyStrategies.serverSideApply({ fieldManager: (await packageDetails).name })
? applyStrategies.serverSideApply({ fieldManager: (await packageDetails ?? defaultPackage).name })
: applyStrategies.clientSideApply,
})

Expand Down
6 changes: 3 additions & 3 deletions packages/driver-kube-pod/src/driver/client/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ensureDefined, extractDefined, randomString, truncatePrefix } from '@pr
import { pick } from 'lodash-es'
import { tryParseJson } from '@preevy/common'
import { sanitizeLabel, sanitizeLabels } from './labels.js'
import { HasMetadata, Package } from './common.js'
import { HasMetadata, Package, defaultPackage } from './common.js'
import { KubernetesType } from './dynamic/index.js'

export const MAX_LABEL_LENGTH = 63
Expand Down Expand Up @@ -70,12 +70,12 @@ export const addAllTypesAnnotation = (
}

export const addEnvMetadata = (
{ profileId, envId, createdAt, instance, package: { name, version }, templateHash }: {
{ profileId, envId, createdAt, instance, package: { name, version } = defaultPackage, templateHash }: {
profileId: string
envId: string
createdAt: Date
instance: string
package: Package
package?: Package
templateHash: string
},
) => (
Expand Down
13 changes: 11 additions & 2 deletions packages/driver-kube-pod/src/driver/creation-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { inspect } from 'util'
import { DeploymentMachine, ResourceType, StatefulSetMachine, k8sObjectToMachine } from './common.js'
import { clientFromConfiguration, listMachines, machineConnection, flags as machineDriverFlags, parseRfc1123Flag } from './driver.js'
import { Client, CreationClient, kubeCreationClient, loadKubeConfig } from './client/index.js'
import { DEFAULT_TEMPLATE, packageJson } from '../static.js'
import { DEFAULT_TEMPLATE, packageJsonPath } from '../static.js'
import { Package } from './client/common.js'

export const flags = {
...machineDriverFlags,
Expand Down Expand Up @@ -103,6 +104,14 @@ const machineCreationDriver = (

type FlagTypes = Omit<Interfaces.InferredFlags<typeof flags>, 'json'>

const tryReadPackage = async (): Promise<Package | undefined> => {
try {
return JSON.parse(await fs.promises.readFile(packageJsonPath, 'utf-8'))
} catch (e) {
return undefined
}
}

const creationClientFromConfiguration = ({ flags: f, profileId, log, kc }: {
flags: FlagTypes
profileId: string
Expand All @@ -113,7 +122,7 @@ const creationClientFromConfiguration = ({ flags: f, profileId, log, kc }: {
namespace: f.namespace,
kc,
profileId,
package: packageJson,
package: tryReadPackage(),
template: fs.readFileSync(f.template || DEFAULT_TEMPLATE, 'utf-8'),
storageClass: f['storage-class'],
storageSize: f['storage-size'],
Expand Down
3 changes: 1 addition & 2 deletions packages/driver-kube-pod/src/static.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import path from 'path'
import url from 'url'
import packageJsonImport from '../package.json' assert { type: 'json' }

// eslint-disable-next-line no-underscore-dangle
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))

export const DIR = path.join(__dirname, '../static')
export const DEFAULT_TEMPLATE = path.join(DIR, './default-template.yaml.njk')
export const packageJson = packageJsonImport
export const packageJsonPath = path.join(__dirname, '../package.json')
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -910,28 +910,28 @@
dependencies:
tslib "^2.2.0"

"@azure/core-util@^1.0.0", "@azure/core-util@^1.1.0", "@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0", "@azure/core-util@^1.3.0", "@azure/core-util@^1.6.1":
"@azure/core-util@^1.0.0", "@azure/core-util@^1.1.0", "@azure/core-util@^1.1.1", "@azure/core-util@^1.2.0", "@azure/core-util@^1.3.0":
version "1.7.0"
resolved "https://registry.npmjs.org/@azure/core-util/-/core-util-1.7.0.tgz#3a2f73e8c7eed0666e8b6ff9ca2c1951e175feba"
integrity sha512-Zq2i3QO6k9DA8vnm29mYM4G8IE9u1mhF1GUabVEqPNX8Lj833gdxQ2NAFxt2BZsfAL+e9cT8SyVN7dFVJ/Hf0g==
dependencies:
"@azure/abort-controller" "^2.0.0"
tslib "^2.2.0"

"@azure/identity@^3.2.2":
version "3.4.2"
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-3.4.2.tgz#6b01724c9caac7cadab6b63c76584345bda8e2de"
integrity sha512-0q5DL4uyR0EZ4RXQKD8MadGH6zTIcloUoS/RVbCpNpej4pwte0xpqYxk8K97Py2RiuUvI7F4GXpoT4046VfufA==
"@azure/identity@^4.2.0":
version "4.2.0"
resolved "https://registry.yarnpkg.com/@azure/identity/-/identity-4.2.0.tgz#acaee2f50785cc87778ec7eedcc20d6e72c1da23"
integrity sha512-ve3aYv79qXOJ8wRxQ5jO0eIz2DZ4o0TyME4m4vlGV5YyePddVZ+pFMzusAMODNAflYAAv1cBIhKnd4xytmXyig==
dependencies:
"@azure/abort-controller" "^1.0.0"
"@azure/core-auth" "^1.5.0"
"@azure/core-client" "^1.4.0"
"@azure/core-rest-pipeline" "^1.1.0"
"@azure/core-tracing" "^1.0.0"
"@azure/core-util" "^1.6.1"
"@azure/core-util" "^1.3.0"
"@azure/logger" "^1.0.0"
"@azure/msal-browser" "^3.5.0"
"@azure/msal-node" "^2.5.1"
"@azure/msal-browser" "^3.11.1"
"@azure/msal-node" "^2.6.6"
events "^3.0.0"
jws "^4.0.0"
open "^8.0.0"
Expand All @@ -945,24 +945,24 @@
dependencies:
tslib "^2.6.2"

"@azure/msal-browser@^3.5.0":
version "3.5.0"
resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-3.5.0.tgz#eb64c931c78c2b75c70807f618e1284bbb183380"
integrity sha512-2NtMuel4CI3UEelCPKkNRXgKzpWEX48fvxIvPz7s0/sTcCaI08r05IOkH2GkXW+czUOtuY6+oGafJCpumnjRLg==
"@azure/msal-browser@^3.11.1":
version "3.14.0"
resolved "https://registry.yarnpkg.com/@azure/msal-browser/-/msal-browser-3.14.0.tgz#1cb5cab438a9943212aa50c403d11f775c787b21"
integrity sha512-Un85LhOoecJ3HDTS3Uv3UWnXC9/43ZSO+Kc+anSqpZvcEt58SiO/3DuVCAe1A3I5UIBYJNMgTmZPGXQ0MVYrwA==
dependencies:
"@azure/msal-common" "14.4.0"
"@azure/msal-common" "14.10.0"

"@azure/msal-common@14.4.0":
version "14.4.0"
resolved "https://registry.yarnpkg.com/@azure/msal-common/-/msal-common-14.4.0.tgz#f938c1d96bb73d65baab985c96faaa273c97cfd5"
integrity sha512-ffCymScQuMKVj+YVfwNI52A5Tu+uiZO2eTf+c+3TXxdAssks4nokJhtr+uOOMxH0zDi6d1OjFKFKeXODK0YLSg==
"@azure/msal-common@14.10.0":
version "14.10.0"
resolved "https://registry.yarnpkg.com/@azure/msal-common/-/msal-common-14.10.0.tgz#215449726717b53d549953db77562cad6cb8421c"
integrity sha512-Zk6DPDz7e1wPgLoLgAp0349Yay9RvcjPM5We/ehuenDNsz/t9QEFI7tRoHpp/e47I4p20XE3FiDlhKwAo3utDA==

"@azure/msal-node@^2.5.1":
version "2.5.1"
resolved "https://registry.yarnpkg.com/@azure/msal-node/-/msal-node-2.5.1.tgz#d180a1ba5fdc611a318a8f018a2db3453e2e2898"
integrity sha512-PsPRISqCG253HQk1cAS7eJW7NWTbnBGpG+vcGGz5z4JYRdnM2EIXlj1aBpXCdozenEPtXEVvHn2ELleW1w82nQ==
"@azure/msal-node@^2.6.6":
version "2.8.1"
resolved "https://registry.yarnpkg.com/@azure/msal-node/-/msal-node-2.8.1.tgz#aded28d37eea2e7278c9bd44f2016647390f239c"
integrity sha512-VcZZM+5VvCWRBTOF7SxMKaxrz+EXjntx2u5AQe7QE06e6FuPJElGBrImgNgCh5QmFaNCfVFO+3qNR7UoFD/Gfw==
dependencies:
"@azure/msal-common" "14.4.0"
"@azure/msal-common" "14.10.0"
jsonwebtoken "^9.0.0"
uuid "^8.3.0"

Expand Down
Loading