Can't switch between mojo specs easily
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mojo: Continuous Delivery for Juju |
Confirmed
|
Low
|
Unassigned |
Bug Description
A developer should be able to pull (or switch to) a spec branch, and run one command, to run a spec.
Steps to repro:
1) Pull a mojo spec branch (or switch to a different spec) - mojo-u1-project-A
2) `mojo run`
Expected result: mojo runs the main manifest for mojo-u1-project-A
Actual result: A bunch of env vars (at least MOJO_STAGE=
3) debug/develop, then destroy juju env and rebootstrap
4) cd/switch to a different spec - mojo-u1-project-B
5) `mojo run`
Expected result: mojo runs the main manifest for mojo-u1-project-B
Actual result: A bunch of env vars need to be redefined / exported, and can result in contamination from mojo-u1-project-A
This isn't an issue for deployments/IS, as a deployment is setup once, env exported, and things don't change (at least, you don't switch to a different spec in that env). But for a typical (?) developer workflow, it isn't great.
In the past, we've worked around this by using a Makefile to define the required variables without needing to export them to the session, so we can switch branches and just run `make run`. But this has then leaked into some deployment commands (ie. currently `make manifests/
description: | updated |
AFAICT, the best way forward is simply for us to continue to use a Makefile for development, but move all the env vars out into a (stage specific) envrc in the spec that can alternately be sourced. In development, our Makefile will just ensure it's sourced before running equivalent mojo commands, while on staging / production (or in development if we choose to test), we can manually source the env file and run with mojo directly (the same commands).
FWIW, I've been investigating a way for us devs to be able to use mojo directly (without a Makefile) - with mojo automatically sourcing the relevant env file, but afaict, it's pretty useless, as for mojo to be able to *find* the correct env file in the first place, it still needs MOJO_STAGE= ols/mojo- your-spec- name/stage, and MOJO_WORKSPACE and MOJO_SPEC.. Even if we hack around to derive MOJO_STAGE from the CWD iff MOJO_STAGE isn't defined, we'd still need to either define workspace and spec, or load an env from the spec in the CWD (both of which aren't great options).