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

getdozer / dozer / 5829357348

pending completion
5829357348

Pull #1839

github

aaryaattrey
typo
Pull Request #1839: load config from stdin

37 of 37 new or added lines in 4 files covered. (100.0%)

45551 of 59108 relevant lines covered (77.06%)

39686.65 hits per line

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

69.39
/dozer-cli/src/cli/types.rs
1
use clap::{Args, Parser, Subcommand};
2

3
use super::helper::{DESCRIPTION, LOGO};
4

5
#[cfg(feature = "cloud")]
6
use crate::cli::cloud::Cloud;
7
use dozer_types::constants::DEFAULT_CONFIG_PATH_PATTERNS;
8

9
#[derive(Parser, Debug)]
×
10
#[command(author, version, name = "dozer")]
11
#[command(
12
    about = format!("{} \n {}", LOGO, DESCRIPTION),
13
    long_about = None,
14
)]
15
pub struct Cli {
16
    #[arg(
17
        global = true,
18
        short = 'c',
19
        long = "config-path",
20
        default_values = DEFAULT_CONFIG_PATH_PATTERNS
21
    )]
22
    pub config_paths: Vec<String>,
×
23
    #[arg(global = true, long, hide = true)]
24
    pub config_token: Option<String>,
25
    #[arg(global = true, long, value_parser(parse_config_override))]
26
    pub config_overrides: Vec<(String, serde_json::Value)>,
×
27

28
    #[arg(global = true, long = "ignore-pipe")]
29
    pub ignore_pipe: bool,
×
30
    #[clap(subcommand)]
31
    pub cmd: Option<Commands>,
32
}
×
33

×
34
fn parse_config_override(
3✔
35
    arg: &str,
3✔
36
) -> Result<(String, serde_json::Value), Box<dyn std::error::Error + Send + Sync + 'static>> {
3✔
37
    let mut split = arg.split('=');
3✔
38
    let pointer = split.next().ok_or("missing json pointer")?;
3✔
39
    let value = split.next().ok_or("missing json value")?;
3✔
40
    Ok((pointer.to_string(), serde_json::from_str(value)?))
3✔
41
}
3✔
42

43
#[derive(Debug, Subcommand)]
×
44
pub enum Commands {
45
    #[command(
46
        about = "Initialize an app using a template",
47
        long_about = "Initialize dozer app workspace. It will generate dozer configuration and \
48
            folder structure."
49
    )]
50
    Init,
51
    #[command(
52
        about = "Clean home directory",
53
        long_about = "Clean home directory. It removes all data, schemas and other files in app \
54
            directory"
55
    )]
56
    Clean,
57
    #[command(
58
        about = "Initialize and lock schema definitions. Once initialized, schemas cannot \
59
            be changed"
60
    )]
61
    Build(Build),
62
    #[command(about = "Run App or Api Server")]
63
    Run(Run),
64
    #[command(
65
        about = "Show Sources",
66
        long_about = "Show available tables schemas in external sources"
67
    )]
68
    Connectors(ConnectorCommand),
69
    #[command(about = "Change security settings")]
70
    Security(Security),
71
    #[cfg(feature = "cloud")]
72
    #[command(about = "Deploy cloud applications")]
73
    Cloud(Cloud),
74
}
75

76
#[derive(Debug, Args)]
×
77
#[command(args_conflicts_with_subcommands = true)]
78
pub struct Build {
79
    #[arg(short = 'f')]
80
    pub force: Option<Option<String>>,
81
}
82

83
#[derive(Debug, Args)]
×
84
pub struct Run {
85
    #[command(subcommand)]
86
    pub command: RunCommands,
87
}
88

89
#[derive(Debug, Subcommand)]
×
90
pub enum RunCommands {
91
    #[command(
92
        about = "Run app instance",
93
        long_about = "Run app instance. App instance is responsible for ingesting data and \
94
            passing it through pipeline"
95
    )]
96
    App,
97
    #[command(
98
        about = "Run api instance",
99
        long_about = "Run api instance. Api instance runs server which creates access to \
100
            API endpoints through REST and GRPC (depends on configuration)"
101
    )]
102
    Api,
103
}
104

105
#[derive(Debug, Args)]
×
106
pub struct Security {
107
    #[command(subcommand)]
108
    pub command: SecurityCommands,
109
}
110

111
#[derive(Debug, Subcommand)]
×
112
pub enum SecurityCommands {
113
    #[command(
114
        author,
115
        version,
116
        about = "Generate master token",
117
        long_about = "Master Token can be used to create other run time tokens \
118
        that encapsulate different permissions."
119
    )]
120
    GenerateToken,
121
}
122

123
#[derive(Debug, Args)]
×
124
#[command(args_conflicts_with_subcommands = true)]
125
pub struct Deploy {
126
    pub target_url: String,
×
127
    #[arg(short = 'u')]
128
    pub username: Option<String>,
129
    #[arg(short = 'p')]
130
    pub password: Option<String>,
131
}
132

133
#[derive(Debug, Args)]
×
134
pub struct ConnectorCommand {
135
    #[arg(short = 'f')]
136
    pub filter: Option<String>,
137
}
138

139
#[cfg(test)]
140
mod tests {
141
    #[test]
1✔
142
    fn test_parse_config_override_string() {
1✔
143
        let arg = "/app=\"abc\"";
1✔
144
        let result = super::parse_config_override(arg).unwrap();
1✔
145
        assert_eq!(result.0, "/app");
1✔
146
        assert_eq!(result.1, serde_json::Value::String("abc".to_string()));
1✔
147
    }
1✔
148

149
    #[test]
1✔
150
    fn test_parse_config_override_number() {
1✔
151
        let arg = "/app=123";
1✔
152
        let result = super::parse_config_override(arg).unwrap();
1✔
153
        assert_eq!(result.0, "/app");
1✔
154
        assert_eq!(result.1, serde_json::Value::Number(123.into()));
1✔
155
    }
1✔
156

157
    #[test]
1✔
158
    fn test_parse_config_override_object() {
1✔
159
        let arg = "/app={\"a\": 1}";
1✔
160
        let result = super::parse_config_override(arg).unwrap();
1✔
161
        assert_eq!(result.0, "/app");
1✔
162
        assert_eq!(
1✔
163
            result.1,
1✔
164
            serde_json::json!({
1✔
165
                "a": 1
1✔
166
            })
1✔
167
        );
1✔
168
    }
1✔
169
}
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