Skip to content

Commit

Permalink
feat: support for labels
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Hayes committed Nov 4, 2020
1 parent a042b4c commit 186128a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/dotenv-azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,11 @@ export default class DotenvAzure {
async loadFromAzure(dotenvVars?: DotenvParseOutput): Promise<VariablesObject> {
const credentials = this.getAzureCredentials(dotenvVars)
const appConfigClient = new AppConfigurationClient(credentials.connectionString)
const { appConfigVars, keyVaultReferences } = await this.getAppConfigurations(appConfigClient)
const labels = dotenvVars?.AZURE_APP_CONFIG_LABELS || ''
const { appConfigVars, keyVaultReferences } = await this.getAppConfigurations(
appConfigClient,
labels
)
const keyVaultSecrets = await this.getSecretsFromKeyVault(credentials, keyVaultReferences)
return { ...appConfigVars, ...keyVaultSecrets }
}
Expand All @@ -114,11 +118,14 @@ export default class DotenvAzure {
}
}

protected async getAppConfigurations(client: AppConfigurationClient): Promise<AppConfigurations> {
protected async getAppConfigurations(
client: AppConfigurationClient,
labels = ''
): Promise<AppConfigurations> {
const appConfigVars: VariablesObject = {}
const keyVaultReferences: KeyVaultReferences = {}

for await (const config of client.listConfigurationSettings()) {
for await (const config of client.listConfigurationSettings({ labelFilter: labels })) {
if (this.isKeyVaultReference(config)) {
keyVaultReferences[config.key] = this.getKeyVaultReferenceInfo(config)
} else {
Expand Down

0 comments on commit 186128a

Please sign in to comment.