Skip to content

Commit

Permalink
Change command to run_all to dozer run (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse-Bakker committed Aug 29, 2023
1 parent f078419 commit c9462bf
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 88 deletions.
3 changes: 2 additions & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ COPY target/release/dozer /usr/local/bin/
ENV PATH="$PATH:/usr/local/protoc/bin"

WORKDIR /usr/dozer
CMD ["dozer"]
ENTRYPOINT ["dozer"]
CMD ["run"]
4 changes: 2 additions & 2 deletions dozer-cli/src/cli/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct Cli {
#[arg(global = true, long = "ignore-pipe")]
pub ignore_pipe: bool,
#[clap(subcommand)]
pub cmd: Option<Commands>,
pub cmd: Commands,
}

fn parse_config_override(
Expand Down Expand Up @@ -94,7 +94,7 @@ pub struct Build {
#[derive(Debug, Args)]
pub struct Run {
#[command(subcommand)]
pub command: RunCommands,
pub command: Option<RunCommands>,
}

#[derive(Debug, Subcommand)]
Expand Down
160 changes: 77 additions & 83 deletions dozer-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ fn run() -> Result<(), OrchestrationError> {
.map(|cloud| cloud.app_id.clone().unwrap_or(app_name));

// We always enable telemetry when running live.
let telemetry_config = if matches!(cli.cmd, Some(Commands::Live(_))) {
let telemetry_config = if matches!(cli.cmd, Commands::Live(_)) {
Some(TelemetryConfig {
trace: None,
metrics: Some(TelemetryMetricsConfig::Prometheus(())),
Expand All @@ -153,96 +153,90 @@ fn run() -> Result<(), OrchestrationError> {
.runtime
.block_on(async { Telemetry::new(app_id.as_deref(), telemetry_config) });

if let Some(cmd) = cli.cmd {
// run individual servers
match cmd {
Commands::Run(run) => match run.command {
RunCommands::Api => {
render_logo();

dozer.run_api(shutdown_receiver)
}
RunCommands::App => {
render_logo();

dozer.run_apps(shutdown_receiver, None)
}
},
Commands::Security(security) => match security.command {
SecurityCommands::GenerateToken => {
let token = dozer.generate_token()?;
info!("token: {:?} ", token);
Ok(())
}
},
Commands::Build(build) => {
let force = build.force.is_some();
// run individual servers
match cli.cmd {
Commands::Run(run) => match run.command {
Some(RunCommands::Api) => {
render_logo();

dozer.build(force, shutdown_receiver)
}
Commands::Connectors(ConnectorCommand { filter }) => {
dozer.runtime.block_on(list_sources(
dozer.runtime.clone(),
cli.config_paths,
cli.config_token,
cli.config_overrides,
cli.ignore_pipe,
filter,
))
dozer.run_api(shutdown_receiver)
}
Commands::Clean => dozer.clean(),
#[cfg(feature = "cloud")]
Commands::Cloud(cloud) => {
Some(RunCommands::App) => {
render_logo();

match cloud.command.clone() {
CloudCommands::Deploy(deploy) => dozer.deploy(cloud, deploy, cli.config_paths),
CloudCommands::Api(api) => dozer.api(cloud, api),
CloudCommands::Login {
organisation_slug,
profile_name,
client_id,
client_secret,
} => dozer.login(
cloud,
organisation_slug,
profile_name,
client_id,
client_secret,
),
CloudCommands::Secrets(command) => {
dozer.execute_secrets_command(cloud, command)
}
CloudCommands::Delete => dozer.delete(cloud),
CloudCommands::Status => dozer.status(cloud),
CloudCommands::Monitor => dozer.monitor(cloud),
CloudCommands::Logs(logs) => dozer.trace_logs(cloud, logs),
CloudCommands::Version(version) => dozer.version(cloud, version),
CloudCommands::List(list) => dozer.list(cloud, list),
CloudCommands::SetApp { app_id } => {
CloudAppContext::save_app_id(app_id.clone())?;
info!("Using \"{app_id}\" app");
Ok(())
}
}
}
Commands::Init => {
panic!("This should not happen as it is handled in parse_and_generate");
dozer.run_apps(shutdown_receiver, None)
}
Commands::Live(live_flags) => {
None => {
render_logo();
dozer.runtime.block_on(live::start_live_server(
&dozer.runtime,
shutdown_receiver,
live_flags,
))?;
dozer.run_all(shutdown_receiver)
}
},
Commands::Security(security) => match security.command {
SecurityCommands::GenerateToken => {
let token = dozer.generate_token()?;
info!("token: {:?} ", token);
Ok(())
}
}
} else {
render_logo();
},
Commands::Build(build) => {
let force = build.force.is_some();

dozer.run_all(shutdown_receiver)
dozer.build(force, shutdown_receiver)
}
Commands::Connectors(ConnectorCommand { filter }) => dozer.runtime.block_on(list_sources(
dozer.runtime.clone(),
cli.config_paths,
cli.config_token,
cli.config_overrides,
cli.ignore_pipe,
filter,
)),
Commands::Clean => dozer.clean(),
#[cfg(feature = "cloud")]
Commands::Cloud(cloud) => {
render_logo();

match cloud.command.clone() {
CloudCommands::Deploy(deploy) => dozer.deploy(cloud, deploy, cli.config_paths),
CloudCommands::Api(api) => dozer.api(cloud, api),
CloudCommands::Login {
organisation_slug,
profile_name,
client_id,
client_secret,
} => dozer.login(
cloud,
organisation_slug,
profile_name,
client_id,
client_secret,
),
CloudCommands::Secrets(command) => dozer.execute_secrets_command(cloud, command),
CloudCommands::Delete => dozer.delete(cloud),
CloudCommands::Status => dozer.status(cloud),
CloudCommands::Monitor => dozer.monitor(cloud),
CloudCommands::Logs(logs) => dozer.trace_logs(cloud, logs),
CloudCommands::Version(version) => dozer.version(cloud, version),
CloudCommands::List(list) => dozer.list(cloud, list),
CloudCommands::SetApp { app_id } => {
CloudAppContext::save_app_id(app_id.clone())?;
info!("Using \"{app_id}\" app");
Ok(())
}
}
}
Commands::Init => {
panic!("This should not happen as it is handled in parse_and_generate");
}
Commands::Live(live_flags) => {
render_logo();
dozer.runtime.block_on(live::start_live_server(
&dozer.runtime,
shutdown_receiver,
live_flags,
))?;
Ok(())
}
}
}

Expand All @@ -252,7 +246,7 @@ fn parse_and_generate() -> Result<Cli, OrchestrationError> {
dozer_tracing::init_telemetry_closure(None, None, || -> Result<Cli, OrchestrationError> {
let cli = Cli::parse();

if let Some(Commands::Init) = cli.cmd {
if let Commands::Init = cli.cmd {
Telemetry::new(None, None);
if let Err(e) = generate_config_repl() {
error!("{}", e);
Expand Down
2 changes: 1 addition & 1 deletion dozer-tests/src/e2e_tests/checker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn check_build_failure(
) {
{
let (mut command, _cleanups) = dozer_command();
command.args(["--ignore-pipe", "--config-path", dozer_config_path]);
command.args(["--ignore-pipe", "--config-path", dozer_config_path, "run"]);
assert_command_fails(command, message);
}
{
Expand Down
2 changes: 1 addition & 1 deletion dozer-tests/src/e2e_tests/runner/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Runner {
fn spawn_dozer_same_process(dozer_bin: &str, dozer_config_path: &str) -> Vec<Cleanup> {
let child = spawn_command(
dozer_bin,
&["--config-path", dozer_config_path, "--ignore-pipe"],
&["--config-path", dozer_config_path, "--ignore-pipe", "run"],
);
vec![Cleanup::KillProcess(child)]
}
Expand Down

0 comments on commit c9462bf

Please sign in to comment.