Allow defaults to be specified, or env not to be set, if vault or slot not found with op run
I'm using op run combined with a .env file to load our development configuration, but we have quite a bit of optional configuration. Some devs may need part of the config, other devs might need other parts. In order to make this simple, it would be nice if when using the op:// in an .env file with op run you could tell the command to ignore missing vaults or slots and just not set those environment variables, maybe printing a warning? Would be nice to do this reference by reference in the file so some could be required and other config optional, but a global flag on the op run command would be better than nothing here too. Bonus points for being able to specify a default value other than empty/not set for each environment variable reference in the .env file.
Using CLI version 2.6.2 and didn't see a way to do this, but maybe I'm missing something? Right now I just get could not resolve item UUID
if I have a slot that isn't in my vault
1Password Version: Not Provided
Extension Version: Not Provided
OS Version: Not Provided
Browser:_ Not Provided
Comments
-
I suppose the same would apply to cases where the slot existed but some field didn't
0 -
Thanks for the comment, but not sure this helps, unless I'm misunderstanding something.
If I have a line in my .env file like this:
DB_USERNAME="op://${OP_VAULT:-dev}/db/username"
how would I make it so the DB_USERNAME was set to "jonb1" (for instance) if the vault doesn't exist?In this case I get
[ERROR] 2023/01/02 19:32:10 could not resolve item UUID for item db
Something like this:
DB_USER_NAME="${op://dev/db/username:-jonb1}"
givesexpected character ':'
andop://dev/db/username
isn't really a VAR_NAME anyway.It's not that I want a default value for an variable, but a default value if the resolution of the vault/slot/attribute doesn't work for some reason.
0