diff --git a/src/config.ts b/src/config.ts index efbb820..1daadea 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { DeploymentProperties } from '@azure/arm-resources' import { DeploymentStackProperties } from '@azure/arm-resourcesdeploymentstacks' diff --git a/src/handler.ts b/src/handler.ts index f7b9c20..a78e729 100644 --- a/src/handler.ts +++ b/src/handler.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import { DeploymentProperties, @@ -41,15 +43,17 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< switch (this.config.scope) { case 'tenant': { - this.config.await - ? await this.client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginCreateOrUpdateAtTenantScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginCreateOrUpdateAtTenantScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginCreateOrUpdateAtTenantScope( + this.config.name, + deploymentParams + ) + } break } case 'managementGroup': { @@ -59,29 +63,33 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( - managementGroupId, - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginCreateOrUpdateAtManagementGroupScope( - managementGroupId, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginCreateOrUpdateAtManagementGroupScopeAndWait( + managementGroupId, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginCreateOrUpdateAtManagementGroupScope( + managementGroupId, + this.config.name, + deploymentParams + ) + } break } case 'subscription': { - this.config.await - ? await this.client.deployments.beginCreateOrUpdateAtSubscriptionScopeAndWait( - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginCreateOrUpdateAtSubscriptionScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginCreateOrUpdateAtSubscriptionScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginCreateOrUpdateAtSubscriptionScope( + this.config.name, + deploymentParams + ) + } break } case 'resourceGroup': { @@ -91,17 +99,19 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginCreateOrUpdateAndWait( - resourceGroupName, - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginCreateOrUpdate( - resourceGroupName, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginCreateOrUpdateAndWait( + resourceGroupName, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginCreateOrUpdate( + resourceGroupName, + this.config.name, + deploymentParams + ) + } break } default: { @@ -120,15 +130,17 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< switch (this.config.scope) { case 'tenant': { - this.config.await - ? await this.client.deployments.beginValidateAtTenantScopeAndWait( - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginValidateAtTenantScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginValidateAtTenantScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginValidateAtTenantScope( + this.config.name, + deploymentParams + ) + } break } case 'managementGroup': { @@ -138,29 +150,33 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginValidateAtManagementGroupScopeAndWait( - managementGroupId, - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginValidateAtManagementGroupScope( - managementGroupId, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginValidateAtManagementGroupScopeAndWait( + managementGroupId, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginValidateAtManagementGroupScope( + managementGroupId, + this.config.name, + deploymentParams + ) + } break } case 'subscription': { - this.config.await - ? await this.client.deployments.beginValidateAtSubscriptionScopeAndWait( - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginValidateAtSubscriptionScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginValidateAtSubscriptionScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginValidateAtSubscriptionScope( + this.config.name, + deploymentParams + ) + } break } case 'resourceGroup': { @@ -170,17 +186,19 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginValidateAndWait( - resourceGroupName, - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginValidate( - resourceGroupName, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginValidateAndWait( + resourceGroupName, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginValidate( + resourceGroupName, + this.config.name, + deploymentParams + ) + } break } default: { @@ -199,15 +217,17 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< switch (this.config.scope) { case 'tenant': { - this.config.await - ? await this.client.deployments.beginWhatIfAtTenantScopeAndWait( - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginWhatIfAtTenantScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginWhatIfAtTenantScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginWhatIfAtTenantScope( + this.config.name, + deploymentParams + ) + } break } case 'managementGroup': { @@ -217,29 +237,33 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginWhatIfAtManagementGroupScopeAndWait( - managementGroupId, - this.config.name, - deploymentParams - ) - : this.client.deployments.beginWhatIfAtManagementGroupScope( - managementGroupId, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginWhatIfAtManagementGroupScopeAndWait( + managementGroupId, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginWhatIfAtManagementGroupScope( + managementGroupId, + this.config.name, + deploymentParams + ) + } break } case 'subscription': { - this.config.await - ? this.client.deployments.beginWhatIfAtSubscriptionScopeAndWait( - this.config.name, - deploymentParams - ) - : this.client.deployments.beginWhatIfAtSubscriptionScope( - this.config.name, - deploymentParams - ) + if (this.config.await) { + this.client.deployments.beginWhatIfAtSubscriptionScopeAndWait( + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginWhatIfAtSubscriptionScope( + this.config.name, + deploymentParams + ) + } break } case 'resourceGroup': { @@ -249,17 +273,19 @@ export class ResourceDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deployments.beginWhatIfAndWait( - resourceGroupName, - this.config.name, - deploymentParams - ) - : await this.client.deployments.beginWhatIf( - resourceGroupName, - this.config.name, - deploymentParams - ) + if (this.config.await) { + await this.client.deployments.beginWhatIfAndWait( + resourceGroupName, + this.config.name, + deploymentParams + ) + } else { + await this.client.deployments.beginWhatIf( + resourceGroupName, + this.config.name, + deploymentParams + ) + } break } } @@ -286,29 +312,33 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginCreateOrUpdateAtManagementGroupAndWait( - managementGroupId, - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginCreateOrUpdateAtManagementGroup( - managementGroupId, - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginCreateOrUpdateAtManagementGroupAndWait( + managementGroupId, + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginCreateOrUpdateAtManagementGroup( + managementGroupId, + this.config.name, + stackParams + ) + } break } case 'subscription': { - this.config.await - ? await this.client.deploymentStacks.beginCreateOrUpdateAtSubscriptionAndWait( - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginCreateOrUpdateAtSubscription( - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginCreateOrUpdateAtSubscriptionAndWait( + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginCreateOrUpdateAtSubscription( + this.config.name, + stackParams + ) + } break } case 'resourceGroup': { @@ -318,17 +348,19 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginCreateOrUpdateAtResourceGroupAndWait( - resourceGroupName, - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginCreateOrUpdateAtResourceGroup( - resourceGroupName, - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginCreateOrUpdateAtResourceGroupAndWait( + resourceGroupName, + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginCreateOrUpdateAtResourceGroup( + resourceGroupName, + this.config.name, + stackParams + ) + } break } default: { @@ -353,29 +385,33 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginValidateStackAtManagementGroupAndWait( - managementGroupId, - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginValidateStackAtManagementGroup( - managementGroupId, - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginValidateStackAtManagementGroupAndWait( + managementGroupId, + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginValidateStackAtManagementGroup( + managementGroupId, + this.config.name, + stackParams + ) + } break } case 'subscription': { - this.config.await - ? await this.client.deploymentStacks.beginValidateStackAtSubscriptionAndWait( - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginValidateStackAtSubscription( - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginValidateStackAtSubscriptionAndWait( + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginValidateStackAtSubscription( + this.config.name, + stackParams + ) + } break } case 'resourceGroup': { @@ -385,17 +421,19 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginValidateStackAtResourceGroupAndWait( - resourceGroupName, - this.config.name, - stackParams - ) - : await this.client.deploymentStacks.beginValidateStackAtResourceGroup( - resourceGroupName, - this.config.name, - stackParams - ) + if (this.config.await) { + await this.client.deploymentStacks.beginValidateStackAtResourceGroupAndWait( + resourceGroupName, + this.config.name, + stackParams + ) + } else { + await this.client.deploymentStacks.beginValidateStackAtResourceGroup( + resourceGroupName, + this.config.name, + stackParams + ) + } break } default: { @@ -414,25 +452,29 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.managementGroupId : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginDeleteAtManagementGroupAndWait( - managementGroupId, - this.config.name - ) - : await this.client.deploymentStacks.beginDeleteAtManagementGroup( - managementGroupId, - this.config.name - ) + if (this.config.await) { + await this.client.deploymentStacks.beginDeleteAtManagementGroupAndWait( + managementGroupId, + this.config.name + ) + } else { + await this.client.deploymentStacks.beginDeleteAtManagementGroup( + managementGroupId, + this.config.name + ) + } break } case 'subscription': { - this.config.await - ? await this.client.deploymentStacks.beginDeleteAtSubscriptionAndWait( - this.config.name - ) - : await this.client.deploymentStacks.beginDeleteAtSubscription( - this.config.name - ) + if (this.config.await) { + await this.client.deploymentStacks.beginDeleteAtSubscriptionAndWait( + this.config.name + ) + } else { + await this.client.deploymentStacks.beginDeleteAtSubscription( + this.config.name + ) + } break } case 'resourceGroup': { @@ -442,15 +484,17 @@ export class StackDeploymentHandler extends BaseDeploymentHandler< ? this.config.context.resourceGroupName : helpers.throwError('Invalid context') - this.config.await - ? await this.client.deploymentStacks.beginDeleteAtResourceGroupAndWait( - resourceGroupName, - this.config.name - ) - : await this.client.deploymentStacks.beginDeleteAtResourceGroup( - resourceGroupName, - this.config.name - ) + if (this.config.await) { + await this.client.deploymentStacks.beginDeleteAtResourceGroupAndWait( + resourceGroupName, + this.config.name + ) + } else { + await this.client.deploymentStacks.beginDeleteAtResourceGroup( + resourceGroupName, + this.config.name + ) + } break } default: { diff --git a/src/helpers/context.ts b/src/helpers/context.ts index 85d7292..fe34587 100644 --- a/src/helpers/context.ts +++ b/src/helpers/context.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import * as helpers from '../helpers' diff --git a/src/helpers/error.ts b/src/helpers/error.ts index 33ab919..7f367c0 100644 --- a/src/helpers/error.ts +++ b/src/helpers/error.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. export function throwError(message: string): never { throw new Error(message) } diff --git a/src/helpers/file.ts b/src/helpers/file.ts index a48422c..1f9a02b 100644 --- a/src/helpers/file.ts +++ b/src/helpers/file.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import * as exec from '@actions/exec' import * as io from '@actions/io' diff --git a/src/helpers/index.ts b/src/helpers/index.ts index 43df1e1..6355f47 100644 --- a/src/helpers/index.ts +++ b/src/helpers/index.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. export * from './context' export * from './file' export * from './error' diff --git a/src/helpers/input.ts b/src/helpers/input.ts index b88e27c..73f55d6 100644 --- a/src/helpers/input.ts +++ b/src/helpers/input.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import * as helpers from '../helpers' diff --git a/src/helpers/version.ts b/src/helpers/version.ts index baf77be..428456d 100644 --- a/src/helpers/version.ts +++ b/src/helpers/version.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import * as exec from '@actions/exec' import * as io from '@actions/io' diff --git a/src/index.ts b/src/index.ts index b08f970..b2a6ae7 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,5 @@ -/** - * The entrypoint for the action. - */ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import { run } from './main' // eslint-disable-next-line @typescript-eslint/no-floating-promises diff --git a/src/main.ts b/src/main.ts index 864453c..2079ff0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. import * as core from '@actions/core' import { ResourceManagementClient } from '@azure/arm-resources'