Skip to content

Commit

Permalink
refactor: remove path aliases and rewrite to default exports
Browse files Browse the repository at this point in the history
  • Loading branch information
Harjot1Singh committed Oct 1, 2023
1 parent 5a9fea4 commit 44cfa74
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 31 deletions.
4 changes: 3 additions & 1 deletion environment/cluster-applications/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ type Options = {
cluster: Awaited<ReturnType<typeof cluster>>,
}

export = async ( { cluster }: Options ) => {
const clusterApplicationsModule = async ( { cluster }: Options ) => {
traefik( { cluster } )
}

export default clusterApplicationsModule
4 changes: 3 additions & 1 deletion environment/cluster-applications/traefik.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const certificateResolvers = [

const config = new Config()

export = ( { cluster: { provider } }: Options ) => {
const traefik = ( { cluster: { provider } }: Options ) => {
new helm.v3.Chart( 'traefik-ingress', {
chart: 'traefik',
version: '10.19.4',
Expand Down Expand Up @@ -50,3 +50,5 @@ export = ( { cluster: { provider } }: Options ) => {
},
}, { provider } )
}

export default traefik
7 changes: 4 additions & 3 deletions environment/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { listManagedClusterUserCredentialsOutput, ManagedCluster } from '@pulumi/azure-native/containerservice'
import { Provider } from '@pulumi/kubernetes'

import identity from '~/shared/identity'

import identity from '../shared/identity'
import logging from './logging'
import network from './network'

Expand All @@ -12,7 +11,7 @@ type Options = {
logging: Awaited<ReturnType<typeof logging>>,
}

export = async ( {
const clusterModule = async ( {
identity: { application, resourceGroup, servicePrincipalPassword },
network: { subnet },
logging: { logAnalyticsWorkspace },
Expand Down Expand Up @@ -57,3 +56,5 @@ export = async ( {

return { cluster, kubeconfig, provider }
}

export default clusterModule
7 changes: 4 additions & 3 deletions environment/github-secrets.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { ActionsOrganizationSecret } from '@pulumi/github'

import * as environment from '~/shared/environment'

import * as environment from '../shared/environment'
import cluster from './cluster'

type Options = {
cluster: Awaited<ReturnType<typeof cluster>>,
}

export = async ( { cluster: { kubeconfig } }: Options ) => {
const githubSecretsModule = async ( { cluster: { kubeconfig } }: Options ) => {
new ActionsOrganizationSecret( 'kubeconfig-github-secret', {
secretName: `${environment.name.toUpperCase()}__KUBECONFIG`,
visibility: 'all',
plaintextValue: kubeconfig,
} )
}

export default githubSecretsModule
9 changes: 5 additions & 4 deletions environment/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import azureModule from '~/shared/azure'
import identityModule from '~/shared/identity'

import azureModule from '../shared/azure'
import identityModule from '../shared/identity'
import clusterModule from './cluster'
import clusterApplications from './cluster-applications'
import githubSecretsModule from './github-secrets'
import loggingModule from './logging'
import networkModule from './network'

export = async () => {
const stack = async () => {
const azure = await azureModule()

const identity = await identityModule()
Expand All @@ -23,3 +22,5 @@ export = async () => {
logAnalyticsWorkspaceId: logging.logAnalyticsWorkspace.id,
}
}

export = stack
6 changes: 4 additions & 2 deletions environment/logging.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Workspace } from '@pulumi/azure-native/operationalinsights'

import identity from '~/shared/identity'
import identity from '../shared/identity'

type Options = {
identity: Awaited<ReturnType<typeof identity>>,
}

export = async ( { identity: { resourceGroup } }: Options ) => {
const loggingModule = async ( { identity: { resourceGroup } }: Options ) => {
const logAnalyticsWorkspace = new Workspace( 'default-workspace', {
resourceGroupName: resourceGroup.name,
location: resourceGroup.location,
Expand All @@ -15,3 +15,5 @@ export = async ( { identity: { resourceGroup } }: Options ) => {

return { logAnalyticsWorkspace }
}

export default loggingModule
8 changes: 5 additions & 3 deletions environment/network.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { PrincipalType, RoleAssignment } from '@pulumi/azure-native/authorization'
import { Subnet, VirtualNetwork } from '@pulumi/azure-native/network'

import azure from '~/shared/azure'
import identity from '~/shared/identity'
import azure from '../shared/azure'
import identity from '../shared/identity'

type Options = {
azure: Awaited<ReturnType<typeof azure>>,
identity: Awaited<ReturnType<typeof identity>>,
}

export = async ( {
const networkModule = async ( {
azure: { subscriptionId },
identity: { resourceGroup, servicePrincipal },
}: Options ) => {
Expand All @@ -33,3 +33,5 @@ export = async ( {

return { virtualNetwork, subnet, subnetAssignment }
}

export default networkModule
4 changes: 3 additions & 1 deletion shared/azure.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { getClientConfig } from '@pulumi/azure-native/authorization'

export = async () => {
const azureModule = async () => {
const { subscriptionId, tenantId } = await getClientConfig()

return { subscriptionId, tenantId }
}

export default azureModule
6 changes: 4 additions & 2 deletions shared/identity.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { ResourceGroup } from '@pulumi/azure-native/resources'
import { Application, ServicePrincipal, ServicePrincipalPassword } from '@pulumi/azuread'

import * as environment from '~/shared/environment'
import * as environment from './environment'

export = async () => {
const identityModule = async () => {
const application = new Application( `${environment.name}-environment-app`, { displayName: `${environment.name}-environment-app` } )

const servicePrincipal = new ServicePrincipal( `${environment.name}-environment-service-principal`, {
Expand All @@ -21,3 +21,5 @@ export = async () => {

return { application, servicePrincipal, servicePrincipalPassword, resourceGroup }
}

export default identityModule
9 changes: 5 additions & 4 deletions tools/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import azureModule from '~/shared/azure'
import identityModule from '~/shared/identity'

import azureModule from '../shared/azure'
import identityModule from '../shared/identity'
import keyVaultModule from './key-vault'

export = async () => {
const stack = async () => {
const azure = await azureModule()

const identity = await identityModule()

await keyVaultModule( { azure, identity } )
}

export = stack
8 changes: 5 additions & 3 deletions tools/key-vault.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { keyvault } from '@pulumi/azure-native'

import azure from '~/shared/azure'
import identity from '~/shared/identity'
import azure from '../shared/azure'
import identity from '../shared/identity'

type Options = {
azure: Awaited<ReturnType<typeof azure>>,
identity: Awaited<ReturnType<typeof identity>>,
}

export = async ( {
const keyVaultModule = async ( {
azure: { tenantId },
identity: { resourceGroup, servicePrincipal },
}: Options ) => new keyvault.Vault( 'shabad-os-tools', {
Expand All @@ -31,3 +31,5 @@ export = async ( {
} ],
},
} )

export default keyVaultModule
5 changes: 1 addition & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
"noEmit": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"skipLibCheck": true,
"paths": {
"~/*": ["./*"]
}
"skipLibCheck": true
}
}

0 comments on commit 44cfa74

Please sign in to comment.