Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for labels #417

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

Conversation

kylehayes
Copy link

@kylehayes kylehayes commented Nov 18, 2020

I added support for labels which by itself was a pretty simple change by passing the labelFilter property into listConfigurationSettings. When running this in production for our system, however, the Azure credentials were not being picked up from our container's environment. I realized this was because the credentials were not read from process.env when loading in config(). I added support for this which required some typing change since it was no longer the same shape as DotenvParseOutput.

I'm not married to any of this so open to any suggestions. Thanks for creating this project!

Copy link
Collaborator

@danielfsousa danielfsousa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just need to add some tests and update the README.md before merging.

Thank you for your contribution!

src/dotenv-azure.ts Outdated Show resolved Hide resolved
src/dotenv-azure.ts Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
package-lock.json Outdated Show resolved Hide resolved
@kylehayes
Copy link
Author

Sounds great! I've made the changes locally per your suggestions. I'll add some tests and update the README within the week.

- Adding support for labels
- Mixing in process.env for Azure loadFromAzure
@kylehayes
Copy link
Author

I added a test to ensure config doesn't throw if labels are defined. I'm not sure if or what other tests you might be looking for to test the label filtering functionality. I'm not very experience with mocks so any direction or assistance you can provide with awesome.

@danielfsousa
Copy link
Collaborator

I added a test to ensure config doesn't throw if labels are defined. I'm not sure if or what other tests you might be looking for to test the label filtering functionality. I'm not very experience with mocks so any direction or assistance you can provide with awesome.

We could use the toBeCalledWith function to assert that we are passing the AZURE_APP_CONFIG_LABELS to client.listConfigurationSettings():

expect(appConfigListMock).toBeCalledWith(
  expect.objectContaining({
    labelFilter: AZURE_APP_CONFIG_LABELS,
  })
)

@danielfsousa
Copy link
Collaborator

Another good feature to have is allowing the label filter to be defined programmatically, just like the connectionString:

const connectionString = this.connectionString || vars.AZURE_APP_CONFIG_CONNECTION_STRING

Then we could use it like this:

await dotenvAzure.config({ labels: 'production,development' })

or

await dotenvAzure.config({ labels: ['production', 'development'] })

@danielfsousa
Copy link
Collaborator

danielfsousa commented Nov 25, 2020

The CI is failing because of prettier, just run the script below, commit the changes and it should be fixed:

npm run format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants