anton-rs / op-up

Composable OP Stack Orchestration
https://stack.anton.systems
MIT License
41 stars 2 forks source link

feat(bin): Down Subcommand #21

Open refcell opened 1 year ago

refcell commented 1 year ago

Description

As part of #17, this task is to introduce a new down subcommand to op-up that winds down the op-stack defined by the local stack.toml configuration file.

Since this is a destructive action, it should use inquire to prompt the user to confirm running the command.

The logic of winding down a stack based on the config should be abstracted into the Stage Manager orchestrator (doesn't exist yet). This allows the opup cli binary to build the stage manager from the config, and then be able to wind down the stack via a simple down() -> eyre::Result<()> call.

For example

StageManager::from(config).down()?;

The logic behind building a stage manager orchestrator from the stack config is so that it can handle finding existing running stack components based on the configuration. This separates concerns whereby the stack configuration solely handles component and stack configuration while the stage manager can handle orchestrating the stack stages/components.

Since the stage manager .down() call is very minimal, the down subcommand logic can be placed inside cli.rs alongside subcommand dispatching.

roninjin10 commented 1 year ago

I'll take this one if nobody else is on it

merklefruit commented 1 year ago

go for it ser!

merklefruit commented 1 year ago

This really comes handy for debugging the stages module which I'm working on, @roninjin10 did you have any luck with it yet?

The logic behind building a stage manager orchestrator from the stack config is so that it can handle finding existing running stack components based on the configuration.

All opup components are tagged with a com.docker.compose.project=op-up label, so for now a minimal version would just be to stop and remove all running docker containers with this label, regardless of the stack.toml file which we don't have just yet.

roninjin10 commented 1 year ago

Hey @merklefruit sorry for delay been super busy with 3 projects I'm working on. I plan on starting on this this weekend and contributing semi regularly starting tomorrow. I've read the rust book 3 times but have written very little so I may be slow even once I start though

merklefruit commented 1 year ago

No worries at all sir!