• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

getdozer / dozer / 4020902227

pending completion
4020902227

Pull #743

github

GitHub
Merge 57279c6b6 into a12da35a5
Pull Request #743: Chore clippy fix

165 of 165 new or added lines in 60 files covered. (100.0%)

23638 of 35485 relevant lines covered (66.61%)

38417.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/dozer-admin/src/cli/cli_process.rs
1
use std::{fs::File, path::Path, process::Command};
2

3
use super::{
4
    utils::{init_db_with_config, init_internal_pipeline_client, kill_process_at, reset_db},
5
    AdminCliConfig,
6
};
7
use crate::server;
8
use dozer_orchestrator::internal_grpc::GetAppConfigRequest;
9
use dozer_types::{models::app_config::Config, serde_yaml};
10

11
pub struct CliProcess {
12
    pub config: AdminCliConfig,
13
}
14
impl CliProcess {
15
    fn get_internal_config(&mut self) {
×
16
        // priority read config from home_dir
×
17
        let home_dir = self.config.home_dir.to_owned();
×
18
        let path = Path::new(&home_dir).join("internal_config/config.yaml");
×
19
        if path.exists() {
×
20
            let f = File::open(path).expect("Couldn't open file");
×
21
            let reader_result = serde_yaml::from_reader::<File, serde_yaml::Value>(f);
×
22
            if let Ok(config) = reader_result {
×
23
                let pipeline_internal_value = &config["pipeline_internal"];
×
24
                let pipeline_internal =
×
25
                    serde_yaml::from_value(pipeline_internal_value.to_owned()).unwrap_or_default();
×
26
                let api_internal_value = &config["api_internal"];
×
27
                let api_internal =
×
28
                    serde_yaml::from_value(api_internal_value.to_owned()).unwrap_or_default();
×
29
                self.config.api_internal = api_internal;
×
30
                self.config.pipeline_internal = pipeline_internal;
×
31
            }
×
32
        }
×
33
    }
×
34

35
    fn start_ui_server(&self) {
×
36
        let ui_path = Path::new(&self.config.ui_path);
×
37
        if ui_path.exists() {
×
38
            // execute command serve
×
39
            Command::new("serve")
×
40
                .arg("-s")
×
41
                .arg(&self.config.ui_path)
×
42
                .spawn()
×
43
                .expect("Start ui server failed");
×
44
        }
×
45
    }
×
46
    pub async fn start(&mut self) -> Result<(), Box<dyn std::error::Error>> {
×
47
        self.get_internal_config();
×
48
        let internal_pipeline_config = self.config.to_owned().pipeline_internal;
×
49
        let client_connect_result = init_internal_pipeline_client(internal_pipeline_config).await;
×
50
        let mut dozer_config: Config = Config::default();
×
51
        if let Ok(mut client) = client_connect_result {
×
52
            let response = client.get_config(GetAppConfigRequest {}).await?;
×
53
            let config = response.into_inner();
×
54
            dozer_config = config.data.unwrap();
×
55
        }
×
56
        reset_db();
×
57
        init_db_with_config(dozer_config);
×
58
        kill_process_at(3000);
×
59
        kill_process_at(self.config.to_owned().port as u16);
×
60

×
61
        // start ui
×
62
        self.start_ui_server();
×
63
        server::start_admin_server(self.config.to_owned()).await?;
×
64
        Ok(())
×
65
    }
×
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc