Open nixwiz opened 4 years ago
Love this! Great idea.
Required by https://github.com/sensu/sensu-go/issues/3619
Feature spec:
Validate()
function of the asset)@palourde to check with @nixwiz if we've already addressed the user stories with the PR for https://github.com/sensu/sensu-go/issues/3662.
@nixwiz So I'm wondering if this issue is still relevant, now that resources that consume assets can retrieve the path of these assets via a token substitution and/or an environment variable. WDYT?
For reference: https://github.com/sensu/sensu-docs/issues/2483
Unless I can do something like this:
"type": "Asset",
"api_version": "core/v2",
"metadata": {
"name": "perl-runtime",
"namespace": "default",
"labels": {
"origin": "bonsai"
}
},
"spec": {
"env_vars": {
"PERL5LIB": "{{assetPath}}/lib"
},
Then the changes implemented don't exactly address the use case I specified. If I want to surface a custom env variable based on the asset path, I either need to write a wrapper script around my asset or otherwise incorporate its retrieval in my asset.
Update on this.
So i'm prototyping a new python runtime asset to aid with users who want to use python based checks
I'm running into a similar need. To make this work I need to manipulate the PYTHONPATH variable and extend it with additional paths relative to each asset's install directory. The workaround right now is to write wrapper scripts for each python check command. Being able to do the envvar manipulation as part of the asset definition would simplify things greatly.
User wants to use in-house python check that needs to use python module not included in python runtime
sensu-python-runtime -> base runtime for python python-inhouse-check -> in-house asset with python check and needed python modules
lib/
using pip --target
to install missing python moduleslibexec/
which is not in executable pathbin/
for each python check script, wrapper extends PYTHONPATH envvar to include assets lib/
If we had a way to extend PYTHONPATH as part of asset definition, python assets wouldn't need to do the complicated wrapper in bin/
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
To allow the possibility of other scripting runtimes or functionality it would be helpful to surface additional/custom environment variables for downloaded assets.
Feature Suggestion
There should be a way to have an asset create (or append to) custom environment variables to be surfaced when that asset is run. This could be part of the asset definition itself.
Possible Implementation
Adding env_vars to the asset definition, where each key is the env variable and the value is a path relative to the PATH_TO_ASSET to populate into the variable.
Something along the lines of the following where in this case the PERL5LIB environment variable will include the appropriate PATH_TO_ASSET/lib directory when executed (e.g. PERL5LIB=/var/cache/sensu/sensu-agent/sha512sumvalue/lib).
Context