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

chezmoi-sh / kubevault / 10326604998

09 Aug 2024 10:39PM UTC coverage: 17.603% (+6.7%) from 10.88%
10326604998

Pull #21

github

web-flow
Merge 00e2c851d into 92bb21f26
Pull Request #21: :white_check_mark:(core): Add more test to test all CLI commands

513 of 7101 branches covered (7.22%)

Branch coverage included in aggregate %.

506 of 530 new or added lines in 6 files covered. (95.47%)

417 existing lines in 2 files now uncovered.

1204 of 2653 relevant lines covered (45.38%)

314.55 hits per line

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

21.05
/src/cli.rs
1
/*
2
 * Copyright (C) 2024 Alexandre Nicolaie (xunleii@users.noreply.github.com)
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *         http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 * ----------------------------------------------------------------------------
16
**/
17

18
use anyhow::Result;
19
use clap::{CommandFactory, Parser, Subcommand};
20
use clap_complete::{generate, Shell};
21

22
mod can_read_secret;
23
mod external_secret_store;
24
mod generate_manifests;
25
mod new_vault_directory;
26

27
/// Access control directory name
28
pub const ACCESS_CONTROL_DIRECTORY: &str = "access_control";
29
/// Key-value store directory name
30
pub const KVSTORE_DIRECTORY: &str = "kvstore";
31

32
#[derive(Debug, Parser)]
18✔
33
#[command(
34
    name = "kubevault",
35
    about = "kubevault transforms a Kubernetes cluster into a secret management system.",
36
    long_about = "kubevault is a tool that transforms a Kubernetes cluster into a secret management system by relying on resources like Secrets and RBAC provided by Kubernetes.",
37
    author,
38
    version
39
)]
40
pub struct Opts {
41
    #[command(subcommand)]
4!
42
    command: Option<KubeVaultCommands>,
×
43
}
44

45
#[derive(Debug, Subcommand)]
41!
46
pub enum KubeVaultCommands {
47
    Generate(generate_manifests::Command),
5✔
48
    New(new_vault_directory::Command),
5✔
49
    CanRead(can_read_secret::Command),
5✔
50
    ExternalSecretStore(external_secret_store::Command),
5✔
51

52
    #[command(about = "Generate shell completion scripts")]
53
    Completion {
54
        #[arg(
10✔
55
            help = "The shell to generate the completion script for",
56
            value_parser = clap::value_parser!(Shell),
15✔
57
        )]
58
        shell: Shell,
×
59
    },
60
}
61

62
impl Opts {
63
    pub fn exec(&self) -> Result<()> {
4✔
64
        match &self.command {
4!
65
            Some(KubeVaultCommands::Generate(cmd)) => cmd.run(std::io::stdout())?,
3!
66
            Some(KubeVaultCommands::New(cmd)) => cmd.run()?,
×
NEW
67
            Some(KubeVaultCommands::CanRead(cmd)) => cmd.run(std::io::stdout())?,
×
68
            Some(KubeVaultCommands::ExternalSecretStore(cmd)) => cmd.run(std::io::stdout())?,
4!
69

70
            Some(KubeVaultCommands::Completion { shell }) => match shell {
×
71
                Shell::Bash | Shell::Zsh | Shell::Fish | Shell::Elvish | Shell::PowerShell => {
72
                    let mut cmd = Opts::command();
×
73
                    generate(*shell, &mut cmd, "kubevault", &mut std::io::stdout());
×
74
                }
×
75
                _ => {
76
                    anyhow::bail!("Unsupported shell {:?}", shell);
77
                }
78
            },
79
            None => {
80
                anyhow::bail!("No subcommand provided. Use --help for more information.");
1✔
81
            }
82
        }
83

84
        Ok(())
3✔
85
    }
4✔
86
}
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

© 2026 Coveralls, Inc