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

feat(variform): add a builtin function to get env vars #13507

Merged
merged 2 commits into from
Jul 25, 2024

Conversation

lafirest
Copy link
Member

@lafirest lafirest commented Jul 23, 2024

Fixes EMQX-12702

Release version: v/e5.7.2

Summary

PR Checklist

Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:

  • Added tests for the changes
  • Added property-based tests for code which performs user input validation
  • Changed lines covered in coverage report
  • Change log has been added to changes/(ce|ee)/(feat|perf|fix|breaking)-<PR-id>.en.md files
  • For internal contributor: there is a jira ticket to track this change
  • Created PR to emqx-docs if documentation update is required, or link to a follow-up jira ticket
  • Schema changes are backward compatible

Checklist for CI (.github/workflows) changes

  • If changed package build workflow, pass this action (manual trigger)
  • Change log has been added to changes/ dir for user-facing artifacts update

@lafirest lafirest marked this pull request as ready for review July 23, 2024 09:40
@lafirest lafirest requested a review from a team as a code owner July 23, 2024 09:40
@@ -252,6 +252,9 @@
timezone_to_offset_seconds/1
]).

%% System functions
-export([getenv/1]).
Copy link
Member

Choose a reason for hiding this comment

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

Environment variables are often used to store secrets, I would be very cautious to have a function that exposes them through the rule engine. Especially if its input may somehow by templated from the contents on MQTT message.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I agree with you, but this is a customer requirement. They use environment variables to deploy EMQX, and they want to be able to pull the kafka topic from the environment variable.
In the first plan, we created a new app that allowed customization of predefined variables in placeholders. However, after review, it was considered too complex.

Copy link
Member

@ieQu1 ieQu1 Jul 24, 2024

Choose a reason for hiding this comment

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

Perhaps this function should be disabled by default, with possibility to enable it via feature flag?
Otherwise one customer's demands can create vulnerability for all EMQX users...

Copy link
Member

Choose a reason for hiding this comment

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

sorry, missed this point.
will add a forced prefix instead.

Copy link
Member

Choose a reason for hiding this comment

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

@zmstone
Copy link
Member

zmstone commented Jul 24, 2024

please send a PR to emqx-docs to document this new func.
https://docs.emqx.com/en/emqx/latest/configuration/configuration.html#pre-defined-functions

Copy link
Member

@zmstone zmstone left a comment

Choose a reason for hiding this comment

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

need a namespace for the PT

apps/emqx_utils/src/emqx_variform_bif.erl Show resolved Hide resolved
apps/emqx_utils/src/emqx_variform_bif.erl Show resolved Hide resolved
@lafirest lafirest merged commit 1925ed2 into emqx:release-57 Jul 25, 2024
180 checks passed
@lafirest lafirest deleted the feat/env_func branch July 25, 2024 14:46
@emqxqa
Copy link

emqxqa commented Jul 30, 2024

TestExecution

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.

4 participants