[21] Conditionnal injection (jinja?)
Hi CLI-team,
First of all, thanks for the CLI. v1 already changed our way of working at Cortexia.
Thanks for the v2 which allows us to already clean and consolidate our scripts by simply upgrading to v2.
And thanks for allowing us to test and share with you ;)
Secondly, I have a question / suggestion :)
How about allowing some "Jinja-ness" in the injection templating process ? Like in https://jinja.palletsprojects.com/en/3.0.x/
That would be of course a lot "in" for one shot.
But a first step that would cover my use case would be to "only" get conditional directives.
My use case is the following: I generate .env files from the values in some 1password items (similar example than the one in the doc)
DB_HOST={{ op://app/db/host }}
DB_PASSWORD={{ op://app-prod/db/password }}
...
In my use case, I also have default values in my application, e.g. db_host=xxx
With my current usage of v1, I do the following checks in my scripts when I generate my .env file (pseudo-code)
if 'db_host' in one_password_item.fields:
print("DB_HOST={one_password_item.fields.db_host}", ".env")
print("DB_PASSWORD={{ one_password_item.fields.db_password }}", ".env")
...
The output can be
DB_HOST=xxx
DB_PASSWORD=password
...
or, when using default values from the app (not having any value defined in the 1password item):
DB_PASSWORD=password
...
what I would not like to have is
DB_HOST=
DB_PASSWORD=password
...
because with the empty declaration above, the natural behavior of my app would be to override the default db_host=xxx with an empty value from the .env file
Hence the suggestion for conditional injection, or better, jinja-ness ;)
Take care,
Emmanuel
1Password Version: 7.9.2
Extension Version: 2.0.0-beta.6
OS Version: macOS 11.6
