mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-22 19:40:56 +08:00
19 lines
537 B
TypeScript
19 lines
537 B
TypeScript
import {Kubectl} from '../types/kubectl'
|
|
|
|
const trafficSplitAPIVersionPrefix = 'split.smi-spec.io'
|
|
|
|
export async function getTrafficSplitAPIVersion(
|
|
kubectl: Kubectl
|
|
): Promise<string> {
|
|
const result = await kubectl.executeCommand('api-versions')
|
|
const trafficSplitAPIVersion = result.stdout
|
|
.split('\n')
|
|
.find((version) => version.startsWith(trafficSplitAPIVersionPrefix))
|
|
|
|
if (!trafficSplitAPIVersion) {
|
|
throw new Error('Unable to find traffic split api version')
|
|
}
|
|
|
|
return trafficSplitAPIVersion
|
|
}
|