mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-04-18 21:22:18 +08:00
* Migrate build toolchain from ncc/Jest to esbuild/Vitest Replace the legacy ncc/Jest/Babel build stack with a modern ESM toolchain: Build: - Replace @vercel/ncc with esbuild (--platform=node --target=node20 --format=esm) - Add createRequire banner for CJS interop in ESM bundle - Add "type": "module" to package.json - Add tsc --noEmit typecheck script (esbuild strips types without checking) - Add typecheck to husky pre-commit hook Dependencies: - Bump @actions/core@3, exec@3, io@3, tool-cache@4 (ESM-only) - Replace jest/ts-jest/@babel/* with vitest@4 Tests: - Convert 29 test files: jest.fn()→vi.fn(), jest.mock()→vi.mock(), jest.spyOn()→vi.spyOn() - Fix vitest 4 compat: mockImplementation requires args, mock call tracking, await .rejects CI: - Update build step from ncc build → npm run build - Update composite action to use npm run build * Switch tsconfig to NodeNext module resolution Change module/moduleResolution from ES2022/bundler to NodeNext/NodeNext and target from ES2022 to ES2020. - Add .js extensions to all relative imports across 59 source/test files (required by NodeNext module resolution) - Add vitest/globals to tsconfig types array for global test API declarations
92 lines
2.5 KiB
TypeScript
92 lines
2.5 KiB
TypeScript
import {K8sDeleteObject} from '../../types/k8sObject.js'
|
|
import {Kubectl} from '../../types/kubectl.js'
|
|
import {
|
|
BlueGreenDeployment,
|
|
BlueGreenManifests,
|
|
BlueGreenRejectResult
|
|
} from '../../types/blueGreenTypes.js'
|
|
import {deleteGreenObjects, NONE_LABEL_VALUE} from './blueGreenHelper.js'
|
|
import {routeBlueGreenSMI} from './route.js'
|
|
import {cleanupSMI} from './smiBlueGreenHelper.js'
|
|
import {routeBlueGreenIngressUnchanged, routeBlueGreenService} from './route.js'
|
|
|
|
export async function rejectBlueGreenIngress(
|
|
kubectl: Kubectl,
|
|
manifestObjects: BlueGreenManifests,
|
|
timeout?: string
|
|
): Promise<BlueGreenRejectResult> {
|
|
// get all kubernetes objects defined in manifest files
|
|
// route ingress to stables services
|
|
const routeResult = await routeBlueGreenIngressUnchanged(
|
|
kubectl,
|
|
manifestObjects.serviceNameMap,
|
|
manifestObjects.ingressEntityList,
|
|
timeout
|
|
)
|
|
|
|
// delete green services and deployments
|
|
const deleteResult = await deleteGreenObjects(
|
|
kubectl,
|
|
[].concat(
|
|
manifestObjects.deploymentEntityList,
|
|
manifestObjects.serviceEntityList
|
|
),
|
|
timeout
|
|
)
|
|
|
|
return {routeResult, deleteResult}
|
|
}
|
|
|
|
export async function rejectBlueGreenService(
|
|
kubectl: Kubectl,
|
|
manifestObjects: BlueGreenManifests,
|
|
timeout?: string
|
|
): Promise<BlueGreenRejectResult> {
|
|
// route to stable objects
|
|
const routeResult = await routeBlueGreenService(
|
|
kubectl,
|
|
NONE_LABEL_VALUE,
|
|
manifestObjects.serviceEntityList,
|
|
timeout
|
|
)
|
|
|
|
// delete new deployments with green suffix
|
|
const deleteResult = await deleteGreenObjects(
|
|
kubectl,
|
|
manifestObjects.deploymentEntityList,
|
|
timeout
|
|
)
|
|
|
|
return {routeResult, deleteResult}
|
|
}
|
|
|
|
export async function rejectBlueGreenSMI(
|
|
kubectl: Kubectl,
|
|
manifestObjects: BlueGreenManifests,
|
|
timeout?: string
|
|
): Promise<BlueGreenRejectResult> {
|
|
// route trafficsplit to stable deployments
|
|
const routeResult = await routeBlueGreenSMI(
|
|
kubectl,
|
|
NONE_LABEL_VALUE,
|
|
manifestObjects.serviceEntityList,
|
|
timeout
|
|
)
|
|
|
|
// delete rejected new bluegreen deployments
|
|
const deletedObjects = await deleteGreenObjects(
|
|
kubectl,
|
|
manifestObjects.deploymentEntityList,
|
|
timeout
|
|
)
|
|
|
|
// delete trafficsplit and extra services
|
|
const cleanupResult = await cleanupSMI(
|
|
kubectl,
|
|
manifestObjects.serviceEntityList,
|
|
timeout
|
|
)
|
|
|
|
return {routeResult, deleteResult: [].concat(deletedObjects, cleanupResult)}
|
|
}
|