-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Implement Variable API #242
Conversation
This seems like a solid solution to a lot of the problems we're wrestling with. Can you add an example .yml file showing how to use this, if only as a comment here? Personally I find |
Codecov Report
@@ Coverage Diff @@
## master #242 +/- ##
==========================================
+ Coverage 61.84% 63.59% +1.74%
==========================================
Files 52 56 +4
Lines 4739 5021 +282
==========================================
+ Hits 2931 3193 +262
- Misses 1808 1828 +20
Continue to review full report at Codecov.
|
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
It is frequently required to declare variables that will be reused throughout the dashboard specification. Currently we have support for declaring special variables using yaml templating syntax, e.g. to resolve environment variables we can use the jinja2 syntax
{{ env('some_env_var') }}
and this is resolved when the dashboard is loaded. However frequently we have the need to dynamically resolve variables, tie variables to widgets, or specifically in the context of theLumen Builder
to wait to resolve the variables until the final dashboard. To empower users to do these things in a very explicit way we add aVariable
hierarchy to the existing hierarchy of components (i.e. in addition toFilter
,Source
,Transform
andView
).Just like all other components users will be able to declare their own
Variable
types, e.g. to load some secret from a custom variable storage system. Some additional design considerations:The
Variable
definitions are the first thing that are resolved ensuring that all other components can make use of the variables. OneVariable
may even reference anotherVariable
in its definition as long as they are declared in the appropriate order.To use a variable anywhere in the yaml specification you use the
$
syntax already used by sources, e.g. to reference aVariable
namedusername
you would specify$variable.username
(alternative suggestions welcome)A
Variable
can be dynamic just like any other component, therefore it may implement apanel
attribute or property that returns a Panel component which will be rendered in the sidebar.A
Variable
can declare whether it is to be inlined/resolved or not. This is a declaration to the Lumen Builder whether it should resolve the variable and replace it with aConstantVariable
or whether it should simply be inherited as is.