mirror of
https://github.com/Azure/k8s-deploy.git
synced 2026-06-21 10:39:26 +08:00
case-insensitive resource type (#398)
* case-insensitive resource type * inline error and throw outside switch * consistent input naming * catch failed clustertype parse * protect raw input * naming * format
This commit is contained in:
+4
-17
@@ -13,17 +13,15 @@ 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
|
||||
deploymentStrategy: DeploymentStrategy,
|
||||
resourceType: ClusterType
|
||||
) {
|
||||
// update manifests
|
||||
const inputManifestFiles: string[] = updateManifestFiles(manifestFilePaths)
|
||||
@@ -45,8 +43,6 @@ 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([
|
||||
@@ -54,16 +50,7 @@ export async function deploy(
|
||||
])
|
||||
)
|
||||
|
||||
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)
|
||||
await checkManifestStability(kubectl, resourceTypes, resourceType)
|
||||
core.endGroup()
|
||||
|
||||
// print ingresses
|
||||
|
||||
Reference in New Issue
Block a user