mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-21 10:39:26 +08:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 14f45dd2eb | |||
| 6768d69df6 | |||
| 96fae157b0 |
@@ -24,7 +24,7 @@ jobs:
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@45775bd8235c68ba998cffa5171334d58593da47 #v3.28.15
|
||||
uses: github/codeql-action/init@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13
|
||||
# Override language selection by uncommenting this and choosing your languages
|
||||
# with:
|
||||
# languages: go, javascript, csharp, python, cpp, java
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@45775bd8235c68ba998cffa5171334d58593da47 #v3.28.15
|
||||
uses: github/codeql-action/autobuild@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@@ -46,4 +46,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@45775bd8235c68ba998cffa5171334d58593da47 #v3.28.15
|
||||
uses: github/codeql-action/analyze@1b549b9259bda1cb5ddde3b41741a82a2d15a841 #v3.28.13
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -57,7 +57,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -54,7 +54,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
- name: Build
|
||||
run: ncc build src/run.ts -o lib
|
||||
- name: Azure login
|
||||
uses: azure/login@v2.3.0
|
||||
uses: azure/login@v2.2.0
|
||||
with:
|
||||
client-id: ${{ secrets.AZURE_CLIENT_ID }}
|
||||
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
|
||||
@@ -51,7 +51,7 @@ jobs:
|
||||
run: |
|
||||
az aks command invoke --resource-group ${{ env.NAMESPACE }} --name ${{ env.NAMESPACE }} --command "kubectl create ns ${{ env.NAMESPACE }}"
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -46,7 +46,7 @@ jobs:
|
||||
- name: Create namespace to run tests
|
||||
run: kubectl create ns ${{ env.NAMESPACE }}
|
||||
|
||||
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # 5.5.0
|
||||
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # 5.4.0
|
||||
name: Install Python
|
||||
with:
|
||||
python-version: '3.x'
|
||||
|
||||
@@ -2,5 +2,6 @@ node_modules
|
||||
|
||||
.DS_Store
|
||||
.idea
|
||||
lib/
|
||||
|
||||
coverage/
|
||||
@@ -1,17 +1,5 @@
|
||||
# Changelog
|
||||
|
||||
## [5.0.3] - 2025-04-16
|
||||
|
||||
### Added
|
||||
|
||||
- #398 case-insensitive resource type
|
||||
|
||||
## [5.0.2] - 2025-04-15
|
||||
|
||||
### Added
|
||||
|
||||
- #396 Update new resource-type input for action
|
||||
|
||||
## [5.0.1] - 2024-03-12
|
||||
|
||||
### Added
|
||||
|
||||
@@ -80,10 +80,6 @@ inputs:
|
||||
skip-tls-verify:
|
||||
description: True if the insecure-skip-tls-verify option should be used. Input should be 'true' or 'false'.
|
||||
default: false
|
||||
resource-type:
|
||||
description: Either Microsoft.ContainerService/managedClusters or Microsoft.ContainerService/fleets'.
|
||||
required: false
|
||||
default: 'Microsoft.ContainerService/managedClusters'
|
||||
|
||||
branding:
|
||||
color: 'green'
|
||||
|
||||
-17991
File diff suppressed because it is too large
Load Diff
Generated
+32
-33
@@ -25,12 +25,12 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/minimist": "^1.2.5",
|
||||
"@types/node": "^22.14.0",
|
||||
"@types/node": "^22.13.13",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.5.3",
|
||||
"ts-jest": "^29.3.1",
|
||||
"typescript": "5.8.3"
|
||||
"ts-jest": "^29.3.0",
|
||||
"typescript": "5.8.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@actions/core": {
|
||||
@@ -2348,13 +2348,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "22.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.0.tgz",
|
||||
"integrity": "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==",
|
||||
"version": "22.13.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.13.tgz",
|
||||
"integrity": "sha512-ClsL5nMwKaBRwPcCvH8E7+nU4GxHVx1axNvMZTFHMEfNI7oahimt26P5zjVCRrjiIWj6YFXfE1v3dEp94wLcGQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"undici-types": "~6.21.0"
|
||||
"undici-types": "~6.20.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/stack-utils": {
|
||||
@@ -4964,9 +4964,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
"version": "29.3.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.1.tgz",
|
||||
"integrity": "sha512-FT2PIRtZABwl6+ZCry8IY7JZ3xMuppsEV9qFVHOVe8jDzggwUZ9TsM4chyJxL9yi6LvkqcZYU3LmapEE454zBQ==",
|
||||
"version": "29.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.0.tgz",
|
||||
"integrity": "sha512-4bfGBX7Gd1Aqz3SyeDS9O276wEU/BInZxskPrbhZLyv+c1wskDCqDFMJQJLWrIr/fKoAH4GE5dKUlrdyvo+39A==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
@@ -4978,7 +4978,7 @@
|
||||
"lodash.memoize": "^4.1.2",
|
||||
"make-error": "^1.3.6",
|
||||
"semver": "^7.7.1",
|
||||
"type-fest": "^4.38.0",
|
||||
"type-fest": "^4.37.0",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"bin": {
|
||||
@@ -5069,9 +5069,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"version": "5.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
||||
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
@@ -5083,11 +5083,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/unicode-canonical-property-names-ecmascript": {
|
||||
"version": "2.0.1",
|
||||
@@ -6876,12 +6875,12 @@
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "22.14.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.14.0.tgz",
|
||||
"integrity": "sha512-Kmpl+z84ILoG+3T/zQFyAJsU6EPTmOCj8/2+83fSN6djd6I4o7uOuGIH6vq3PrjY5BGitSbFuMN18j3iknubbA==",
|
||||
"version": "22.13.13",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.13.tgz",
|
||||
"integrity": "sha512-ClsL5nMwKaBRwPcCvH8E7+nU4GxHVx1axNvMZTFHMEfNI7oahimt26P5zjVCRrjiIWj6YFXfE1v3dEp94wLcGQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"undici-types": "~6.21.0"
|
||||
"undici-types": "~6.20.0"
|
||||
}
|
||||
},
|
||||
"@types/stack-utils": {
|
||||
@@ -8782,9 +8781,9 @@
|
||||
}
|
||||
},
|
||||
"ts-jest": {
|
||||
"version": "29.3.1",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.1.tgz",
|
||||
"integrity": "sha512-FT2PIRtZABwl6+ZCry8IY7JZ3xMuppsEV9qFVHOVe8jDzggwUZ9TsM4chyJxL9yi6LvkqcZYU3LmapEE454zBQ==",
|
||||
"version": "29.3.0",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.3.0.tgz",
|
||||
"integrity": "sha512-4bfGBX7Gd1Aqz3SyeDS9O276wEU/BInZxskPrbhZLyv+c1wskDCqDFMJQJLWrIr/fKoAH4GE5dKUlrdyvo+39A==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"bs-logger": "^0.2.6",
|
||||
@@ -8795,7 +8794,7 @@
|
||||
"lodash.memoize": "^4.1.2",
|
||||
"make-error": "^1.3.6",
|
||||
"semver": "^7.7.1",
|
||||
"type-fest": "^4.38.0",
|
||||
"type-fest": "^4.37.0",
|
||||
"yargs-parser": "^21.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
@@ -8831,15 +8830,15 @@
|
||||
"dev": true
|
||||
},
|
||||
"typescript": {
|
||||
"version": "5.8.3",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz",
|
||||
"integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==",
|
||||
"version": "5.8.2",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz",
|
||||
"integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==",
|
||||
"dev": true
|
||||
},
|
||||
"undici-types": {
|
||||
"version": "6.21.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz",
|
||||
"integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==",
|
||||
"version": "6.20.0",
|
||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz",
|
||||
"integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==",
|
||||
"dev": true
|
||||
},
|
||||
"unicode-canonical-property-names-ecmascript": {
|
||||
|
||||
+3
-3
@@ -28,11 +28,11 @@
|
||||
"@types/jest": "^29.5.14",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"@types/minimist": "^1.2.5",
|
||||
"@types/node": "^22.14.0",
|
||||
"@types/node": "^22.13.13",
|
||||
"@vercel/ncc": "^0.38.3",
|
||||
"jest": "^29.7.0",
|
||||
"prettier": "^3.5.3",
|
||||
"ts-jest": "^29.3.1",
|
||||
"typescript": "5.8.3"
|
||||
"ts-jest": "^29.3.0",
|
||||
"typescript": "5.8.2"
|
||||
}
|
||||
}
|
||||
|
||||
+17
-4
@@ -13,15 +13,17 @@ import {
|
||||
} from '../strategyHelpers/deploymentHelper'
|
||||
import {DeploymentStrategy} from '../types/deploymentStrategy'
|
||||
import {parseTrafficSplitMethod} from '../types/trafficSplitMethod'
|
||||
import {ClusterType} from '../inputUtils'
|
||||
export const ResourceTypeManagedCluster =
|
||||
'Microsoft.ContainerService/managedClusters'
|
||||
export const ResourceTypeFleet = 'Microsoft.ContainerService/fleets'
|
||||
export type ClusterType =
|
||||
| typeof ResourceTypeManagedCluster
|
||||
| typeof ResourceTypeFleet
|
||||
|
||||
export async function deploy(
|
||||
kubectl: Kubectl,
|
||||
manifestFilePaths: string[],
|
||||
deploymentStrategy: DeploymentStrategy,
|
||||
resourceType: ClusterType
|
||||
deploymentStrategy: DeploymentStrategy
|
||||
) {
|
||||
// update manifests
|
||||
const inputManifestFiles: string[] = updateManifestFiles(manifestFilePaths)
|
||||
@@ -43,6 +45,8 @@ export async function deploy(
|
||||
|
||||
// check manifest stability
|
||||
core.startGroup('Checking manifest stability')
|
||||
const resourceTypeInput =
|
||||
core.getInput('resource-type') || ResourceTypeManagedCluster
|
||||
const resourceTypes: Resource[] = getResources(
|
||||
deployedManifestFiles,
|
||||
models.DEPLOYMENT_TYPES.concat([
|
||||
@@ -50,7 +54,16 @@ export async function deploy(
|
||||
])
|
||||
)
|
||||
|
||||
await checkManifestStability(kubectl, resourceTypes, resourceType)
|
||||
if (
|
||||
resourceTypeInput !== ResourceTypeManagedCluster &&
|
||||
resourceTypeInput !== ResourceTypeFleet
|
||||
) {
|
||||
let errMsg = `Invalid resource type: ${resourceTypeInput}. Supported resource types are: ${ResourceTypeManagedCluster} (default), ${ResourceTypeFleet}`
|
||||
core.setFailed(errMsg)
|
||||
throw new Error(errMsg)
|
||||
}
|
||||
|
||||
await checkManifestStability(kubectl, resourceTypes, resourceTypeInput)
|
||||
core.endGroup()
|
||||
|
||||
// print ingresses
|
||||
|
||||
+14
-9
@@ -38,20 +38,19 @@ import {
|
||||
TrafficSplitMethod
|
||||
} from '../types/trafficSplitMethod'
|
||||
import {parseRouteStrategy, RouteStrategy} from '../types/routeStrategy'
|
||||
import {ClusterType} from '../inputUtils'
|
||||
import {ResourceTypeFleet, ResourceTypeManagedCluster} from './deploy'
|
||||
|
||||
export async function promote(
|
||||
kubectl: Kubectl,
|
||||
manifests: string[],
|
||||
deploymentStrategy: DeploymentStrategy,
|
||||
resourceType: ClusterType
|
||||
deploymentStrategy: DeploymentStrategy
|
||||
) {
|
||||
switch (deploymentStrategy) {
|
||||
case DeploymentStrategy.CANARY:
|
||||
await promoteCanary(kubectl, manifests)
|
||||
break
|
||||
case DeploymentStrategy.BLUE_GREEN:
|
||||
await promoteBlueGreen(kubectl, manifests, resourceType)
|
||||
await promoteBlueGreen(kubectl, manifests)
|
||||
break
|
||||
default:
|
||||
throw Error('Invalid promote deployment strategy')
|
||||
@@ -141,11 +140,7 @@ async function promoteCanary(kubectl: Kubectl, manifests: string[]) {
|
||||
core.endGroup()
|
||||
}
|
||||
|
||||
async function promoteBlueGreen(
|
||||
kubectl: Kubectl,
|
||||
manifests: string[],
|
||||
resourceType: ClusterType
|
||||
) {
|
||||
async function promoteBlueGreen(kubectl: Kubectl, manifests: string[]) {
|
||||
// update container images and pull secrets
|
||||
const inputManifestFiles: string[] = updateManifestFiles(manifests)
|
||||
const manifestObjects: BlueGreenManifests =
|
||||
@@ -172,6 +167,8 @@ async function promoteBlueGreen(
|
||||
|
||||
// checking stability of newly created deployments
|
||||
core.startGroup('Checking manifest stability')
|
||||
const resourceType =
|
||||
core.getInput('resource-type') || ResourceTypeManagedCluster
|
||||
const deployedManifestFiles = deployResult.manifestFiles
|
||||
const resources: Resource[] = getResources(
|
||||
deployedManifestFiles,
|
||||
@@ -179,6 +176,14 @@ async function promoteBlueGreen(
|
||||
models.DiscoveryAndLoadBalancerResource.SERVICE
|
||||
])
|
||||
)
|
||||
if (
|
||||
resourceType !== ResourceTypeManagedCluster &&
|
||||
resourceType !== ResourceTypeFleet
|
||||
) {
|
||||
const errMsg = `Invalid resource type: ${resourceType}. Supported resource types are: ${ResourceTypeManagedCluster} (default), fleet`
|
||||
core.setFailed(errMsg)
|
||||
throw new Error(errMsg)
|
||||
}
|
||||
await KubernetesManifestUtility.checkManifestStability(
|
||||
kubectl,
|
||||
resources,
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
import {parseResourceTypeInput} from './inputUtils'
|
||||
import {
|
||||
ClusterType,
|
||||
ResourceTypeFleet,
|
||||
ResourceTypeManagedCluster
|
||||
} from './actions/deploy'
|
||||
|
||||
describe('InputUtils', () => {
|
||||
describe('parseResourceTypeInput', () => {
|
||||
it('should extract fleet exact match resource type', () => {
|
||||
expect(
|
||||
parseResourceTypeInput('Microsoft.ContainerService/fleets')
|
||||
).toEqual(ResourceTypeFleet)
|
||||
})
|
||||
it('should match fleet case-insensitively', () => {
|
||||
expect(
|
||||
parseResourceTypeInput('Microsoft.containerservice/fleets')
|
||||
).toEqual(ResourceTypeFleet)
|
||||
})
|
||||
it('should match managed cluster case-insensitively', () => {
|
||||
expect(
|
||||
parseResourceTypeInput('Microsoft.containerservice/MAnaGedClusterS')
|
||||
).toEqual(ResourceTypeManagedCluster)
|
||||
})
|
||||
it('should error on unexpected values', () => {
|
||||
expect(() => {
|
||||
parseResourceTypeInput('icrosoft.ContainerService/ManagedCluster')
|
||||
}).toThrow()
|
||||
expect(() => {
|
||||
parseResourceTypeInput('wrong-value')
|
||||
}).toThrow()
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,6 +1,5 @@
|
||||
import * as core from '@actions/core'
|
||||
import {parseAnnotations} from './types/annotations'
|
||||
import {ResourceTypeFleet, ResourceTypeManagedCluster} from './actions/deploy'
|
||||
|
||||
export const inputAnnotations = parseAnnotations(
|
||||
core.getInput('annotations', {required: false})
|
||||
@@ -15,18 +14,3 @@ export function getBufferTime(): number {
|
||||
|
||||
return inputBufferTime
|
||||
}
|
||||
|
||||
export function parseResourceTypeInput(rawInput: string): ClusterType {
|
||||
switch (rawInput.toLowerCase()) {
|
||||
case ResourceTypeFleet.toLowerCase():
|
||||
return ResourceTypeFleet
|
||||
case ResourceTypeManagedCluster.toLowerCase():
|
||||
return ResourceTypeManagedCluster
|
||||
}
|
||||
throw new Error(
|
||||
`Invalid resource type: ${rawInput}. Supported resource types are: ${ResourceTypeManagedCluster} (default), ${ResourceTypeFleet}`
|
||||
)
|
||||
}
|
||||
export type ClusterType =
|
||||
| typeof ResourceTypeManagedCluster
|
||||
| typeof ResourceTypeFleet
|
||||
|
||||
+3
-19
@@ -1,18 +1,12 @@
|
||||
import * as core from '@actions/core'
|
||||
import {getKubectlPath, Kubectl} from './types/kubectl'
|
||||
import {
|
||||
deploy,
|
||||
ResourceTypeFleet,
|
||||
ResourceTypeManagedCluster
|
||||
} from './actions/deploy'
|
||||
import {ClusterType} from './inputUtils'
|
||||
import {deploy} from './actions/deploy'
|
||||
import {promote} from './actions/promote'
|
||||
import {reject} from './actions/reject'
|
||||
import {Action, parseAction} from './types/action'
|
||||
import {parseDeploymentStrategy} from './types/deploymentStrategy'
|
||||
import {getFilesFromDirectoriesAndURLs} from './utilities/fileUtils'
|
||||
import {PrivateKubectl} from './types/privatekubectl'
|
||||
import {parseResourceTypeInput} from './inputUtils'
|
||||
|
||||
export async function run() {
|
||||
// verify kubeconfig is set
|
||||
@@ -42,16 +36,6 @@ export async function run() {
|
||||
const resourceName = core.getInput('name') || ''
|
||||
const skipTlsVerify = core.getBooleanInput('skip-tls-verify')
|
||||
|
||||
let resourceType: ClusterType
|
||||
try {
|
||||
// included in the trycatch to allow raw input to go out of scope after parsing
|
||||
const resourceTypeInput = core.getInput('resource-type')
|
||||
resourceType = parseResourceTypeInput(resourceTypeInput)
|
||||
} catch (e) {
|
||||
core.setFailed(e)
|
||||
return
|
||||
}
|
||||
|
||||
const kubectl = isPrivateCluster
|
||||
? new PrivateKubectl(
|
||||
kubectlPath,
|
||||
@@ -65,11 +49,11 @@ export async function run() {
|
||||
// run action
|
||||
switch (action) {
|
||||
case Action.DEPLOY: {
|
||||
await deploy(kubectl, fullManifestFilePaths, strategy, resourceType)
|
||||
await deploy(kubectl, fullManifestFilePaths, strategy)
|
||||
break
|
||||
}
|
||||
case Action.PROMOTE: {
|
||||
await promote(kubectl, fullManifestFilePaths, strategy, resourceType)
|
||||
await promote(kubectl, fullManifestFilePaths, strategy)
|
||||
break
|
||||
}
|
||||
case Action.REJECT: {
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
} from '../utilities/githubUtils'
|
||||
import {getDeploymentConfig} from '../utilities/dockerUtils'
|
||||
import {DeployResult} from '../types/deployResult'
|
||||
import {ClusterType} from '../inputUtils'
|
||||
import {ClusterType} from '../actions/deploy'
|
||||
|
||||
export async function deployManifests(
|
||||
files: string[],
|
||||
|
||||
@@ -3,8 +3,7 @@ import * as KubernetesConstants from '../types/kubernetesTypes'
|
||||
import {Kubectl, Resource} from '../types/kubectl'
|
||||
import {checkForErrors} from './kubectlUtils'
|
||||
import {sleep} from './timeUtils'
|
||||
import {ResourceTypeFleet} from '../actions/deploy'
|
||||
import {ClusterType} from '../inputUtils'
|
||||
import {ClusterType, ResourceTypeFleet} from '../actions/deploy'
|
||||
|
||||
const IS_SILENT = false
|
||||
const POD = 'pod'
|
||||
@@ -12,10 +11,10 @@ const POD = 'pod'
|
||||
export async function checkManifestStability(
|
||||
kubectl: Kubectl,
|
||||
resources: Resource[],
|
||||
resourceType: ClusterType
|
||||
clusterTyper: ClusterType
|
||||
): Promise<void> {
|
||||
// Skip if resource type is microsoft.containerservice/fleets
|
||||
if (resourceType === ResourceTypeFleet) {
|
||||
if (clusterTyper === ResourceTypeFleet) {
|
||||
core.info(`Skipping checkManifestStability for ${ResourceTypeFleet}`)
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user