From 6afb3d81c4ddad0238df8ac345935aca35626d6c Mon Sep 17 00:00:00 2001 From: Techassi Date: Tue, 26 Sep 2023 13:34:31 +0200 Subject: [PATCH] Various small stacklet command output improvements --- extra/completions/_stackablectl | 3 ++- extra/completions/stackablectl.bash | 6 +++++- extra/completions/stackablectl.fish | 2 +- rust/stackablectl/src/cmds/stacklet.rs | 27 +++++++++++++------------- 4 files changed, 22 insertions(+), 16 deletions(-) diff --git a/extra/completions/_stackablectl b/extra/completions/_stackablectl index 0486a244..ed2d33e2 100644 --- a/extra/completions/_stackablectl +++ b/extra/completions/_stackablectl @@ -624,6 +624,7 @@ _arguments "${_arguments_options[@]}" \ case $line[1] in (credentials) _arguments "${_arguments_options[@]}" \ +'-n+[Namespace in the cluster used to deploy the products]:PRODUCT_NAMESPACE: ' \ '--product-namespace=[Namespace in the cluster used to deploy the products]:PRODUCT_NAMESPACE: ' \ '--product-ns=[Namespace in the cluster used to deploy the products]:PRODUCT_NAMESPACE: ' \ '-l+[Log level this application uses]:LOG_LEVEL: ' \ @@ -644,7 +645,7 @@ _arguments "${_arguments_options[@]}" \ '-V[Print version]' \ '--version[Print version]' \ ':product_name -- The name of the product, for example '\''superset'\'':' \ -'::stacklet_name -- The name of the stacklet, for example '\''superset'\''. Doesn'\''t need to be passed if the product and stacklet name are the same:' \ +':stacklet_name -- The name of the stacklet, for example '\''superset'\'':' \ && ret=0 ;; (list) diff --git a/extra/completions/stackablectl.bash b/extra/completions/stackablectl.bash index e4b1515c..ea10948a 100644 --- a/extra/completions/stackablectl.bash +++ b/extra/completions/stackablectl.bash @@ -3077,7 +3077,7 @@ _stackablectl() { return 0 ;; stackablectl__stacklet__credentials) - opts="-l -d -s -r -h -V --product-ns --product-namespace --log-level --no-cache --offline --demo-file --stack-file --release-file --helm-repo-stable --helm-repo-test --helm-repo-dev --help --version [STACKLET_NAME]" + opts="-n -l -d -s -r -h -V --product-ns --product-namespace --log-level --no-cache --offline --demo-file --stack-file --release-file --helm-repo-stable --helm-repo-test --helm-repo-dev --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3091,6 +3091,10 @@ _stackablectl() { COMPREPLY=($(compgen -f "${cur}")) return 0 ;; + -n) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; --log-level) COMPREPLY=($(compgen -f "${cur}")) return 0 diff --git a/extra/completions/stackablectl.fish b/extra/completions/stackablectl.fish index d11432f7..5f729792 100644 --- a/extra/completions/stackablectl.fish +++ b/extra/completions/stackablectl.fish @@ -257,7 +257,7 @@ complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and not __fis complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and not __fish_seen_subcommand_from credentials; and not __fish_seen_subcommand_from list; and not __fish_seen_subcommand_from help" -f -a "credentials" -d 'Display credentials for a stacklet' complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and not __fish_seen_subcommand_from credentials; and not __fish_seen_subcommand_from list; and not __fish_seen_subcommand_from help" -f -a "list" -d 'List deployed stacklets' complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and not __fish_seen_subcommand_from credentials; and not __fish_seen_subcommand_from list; and not __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' -complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and __fish_seen_subcommand_from credentials" -l product-namespace -l product-ns -d 'Namespace in the cluster used to deploy the products' -r +complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and __fish_seen_subcommand_from credentials" -s n -l product-namespace -l product-ns -d 'Namespace in the cluster used to deploy the products' -r complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and __fish_seen_subcommand_from credentials" -s l -l log-level -d 'Log level this application uses' -r complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and __fish_seen_subcommand_from credentials" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F complete -c stackablectl -n "__fish_seen_subcommand_from stacklet; and __fish_seen_subcommand_from credentials" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F diff --git a/rust/stackablectl/src/cmds/stacklet.rs b/rust/stackablectl/src/cmds/stacklet.rs index 64ad2eaa..75e41062 100644 --- a/rust/stackablectl/src/cmds/stacklet.rs +++ b/rust/stackablectl/src/cmds/stacklet.rs @@ -19,6 +19,8 @@ use crate::{ utils::use_colored_output, }; +const CREDENTIALS_HINT: &str = "Use \"stackablectl stacklet credentials [OPTIONS] \" to display credentials for deployed stacklets."; + #[derive(Debug, Args)] pub struct StackletArgs { #[command(subcommand)] @@ -41,13 +43,13 @@ pub struct StackletCredentialsArgs { /// The name of the product, for example 'superset'. product_name: String, - /// The name of the stacklet, for example 'superset'. Doesn't need to be passed if - /// the product and stacklet name are the same. - stacklet_name: Option, + /// The name of the stacklet, for example 'superset'. + stacklet_name: String, /// Namespace in the cluster used to deploy the products. #[arg( long, + short = 'n', global = true, default_value = DEFAULT_PRODUCT_NAMESPACE, visible_aliases(["product-ns"]), @@ -173,7 +175,7 @@ async fn list_cmd(args: &StackletListArgs, common_args: &Cli) -> Result Result Result { info!("Displaying stacklet credentials"); - let stacklet_name = args - .stacklet_name - .clone() - .unwrap_or(args.product_name.clone()); - - match get_credentials_for_product(&args.product_namespace, &stacklet_name, &args.product_name) - .await - .context(StackletCredentialsSnafu)? + match get_credentials_for_product( + &args.product_namespace, + &args.stacklet_name, + &args.product_name, + ) + .await + .context(StackletCredentialsSnafu)? { Some(credentials) => { let mut table = Table::new(); @@ -210,7 +211,7 @@ async fn credentials_cmd(args: &StackletCredentialsArgs) -> Result