Rofl public vars#705
Conversation
✅ Deploy Preview for oasisprotocol-cli canceled.
|
c08fc30 to
f39a94f
Compare
martintomazic
left a comment
There was a problem hiding this comment.
Followed the style and organisation 1:1 with oasis rofl secrets.
| prevConfig := *cliConfig.Global() | ||
| cliConfig.ResetDefaults() | ||
| t.Cleanup(func() { | ||
| *cliConfig.Global() = prevConfig | ||
| }) |
There was a problem hiding this comment.
NIT: existing global config makes things hard to test cleanly :((
f39a94f to
9dc9218
Compare
matevz
left a comment
There was a problem hiding this comment.
If you define a public var with the same name as the existing secret, Oasis CLI should fail.
9dc9218 to
e3c9919
Compare
Private variable name (if Note there is similar issue with secrets definitions overlapping between each other:
meaning cli should probably not allow setting |
matevz
left a comment
There was a problem hiding this comment.
Please also mention special env. metadata fields behavior in the ROFL manifest specs https://github.com/oasisprotocol/oasis-sdk/blob/main/docs/rofl/features/manifest.md
| // publicVarImportCmd bulk-imports public variables from a .env file (key=value with # comments). | ||
| // Supports '-' to read from stdin. Existing public variables are replaced only with --force. | ||
| publicVarImportCmd = &cobra.Command{ | ||
| Use: "import <dot-env-file>|-", |
There was a problem hiding this comment.
It would be useful to have another rofl public-var set-env-file <dot-env-file> command which references the given .env filename with the current deployment.
Then, ROFL manifest file is updated with something like
deployments:
testnet:
metadata_env_file: .env.testnetAnd when you run oasis rofl update, the content of this env file is read on-the-fly and populates env. fields in metadata. This way we never get inconsistency between .env files and the manifest.
There was a problem hiding this comment.
I assume rofl github actions will have access to env files as they run in the repo checkout or?
My concerns are:
- What happens if you have variables defined both as part of the manifest metadata and inside manifest referenced env file? What happens if they overlap? Do we want precedence complexity?
- Currently manifest acts as a source of truth for other commands, so every time
manifest.GetMetadata()is called we will have to parse it add hoc into the same structure that will differ in memory to what is persisted? What happens when we later write the manifest back? Or we introduce overlay concept, that other commands need to learn about (complexity). - Now before running oasis rofl update you will have two sources of truth that you need to mentally merge.
- Not all metadata is meant to act as public config to docker containers (only .env prefix).
Locally forgetting to run oasis rofl public-var import is same as forgetting to write oasis rofl update?
For the CI I would prefer to run a simple validation step, e.g. running oasis rofl public-var import .env.testnet --force should produce an empty diff for the CI to pass. This way you have sync guarantee without adding further complexity to the cli/manifest parsing?
There was a problem hiding this comment.
Even better inside make/just file we add a command for sanity/sync validation, which can then be called locally (if deploying from local machine) or inside CI.
e3c9919 to
813ada8
Compare
You could also gather these variables under the same key, e.g. |
Part of oasisprotocol/oasis-sdk#2248.
Used public var instead of env to make sure people don't accidentally set secrets here.
Tested it with https://github.com/oasisprotocol/Honoroll/pull/440.