Skip to content

Commit

Permalink
remove default tags
Browse files Browse the repository at this point in the history
  • Loading branch information
baoduy committed Mar 18, 2024
1 parent 507a3d6 commit 496a219
Show file tree
Hide file tree
Showing 30 changed files with 37 additions and 98 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/build-publish-drunk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ jobs:

- run: npm ci

# - name: Run Lints
# run: npm run lint
- name: Run Lints
continue-on-error: true
run: npm run lint

#Fix node_modules/openpgp/openpgp.d.ts:10:46 - error
# - name: Replace text in file
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"test": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register 'z_tests/**/*.test.ts'",
"testcert": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' mocha --timeout 10000 -r ts-node/register '**/*.ts'",
"test-cover": "cross-env TS_NODE_PROJECT='./tsconfig.test.json' nyc mocha --timeout 10000 -r ts-node/register 'z_tests/**/*.ts'",
"lint": "eslint **/*.ts --fix"
"lint": "eslint src/**/*.ts --fix"
},
"devDependencies": {
"@types/chai": "^4.3.12",
Expand Down
14 changes: 7 additions & 7 deletions src/Aks/Helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ export const getAksIdentitySecrets = ({
return getIdentitySecrets({ name, vaultInfo });
};

interface AksProps {
aksName: string;
formatedName?: boolean;
namespace?: string;
groupName: string;
localAccountDisabled?: boolean;
}
// interface AksProps {
// aksName: string;
// formatedName?: boolean;
// namespace?: string;
// groupName: string;
// localAccountDisabled?: boolean;
// }

// /** Get AKS Provider from Managed Cluster*/
// export const createAksProvider = async ({
Expand Down
2 changes: 0 additions & 2 deletions src/Aks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { BasicMonitorArgs, BasicResourceArgs, KeyVaultInfo } from '../types';
import {
currentEnv,
defaultScope,
defaultTags,
Environments,
getResourceIdFromInfo,
getResourceInfoFromId,
Expand Down Expand Up @@ -501,7 +500,6 @@ export default async ({
: undefined,
},

tags: defaultTags,
},
{
protect: lock,
Expand Down
4 changes: 1 addition & 3 deletions src/Apim/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as apimanagement from '@pulumi/azure-native/apimanagement';
import { Input } from '@pulumi/pulumi';

import { defaultTags } from '../Common/AzureEnv';
import { getApimName } from '../Common/Naming';
import { organization } from '../Common/StackEnv';
import { randomUuId } from '../Core/Random';
Expand Down Expand Up @@ -125,7 +123,7 @@ export default ({
"Microsoft.WindowsAzure.ApiManagement.Gateway.Security.Protocols.Tls11":
"false",
},
tags: defaultTags,

lock,
...others,
ignoreChanges: [],
Expand Down
5 changes: 1 addition & 4 deletions src/Apps/LogicApp.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import * as logic from '@pulumi/azure-native/logic';

import { BasicResourceArgs, DefaultResourceArgs } from '../types';

import creator from '../Core/ResourceCreator';
import { defaultTags } from '../Common/AzureEnv';
import { global } from '../Common';
import { getCertOrderName } from '../Common/Naming';

Expand All @@ -17,7 +14,7 @@ export default ({ name, ...others }: Props) => {
...global.groupInfo,
...others,
sku: '',
tags: defaultTags,

} as logic.WorkflowArgs & DefaultResourceArgs);

return order;
Expand Down
4 changes: 2 additions & 2 deletions src/Automation/AutoAccount.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BasicResourceArgs } from '../types';
import * as automation from '@pulumi/azure-native/automation';
import { getAutomationAccountName } from '../Common/Naming';
import { defaultTags } from '../Common/AzureEnv';


interface Props extends BasicResourceArgs {}

Expand All @@ -18,6 +18,6 @@ export default ({ name, group }: Props) => {
sku: {
name: 'Free', //Free, Basic
},
tags: defaultTags,

});
};
3 changes: 1 addition & 2 deletions src/AzAd/ManagedIdentity.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { BasicResourceArgs } from "../types";
import * as azure from "@pulumi/azure-native";
import { getManagedIdentityName } from "../Common/Naming";
import { defaultTags } from "../Common/AzureEnv";
import Locker from "../Core/Locker";

interface Props extends BasicResourceArgs {
Expand All @@ -13,7 +12,7 @@ export default ({ name, group, lock }: Props) => {
const managedIdentity = new azure.managedidentity.UserAssignedIdentity(n, {
resourceName: n,
...group,
tags: defaultTags,

});

if (lock) {
Expand Down
3 changes: 1 addition & 2 deletions src/Cdn/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as cdn from '@pulumi/azure-native/cdn';
import * as azureAd from '@pulumi/azuread';
import { getCdnProfileName } from '../Common/Naming';
import { global } from '../Common';
import { defaultTags } from '../Common/AzureEnv';
import { grantVaultRbacPermission } from '../KeyVault/VaultPermissions';

interface Props {
Expand All @@ -27,7 +26,7 @@ export default ({
...group,
location: 'global',
sku: { name: cdn.SkuName.Standard_Microsoft },
tags: defaultTags,

});

if (vaultAccess) {
Expand Down
7 changes: 2 additions & 5 deletions src/Common/AzureEnv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ pulumi.all([subscriptionId, tenantId]).apply(([s, t]) => {
});

/** ======== Default Variables ================*/

export const defaultTags = {
registerAutoTags({
environment: stack,
organization: organization,
"pulumi-project": projectName,
};

registerAutoTags(defaultTags);
});

export enum Environments {
Global = "global",
Expand Down
6 changes: 3 additions & 3 deletions src/Core/ResourceCreator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint @typescript-eslint/no-explicit-any: "off" */

import * as authorization from '@pulumi/azure-native/authorization';
import * as pulumi from '@pulumi/pulumi';

import { DefaultResourceArgs } from '../types';
import { DiagnosticSetting } from '@pulumi/azure-native/aadiam/diagnosticSetting';
import Locker from './Locker';
import { createDiagnostic } from '../Logs/Helpers';
import { defaultTags } from '../Common/AzureEnv';

const tryFindName = (props: unknown, isResourceGroup: boolean): string => {
const rs = props as {
Expand Down Expand Up @@ -57,7 +57,7 @@ export default function <

const resource = new Class(
name,
{ name, ...props, tags: defaultTags },
{ name, ...props },
{ dependsOn, import: importUri, ignoreChanges, deleteBeforeReplace: true }
);

Expand Down
22 changes: 4 additions & 18 deletions src/CosmosDb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import * as documentdb from '@pulumi/azure-native/documentdb';
import { getCosmosDbName } from '../Common/Naming';
import { DefaultResourceArgs, KeyVaultInfo, ResourceGroupInfo } from '../types';
import ResourceCreator from '../Core/ResourceCreator';
import { defaultTags, isPrd } from '../Common/AzureEnv';
import { isPrd} from '../Common/AzureEnv';
import { createThreatProtection } from '../Logs/Helpers';
import { Input } from '@pulumi/pulumi';

interface CosmosDbProps {
name: string;
group: ResourceGroupInfo;
vaultInfo?: KeyVaultInfo;
locations?: Input<string>[];
locations?: Array<Input<string>>;
enableMultipleWriteLocations?: boolean;
capabilities?: Array<'EnableCassandra' | 'EnableTable' | 'EnableGremlin'>;
kind?: documentdb.DatabaseAccountKind;
Expand Down Expand Up @@ -51,20 +51,6 @@ export default ({
}: CosmosDbProps) => {
name = getCosmosDbName(name);

/**
* The failover priority of the region. A failover priority of 0 indicates a write region. The maximum value for a failover priority = (total number of regions - 1). Failover priority values must be unique for each of the regions in which the database account exists.
*/
//failoverPriority?: pulumi.Input<number>;
/**
* Flag to indicate whether or not this region is an AvailabilityZone region
*/
//isZoneRedundant?: pulumi.Input<boolean>;
/**
* The name of the region.
*/
//locationName?: pulumi.Input<string>;
if (!locations) locations = [group.location!];

const { resource } = ResourceCreator(documentdb.DatabaseAccount, {
accountName: name,
...group,
Expand All @@ -76,7 +62,7 @@ export default ({
? capabilities.map((n) => ({ name: n }))
: undefined,

locations: locations?.map((n) => ({ locationName: n })),
locations:locations? locations.map((n) => ({ locationName: n })):[{locationName: group.location}],

backupPolicy: isPrd
? {
Expand Down Expand Up @@ -137,7 +123,7 @@ export default ({
],
metricsCategories: ['Requests'],
},
tags: defaultTags,

} as unknown as documentdb.DatabaseAccountArgs & DefaultResourceArgs);

if (
Expand Down
3 changes: 1 addition & 2 deletions src/IOT/Hub/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BasicResourceArgs, KeyVaultInfo } from '../../types';
import { getIotHubName } from '../../Common/Naming';
import * as devices from '@pulumi/azure-native/devices';
import { defaultTags, subscriptionId } from '../../Common/AzureEnv';
import { subscriptionId } from '../../Common/AzureEnv';
import { Input } from '@pulumi/pulumi';
import Locker from '../../Core/Locker';
import { EnvRoleNamesType } from '../../AzAd/EnvRoles';
Expand Down Expand Up @@ -124,7 +124,6 @@ export default async ({
...group,

sku,
tags: defaultTags,

properties: {
//authorizationPolicies: [{}],
Expand Down
2 changes: 0 additions & 2 deletions src/KeyVault/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { enums } from "@pulumi/azure-native/types";
import { Input } from "@pulumi/pulumi";
import {
currentPrincipal,
defaultTags,
subscriptionId,
tenantId,
} from "../Common/AzureEnv";
Expand Down Expand Up @@ -103,7 +102,6 @@ export default ({
},
},

tags: defaultTags,
});

//Grant RBAC permission
Expand Down
3 changes: 1 addition & 2 deletions src/Logs/LogAnalytics.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as operationalinsights from '@pulumi/azure-native/operationalinsights';
import { defaultTags } from '../Common/AzureEnv';
import { KeyVaultInfo, ResourceGroupInfo } from '../types';
import { getKeyName, getLogWpName } from '../Common/Naming';
import { addCustomSecret } from '../KeyVault/CustomHelper';
Expand Down Expand Up @@ -36,7 +35,7 @@ export default ({
retentionInDays:
sku === operationalinsights.WorkspaceSkuNameEnum.Free ? 7 : 30, //DO NOT changes this
sku: { name: sku },
tags: defaultTags,

});

if (vaultInfo) {
Expand Down
3 changes: 1 addition & 2 deletions src/ServiceBus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
getTopicName,
getTopicOrQueueVaultName,
} from './ServiceBusHelper';
import { defaultTags, isPrd } from '../Common/AzureEnv';
import { isPrd } from '../Common/AzureEnv';
import creator from '../Core/ResourceCreator';
import { getPrivateEndpointName, getServiceBusName } from '../Common/Naming';
import PrivateEndpoint from '../VNet/PrivateEndpoint';
Expand Down Expand Up @@ -519,7 +519,6 @@ export default ({
...group,
sku: { name: sku, tier: sku },

tags: defaultTags,
...others,

monitoring: monitoring
Expand Down
5 changes: 2 additions & 3 deletions src/SignalR/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as native from '@pulumi/azure-native';
import * as pulumi from '@pulumi/pulumi';

import { defaultTags, isDev } from '../Common/AzureEnv';
import { isDev } from '../Common/AzureEnv';
import { getPrivateEndpointName, getSignalRName } from '../Common/Naming';
import { BasicResourceArgs, KeyVaultInfo, PrivateLinkProps } from '../types';
import PrivateEndpoint from '../VNet/PrivateEndpoint';
Expand Down Expand Up @@ -81,7 +80,7 @@ export default ({
}
: undefined,
sku,
tags: defaultTags,

});

let privateEndpoint: native.network.PrivateEndpoint | undefined = undefined;
Expand Down
3 changes: 1 addition & 2 deletions src/Sql/SqlDb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as sql from '@pulumi/azure-native/sql';
import { BasicResourceArgs, BasicResourceResultProps } from '../types';
import { Input, Output, Resource } from '@pulumi/pulumi';

import { defaultTags, isPrd } from '../Common/AzureEnv';
import { isPrd } from '../Common/AzureEnv';
import { getSqlDbName } from '../Common/Naming';
import Locker from '../Core/Locker';

Expand Down Expand Up @@ -59,7 +59,6 @@ export default ({
//zoneRedundant: isPrd,
requestedBackupStorageRedundancy: isPrd ? 'Zone' : 'Local',

tags: defaultTags,
},
{ dependsOn }
);
Expand Down
4 changes: 1 addition & 3 deletions src/Sql/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getAdGroup } from '../AzAd/Group';
import { roleAssignment } from '../AzAd/RoleAssignment';
import {
currentEnv,
defaultTags,
isPrd,
subscriptionId,
tenantId,
Expand Down Expand Up @@ -179,7 +178,6 @@ export default ({
? sql.ServerNetworkAccessFlag.Disabled
: sql.ServerNetworkAccessFlag.Enabled,

tags: defaultTags,
},
{
ignoreChanges,
Expand Down Expand Up @@ -339,7 +337,7 @@ export default ({
vaultInfo,
contentType: `Sql ${d.name} Connection String`,
dependsOn: d.resource,
tags: defaultTags,

});
}

Expand Down
4 changes: 1 addition & 3 deletions src/Storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { KeyVaultInfo, BasicResourceArgs } from '../types';
import { Input, output } from '@pulumi/pulumi';
import { createThreatProtection } from '../Logs/Helpers';
import { getSecret } from '../KeyVault/Helper';
import { defaultTags, isPrd } from '../Common/AzureEnv';
import { isPrd } from '../Common/AzureEnv';
import cdnCreator from './CdnEndpoint';

import {
Expand Down Expand Up @@ -186,8 +186,6 @@ export default ({
: undefined,
}
: { defaultAction: 'Allow' },

tags: defaultTags,
});

//Soft Delete
Expand Down
Loading

0 comments on commit 496a219

Please sign in to comment.