diff --git a/Cargo.lock b/Cargo.lock index 5d8e3459..d7e66122 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -891,6 +891,18 @@ version = "1.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "abd57806937c9cc163efc8ea3910e00a62e2aeb0b8119f1793a978088f8f6b04" +[[package]] +name = "dialoguer" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25f104b501bf2364e78d0d3974cbc774f738f5865306ed128e1e0d7499c0ad96" +dependencies = [ + "console", + "shell-words", + "tempfile", + "zeroize", +] + [[package]] name = "digest" version = "0.10.7" @@ -3409,6 +3421,12 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "shell-words" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77" + [[package]] name = "shlex" version = "1.3.0" @@ -3546,6 +3564,7 @@ version = "0.0.0-dev" dependencies = [ "bcrypt", "clap", + "either", "futures", "helm-sys", "indexmap", @@ -3730,6 +3749,7 @@ dependencies = [ "clap_complete", "clap_complete_nushell", "comfy-table", + "dialoguer", "directories", "dotenvy", "futures", @@ -3832,6 +3852,19 @@ dependencies = [ "syn 2.0.117", ] +[[package]] +name = "tempfile" +version = "3.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16" +dependencies = [ + "fastrand", + "getrandom 0.3.4", + "once_cell", + "rustix", + "windows-sys 0.61.2", +] + [[package]] name = "tera" version = "1.20.1" diff --git a/Cargo.nix b/Cargo.nix index d5a81ad2..22030b86 100644 --- a/Cargo.nix +++ b/Cargo.nix @@ -2838,6 +2838,42 @@ rec { }; resolvedDefaultFeatures = [ "alloc" "default" ]; }; + "dialoguer" = rec { + crateName = "dialoguer"; + version = "0.12.0"; + edition = "2021"; + sha256 = "15mdq2cp838yiq9fs1jkhvskixvlqz5p8f8dipkn88xz06sh9w95"; + dependencies = [ + { + name = "console"; + packageId = "console"; + } + { + name = "shell-words"; + packageId = "shell-words"; + } + { + name = "tempfile"; + packageId = "tempfile"; + optional = true; + } + { + name = "zeroize"; + packageId = "zeroize"; + optional = true; + } + ]; + features = { + "default" = [ "editor" "password" ]; + "editor" = [ "tempfile" ]; + "fuzzy-matcher" = [ "dep:fuzzy-matcher" ]; + "fuzzy-select" = [ "fuzzy-matcher" ]; + "password" = [ "zeroize" ]; + "tempfile" = [ "dep:tempfile" ]; + "zeroize" = [ "dep:zeroize" ]; + }; + resolvedDefaultFeatures = [ "default" "editor" "password" "tempfile" "zeroize" ]; + }; "digest" = rec { crateName = "digest"; version = "0.10.7"; @@ -3382,7 +3418,7 @@ rec { "js" = [ "std" "getrandom" ]; "std" = [ "alloc" ]; }; - resolvedDefaultFeatures = [ "alloc" "std" ]; + resolvedDefaultFeatures = [ "alloc" "default" "std" ]; }; "find-msvc-tools" = rec { crateName = "find-msvc-tools"; @@ -10238,7 +10274,7 @@ rec { "thread" = [ "linux-raw-sys/prctl" ]; "use-libc" = [ "libc_errno" "libc" ]; }; - resolvedDefaultFeatures = [ "alloc" "std" "stdio" "termios" ]; + resolvedDefaultFeatures = [ "alloc" "default" "fs" "std" "stdio" "termios" ]; }; "rustls" = rec { crateName = "rustls"; @@ -11268,6 +11304,20 @@ rec { "loom" = [ "dep:loom" ]; }; }; + "shell-words" = rec { + crateName = "shell-words"; + version = "1.1.1"; + edition = "2015"; + sha256 = "0xzd5p53xl0ndnk63r0by52rhdrh6pd37szfxszkg73zb6ffcvyw"; + libName = "shell_words"; + authors = [ + "Tomasz Miąsko " + ]; + features = { + "default" = [ "std" ]; + }; + resolvedDefaultFeatures = [ "default" "std" ]; + }; "shlex" = rec { crateName = "shlex"; version = "1.3.0"; @@ -11657,6 +11707,10 @@ rec { packageId = "clap"; features = [ "derive" "env" ]; } + { + name = "either"; + packageId = "either"; + } { name = "futures"; packageId = "futures"; @@ -12423,6 +12477,10 @@ rec { packageId = "comfy-table"; features = [ "custom_styling" ]; } + { + name = "dialoguer"; + packageId = "dialoguer"; + } { name = "directories"; packageId = "directories"; @@ -12741,6 +12799,54 @@ rec { }; resolvedDefaultFeatures = [ "default" "proc-macro" ]; }; + "tempfile" = rec { + crateName = "tempfile"; + version = "3.23.0"; + edition = "2021"; + sha256 = "05igl2gml6z6i2va1bv49f9f1wb3f752c2i63lvlb9s2vxxwfc9d"; + authors = [ + "Steven Allen " + "The Rust Project Developers" + "Ashley Mannix " + "Jason White " + ]; + dependencies = [ + { + name = "fastrand"; + packageId = "fastrand"; + } + { + name = "getrandom"; + packageId = "getrandom 0.3.4"; + optional = true; + usesDefaultFeatures = false; + target = { target, features }: ((target."unix" or false) || (target."windows" or false) || ("wasi" == target."os" or null)); + } + { + name = "once_cell"; + packageId = "once_cell"; + usesDefaultFeatures = false; + features = [ "std" ]; + } + { + name = "rustix"; + packageId = "rustix"; + target = { target, features }: ((target."unix" or false) || ("wasi" == target."os" or null)); + features = [ "fs" ]; + } + { + name = "windows-sys"; + packageId = "windows-sys 0.61.2"; + target = { target, features }: (target."windows" or false); + features = [ "Win32_Storage_FileSystem" "Win32_Foundation" ]; + } + ]; + features = { + "default" = [ "getrandom" ]; + "getrandom" = [ "dep:getrandom" ]; + }; + resolvedDefaultFeatures = [ "default" "getrandom" ]; + }; "tera" = rec { crateName = "tera"; version = "1.20.1"; diff --git a/Cargo.toml b/Cargo.toml index dfbb9ac5..9aff2a6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,10 @@ clap = { version = "4.5", features = ["derive", "env"] } clap_complete = "4.5" clap_complete_nushell = "4.5" comfy-table = { version = "7.1", features = ["custom_styling"] } +dialoguer = "0.12.0" directories = "6.0" dotenvy = "0.15" +either = "1.15.0" futures = "0.3" indexmap = { version = "2.2", features = ["serde"] } indicatif = "0.18" diff --git a/docs/modules/stackablectl/partials/commands/demo.adoc b/docs/modules/stackablectl/partials/commands/demo.adoc index c5b2d39b..21f5b844 100644 --- a/docs/modules/stackablectl/partials/commands/demo.adoc +++ b/docs/modules/stackablectl/partials/commands/demo.adoc @@ -6,10 +6,11 @@ Interact with demos, which are end-to-end usage demonstrations of the Stackable Usage: stackablectl demo [OPTIONS] Commands: - list List available demos - describe Print out detailed demo information - install Install a specific demo - help Print this message or the help of the given subcommand(s) + list List available demos + describe Print out detailed demo information + install Install a specific demo + uninstall Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + help Print this message or the help of the given subcommand(s) Options: -l, --log-level diff --git a/docs/modules/stackablectl/partials/commands/stack.adoc b/docs/modules/stackablectl/partials/commands/stack.adoc index 639b1621..9bc0a561 100644 --- a/docs/modules/stackablectl/partials/commands/stack.adoc +++ b/docs/modules/stackablectl/partials/commands/stack.adoc @@ -6,10 +6,11 @@ Interact with stacks, which are ready-to-use product combinations Usage: stackablectl stack [OPTIONS] Commands: - list List available stacks - describe Describe a specific stack - install Install a specific stack - help Print this message or the help of the given subcommand(s) + list List available stacks + describe Describe a specific stack + install Install a specific stack + uninstall Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + help Print this message or the help of the given subcommand(s) Options: -l, --log-level diff --git a/extra/completions/_stackablectl b/extra/completions/_stackablectl index abba1406..e60dcaae 100644 --- a/extra/completions/_stackablectl +++ b/extra/completions/_stackablectl @@ -672,7 +672,40 @@ repo\:"index.yaml-based repositories\: resolution (dev, test, stable) is based o '--help[Print help (see more with '\''--help'\'')]' \ '-V[Print version]' \ '--version[Print version]' \ -':stack_name -- Name of the stack to describe:_default' \ +':stack_name -- Name of the stack to install:_default' \ +&& ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +'--operator-namespace=[Namespace where the operators are deployed]:OPERATOR_NAMESPACE:_default' \ +'--operator-ns=[Namespace where the operators are deployed]:OPERATOR_NAMESPACE:_default' \ +'-n+[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--namespace=[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--product-ns=[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--release=[Target a specific Stackable release]:RELEASE:_default' \ +'-l+[Log level this application uses]:LOG_LEVEL:_default' \ +'--log-level=[Log level this application uses]:LOG_LEVEL:_default' \ +'*-d+[Provide one or more additional (custom) demo file(s)]:DEMO_FILE:_files' \ +'*--demo-file=[Provide one or more additional (custom) demo file(s)]:DEMO_FILE:_files' \ +'*-s+[Provide one or more additional (custom) stack file(s)]:STACK_FILE:_files' \ +'*--stack-file=[Provide one or more additional (custom) stack file(s)]:STACK_FILE:_files' \ +'*-r+[Provide one or more additional (custom) release file(s)]:RELEASE_FILE:_files' \ +'*--release-file=[Provide one or more additional (custom) release file(s)]:RELEASE_FILE:_files' \ +'-f+[Path to a Helm values file that will be used for the installation of operators]:VALUES_FILE:_files' \ +'--operator-values=[Path to a Helm values file that will be used for the installation of operators]:VALUES_FILE:_files' \ +'--helm-repo-stable=[Provide a custom Helm stable repository URL]:URL:_urls' \ +'--helm-repo-test=[Provide a custom Helm test repository URL]:URL:_urls' \ +'--helm-repo-dev=[Provide a custom Helm dev repository URL]:URL:_urls' \ +'--chart-source=[Source the charts from either a OCI registry or from index.yaml-based repositories]:CHART_SOURCE:((oci\:"OCI registry" +repo\:"index.yaml-based repositories\: resolution (dev, test, stable) is based on the version and thus will be operator-specific"))' \ +'--listener-class-preset=[Choose the ListenerClass preset (\`none\`, \`ephemeral-nodes\` or \`stable-nodes\`)]:LISTENER_CLASS_PRESET:(none stable-nodes ephemeral-nodes)' \ +'--skip-operators-and-crds[Skip uninstalling Stackable operators and CRDs]' \ +'--no-cache[Do not cache the remote (default) demo, stack and release files]' \ +'-h[Print help (see more with '\''--help'\'')]' \ +'--help[Print help (see more with '\''--help'\'')]' \ +'-V[Print version]' \ +'--version[Print version]' \ +':stack_name -- Name of the stack to uninstall:_default' \ && ret=0 ;; (help) @@ -699,6 +732,10 @@ _arguments "${_arguments_options[@]}" : \ _arguments "${_arguments_options[@]}" : \ && ret=0 ;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 +;; (help) _arguments "${_arguments_options[@]}" : \ && ret=0 @@ -988,6 +1025,39 @@ repo\:"index.yaml-based repositories\: resolution (dev, test, stable) is based o ':DEMO -- Demo to install:_default' \ && ret=0 ;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +'--operator-namespace=[Namespace where the operators are deployed]:OPERATOR_NAMESPACE:_default' \ +'--operator-ns=[Namespace where the operators are deployed]:OPERATOR_NAMESPACE:_default' \ +'-n+[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--namespace=[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--product-ns=[Namespace where the stacks or demos are deployed]:NAMESPACE:_default' \ +'--release=[Target a specific Stackable release]:RELEASE:_default' \ +'-l+[Log level this application uses]:LOG_LEVEL:_default' \ +'--log-level=[Log level this application uses]:LOG_LEVEL:_default' \ +'*-d+[Provide one or more additional (custom) demo file(s)]:DEMO_FILE:_files' \ +'*--demo-file=[Provide one or more additional (custom) demo file(s)]:DEMO_FILE:_files' \ +'*-s+[Provide one or more additional (custom) stack file(s)]:STACK_FILE:_files' \ +'*--stack-file=[Provide one or more additional (custom) stack file(s)]:STACK_FILE:_files' \ +'*-r+[Provide one or more additional (custom) release file(s)]:RELEASE_FILE:_files' \ +'*--release-file=[Provide one or more additional (custom) release file(s)]:RELEASE_FILE:_files' \ +'-f+[Path to a Helm values file that will be used for the installation of operators]:VALUES_FILE:_files' \ +'--operator-values=[Path to a Helm values file that will be used for the installation of operators]:VALUES_FILE:_files' \ +'--helm-repo-stable=[Provide a custom Helm stable repository URL]:URL:_urls' \ +'--helm-repo-test=[Provide a custom Helm test repository URL]:URL:_urls' \ +'--helm-repo-dev=[Provide a custom Helm dev repository URL]:URL:_urls' \ +'--chart-source=[Source the charts from either a OCI registry or from index.yaml-based repositories]:CHART_SOURCE:((oci\:"OCI registry" +repo\:"index.yaml-based repositories\: resolution (dev, test, stable) is based on the version and thus will be operator-specific"))' \ +'--listener-class-preset=[Choose the ListenerClass preset (\`none\`, \`ephemeral-nodes\` or \`stable-nodes\`)]:LISTENER_CLASS_PRESET:(none stable-nodes ephemeral-nodes)' \ +'--skip-operators-and-crds[Skip uninstalling Stackable operators and CRDs]' \ +'--no-cache[Do not cache the remote (default) demo, stack and release files]' \ +'-h[Print help (see more with '\''--help'\'')]' \ +'--help[Print help (see more with '\''--help'\'')]' \ +'-V[Print version]' \ +'--version[Print version]' \ +':demo_name -- Demo to uninstall:_default' \ +&& ret=0 +;; (help) _arguments "${_arguments_options[@]}" : \ ":: :_stackablectl__demo__help_commands" \ @@ -1012,6 +1082,10 @@ _arguments "${_arguments_options[@]}" : \ _arguments "${_arguments_options[@]}" : \ && ret=0 ;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 +;; (help) _arguments "${_arguments_options[@]}" : \ && ret=0 @@ -1568,6 +1642,10 @@ _arguments "${_arguments_options[@]}" : \ (install) _arguments "${_arguments_options[@]}" : \ && ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 ;; esac ;; @@ -1620,6 +1698,10 @@ _arguments "${_arguments_options[@]}" : \ (install) _arguments "${_arguments_options[@]}" : \ && ret=0 +;; +(uninstall) +_arguments "${_arguments_options[@]}" : \ +&& ret=0 ;; esac ;; @@ -1866,6 +1948,7 @@ _stackablectl__demo_commands() { 'list:List available demos' \ 'describe:Print out detailed demo information' \ 'install:Install a specific demo' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'stackablectl demo commands' commands "$@" @@ -1881,6 +1964,7 @@ _stackablectl__demo__help_commands() { 'list:List available demos' \ 'describe:Print out detailed demo information' \ 'install:Install a specific demo' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'stackablectl demo help commands' commands "$@" @@ -1905,6 +1989,11 @@ _stackablectl__demo__help__list_commands() { local commands; commands=() _describe -t commands 'stackablectl demo help list commands' commands "$@" } +(( $+functions[_stackablectl__demo__help__uninstall_commands] )) || +_stackablectl__demo__help__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl demo help uninstall commands' commands "$@" +} (( $+functions[_stackablectl__demo__install_commands] )) || _stackablectl__demo__install_commands() { local commands; commands=() @@ -1915,6 +2004,11 @@ _stackablectl__demo__list_commands() { local commands; commands=() _describe -t commands 'stackablectl demo list commands' commands "$@" } +(( $+functions[_stackablectl__demo__uninstall_commands] )) || +_stackablectl__demo__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl demo uninstall commands' commands "$@" +} (( $+functions[_stackablectl__experimental-debug_commands] )) || _stackablectl__experimental-debug_commands() { local commands; commands=() @@ -1996,6 +2090,7 @@ _stackablectl__help__demo_commands() { 'list:List available demos' \ 'describe:Print out detailed demo information' \ 'install:Install a specific demo' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ ) _describe -t commands 'stackablectl help demo commands' commands "$@" } @@ -2014,6 +2109,11 @@ _stackablectl__help__demo__list_commands() { local commands; commands=() _describe -t commands 'stackablectl help demo list commands' commands "$@" } +(( $+functions[_stackablectl__help__demo__uninstall_commands] )) || +_stackablectl__help__demo__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl help demo uninstall commands' commands "$@" +} (( $+functions[_stackablectl__help__experimental-debug_commands] )) || _stackablectl__help__experimental-debug_commands() { local commands; commands=() @@ -2102,6 +2202,7 @@ _stackablectl__help__stack_commands() { 'list:List available stacks' \ 'describe:Describe a specific stack' \ 'install:Install a specific stack' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ ) _describe -t commands 'stackablectl help stack commands' commands "$@" } @@ -2120,6 +2221,11 @@ _stackablectl__help__stack__list_commands() { local commands; commands=() _describe -t commands 'stackablectl help stack list commands' commands "$@" } +(( $+functions[_stackablectl__help__stack__uninstall_commands] )) || +_stackablectl__help__stack__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl help stack uninstall commands' commands "$@" +} (( $+functions[_stackablectl__help__stacklet_commands] )) || _stackablectl__help__stacklet_commands() { local commands; commands=( @@ -2314,6 +2420,7 @@ _stackablectl__stack_commands() { 'list:List available stacks' \ 'describe:Describe a specific stack' \ 'install:Install a specific stack' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'stackablectl stack commands' commands "$@" @@ -2329,6 +2436,7 @@ _stackablectl__stack__help_commands() { 'list:List available stacks' \ 'describe:Describe a specific stack' \ 'install:Install a specific stack' \ +'uninstall:Uninstall a specific stack. Caution\: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' \ 'help:Print this message or the help of the given subcommand(s)' \ ) _describe -t commands 'stackablectl stack help commands' commands "$@" @@ -2353,6 +2461,11 @@ _stackablectl__stack__help__list_commands() { local commands; commands=() _describe -t commands 'stackablectl stack help list commands' commands "$@" } +(( $+functions[_stackablectl__stack__help__uninstall_commands] )) || +_stackablectl__stack__help__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl stack help uninstall commands' commands "$@" +} (( $+functions[_stackablectl__stack__install_commands] )) || _stackablectl__stack__install_commands() { local commands; commands=() @@ -2363,6 +2476,11 @@ _stackablectl__stack__list_commands() { local commands; commands=() _describe -t commands 'stackablectl stack list commands' commands "$@" } +(( $+functions[_stackablectl__stack__uninstall_commands] )) || +_stackablectl__stack__uninstall_commands() { + local commands; commands=() + _describe -t commands 'stackablectl stack uninstall commands' commands "$@" +} (( $+functions[_stackablectl__stacklet_commands] )) || _stackablectl__stacklet_commands() { local commands; commands=( diff --git a/extra/completions/stackablectl.bash b/extra/completions/stackablectl.bash index be0544fa..13c0028a 100644 --- a/extra/completions/stackablectl.bash +++ b/extra/completions/stackablectl.bash @@ -112,6 +112,9 @@ _stackablectl() { stackablectl__demo,list) cmd="stackablectl__demo__list" ;; + stackablectl__demo,uninstall) + cmd="stackablectl__demo__uninstall" + ;; stackablectl__demo__help,describe) cmd="stackablectl__demo__help__describe" ;; @@ -124,6 +127,9 @@ _stackablectl() { stackablectl__demo__help,list) cmd="stackablectl__demo__help__list" ;; + stackablectl__demo__help,uninstall) + cmd="stackablectl__demo__help__uninstall" + ;; stackablectl__help,cache) cmd="stackablectl__help__cache" ;; @@ -184,6 +190,9 @@ _stackablectl() { stackablectl__help__demo,list) cmd="stackablectl__help__demo__list" ;; + stackablectl__help__demo,uninstall) + cmd="stackablectl__help__demo__uninstall" + ;; stackablectl__help__operator,describe) cmd="stackablectl__help__operator__describe" ;; @@ -223,6 +232,9 @@ _stackablectl() { stackablectl__help__stack,list) cmd="stackablectl__help__stack__list" ;; + stackablectl__help__stack,uninstall) + cmd="stackablectl__help__stack__uninstall" + ;; stackablectl__help__stacklet,credentials) cmd="stackablectl__help__stacklet__credentials" ;; @@ -316,6 +328,9 @@ _stackablectl() { stackablectl__stack,list) cmd="stackablectl__stack__list" ;; + stackablectl__stack,uninstall) + cmd="stackablectl__stack__uninstall" + ;; stackablectl__stack__help,describe) cmd="stackablectl__stack__help__describe" ;; @@ -328,6 +343,9 @@ _stackablectl() { stackablectl__stack__help,list) cmd="stackablectl__stack__help__list" ;; + stackablectl__stack__help,uninstall) + cmd="stackablectl__stack__help__uninstall" + ;; stackablectl__stacklet,credentials) cmd="stackablectl__stacklet__credentials" ;; @@ -2139,7 +2157,7 @@ _stackablectl() { return 0 ;; stackablectl__demo) - opts="-l -d -s -r -f -h -V --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version list describe install help" + opts="-l -d -s -r -f -h -V --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version list describe install uninstall help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2479,7 +2497,7 @@ _stackablectl() { return 0 ;; stackablectl__demo__help) - opts="list describe install help" + opts="list describe install uninstall help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -2548,6 +2566,20 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__demo__help__uninstall) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__demo__install) opts="-c -n -l -d -s -r -f -h -V --skip-release --stack-parameters --parameters --cluster --cluster-name --cluster-nodes --cluster-cp-nodes --operator-ns --operator-namespace --product-ns --namespace --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -2936,6 +2968,192 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__demo__uninstall) + opts="-n -l -d -s -r -f -h -V --operator-ns --operator-namespace --product-ns --namespace --skip-operators-and-crds --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version " + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --operator-namespace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --operator-ns) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --namespace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --product-ns) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -n) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --release) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --log-level) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -l) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --demo-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -d) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --stack-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -s) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --release-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -r) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --operator-values) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -f) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --helm-repo-stable) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --helm-repo-test) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --helm-repo-dev) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --chart-source) + COMPREPLY=($(compgen -W "oci repo" -- "${cur}")) + return 0 + ;; + --listener-class-preset) + COMPREPLY=($(compgen -W "none stable-nodes ephemeral-nodes" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__experimental__debug) opts="-n -c -l -d -s -r -f -h -V --namespace --container --image --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version [CMD]..." if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then @@ -3259,7 +3477,7 @@ _stackablectl() { return 0 ;; stackablectl__help__demo) - opts="list describe install" + opts="list describe install uninstall" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3314,6 +3532,20 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__help__demo__uninstall) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__help__experimental__debug) opts="" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -3511,7 +3743,7 @@ _stackablectl() { return 0 ;; stackablectl__help__stack) - opts="list describe install" + opts="list describe install uninstall" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -3566,6 +3798,20 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__help__stack__uninstall) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__help__stacklet) opts="credentials list" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -5937,7 +6183,7 @@ _stackablectl() { return 0 ;; stackablectl__stack) - opts="-l -d -s -r -f -h -V --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version list describe install help" + opts="-l -d -s -r -f -h -V --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version list describe install uninstall help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -6277,7 +6523,7 @@ _stackablectl() { return 0 ;; stackablectl__stack__help) - opts="list describe install help" + opts="list describe install uninstall help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 @@ -6346,6 +6592,20 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__stack__help__uninstall) + opts="" + if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__stack__install) opts="-c -n -l -d -s -r -f -h -V --skip-release --stack-parameters --parameters --cluster --cluster-name --cluster-nodes --cluster-cp-nodes --operator-ns --operator-namespace --product-ns --namespace --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version " if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then @@ -6734,6 +6994,192 @@ _stackablectl() { COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 ;; + stackablectl__stack__uninstall) + opts="-n -l -d -s -r -f -h -V --operator-ns --operator-namespace --product-ns --namespace --skip-operators-and-crds --release --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version " + if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + fi + case "${prev}" in + --operator-namespace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --operator-ns) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --namespace) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --product-ns) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -n) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --release) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --log-level) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + -l) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --demo-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -d) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --stack-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -s) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --release-file) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -r) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --operator-values) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + -f) + local oldifs + if [ -n "${IFS+x}" ]; then + oldifs="$IFS" + fi + IFS=$'\n' + COMPREPLY=($(compgen -f "${cur}")) + if [ -n "${oldifs+x}" ]; then + IFS="$oldifs" + fi + if [[ "${BASH_VERSINFO[0]}" -ge 4 ]]; then + compopt -o filenames + fi + return 0 + ;; + --helm-repo-stable) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --helm-repo-test) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --helm-repo-dev) + COMPREPLY=($(compgen -f "${cur}")) + return 0 + ;; + --chart-source) + COMPREPLY=($(compgen -W "oci repo" -- "${cur}")) + return 0 + ;; + --listener-class-preset) + COMPREPLY=($(compgen -W "none stable-nodes ephemeral-nodes" -- "${cur}")) + return 0 + ;; + *) + COMPREPLY=() + ;; + esac + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + ;; stackablectl__stacklet) opts="-l -d -s -r -f -h -V --log-level --no-cache --demo-file --stack-file --release-file --operator-values --helm-repo-stable --helm-repo-test --helm-repo-dev --chart-source --listener-class-preset --help --version credentials list help" if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then diff --git a/extra/completions/stackablectl.elv b/extra/completions/stackablectl.elv index e98558e7..4faf691a 100644 --- a/extra/completions/stackablectl.elv +++ b/extra/completions/stackablectl.elv @@ -430,6 +430,7 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand list 'List available stacks' cand describe 'Describe a specific stack' cand install 'Install a specific stack' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' cand help 'Print this message or the help of the given subcommand(s)' } &'stackablectl;stack;list'= { @@ -518,10 +519,40 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand -V 'Print version' cand --version 'Print version' } + &'stackablectl;stack;uninstall'= { + cand --operator-namespace 'Namespace where the operators are deployed' + cand --operator-ns 'Namespace where the operators are deployed' + cand -n 'Namespace where the stacks or demos are deployed' + cand --namespace 'Namespace where the stacks or demos are deployed' + cand --product-ns 'Namespace where the stacks or demos are deployed' + cand --release 'Target a specific Stackable release' + cand -l 'Log level this application uses' + cand --log-level 'Log level this application uses' + cand -d 'Provide one or more additional (custom) demo file(s)' + cand --demo-file 'Provide one or more additional (custom) demo file(s)' + cand -s 'Provide one or more additional (custom) stack file(s)' + cand --stack-file 'Provide one or more additional (custom) stack file(s)' + cand -r 'Provide one or more additional (custom) release file(s)' + cand --release-file 'Provide one or more additional (custom) release file(s)' + cand -f 'Path to a Helm values file that will be used for the installation of operators' + cand --operator-values 'Path to a Helm values file that will be used for the installation of operators' + cand --helm-repo-stable 'Provide a custom Helm stable repository URL' + cand --helm-repo-test 'Provide a custom Helm test repository URL' + cand --helm-repo-dev 'Provide a custom Helm dev repository URL' + cand --chart-source 'Source the charts from either a OCI registry or from index.yaml-based repositories' + cand --listener-class-preset 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' + cand --skip-operators-and-crds 'Skip uninstalling Stackable operators and CRDs' + cand --no-cache 'Do not cache the remote (default) demo, stack and release files' + cand -h 'Print help (see more with ''--help'')' + cand --help 'Print help (see more with ''--help'')' + cand -V 'Print version' + cand --version 'Print version' + } &'stackablectl;stack;help'= { cand list 'List available stacks' cand describe 'Describe a specific stack' cand install 'Install a specific stack' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' cand help 'Print this message or the help of the given subcommand(s)' } &'stackablectl;stack;help;list'= { @@ -530,6 +561,8 @@ set edit:completion:arg-completer[stackablectl] = {|@words| } &'stackablectl;stack;help;install'= { } + &'stackablectl;stack;help;uninstall'= { + } &'stackablectl;stack;help;help'= { } &'stackablectl;stacklet'= { @@ -646,6 +679,7 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand list 'List available demos' cand describe 'Print out detailed demo information' cand install 'Install a specific demo' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' cand help 'Print this message or the help of the given subcommand(s)' } &'stackablectl;demo;list'= { @@ -734,10 +768,40 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand -V 'Print version' cand --version 'Print version' } + &'stackablectl;demo;uninstall'= { + cand --operator-namespace 'Namespace where the operators are deployed' + cand --operator-ns 'Namespace where the operators are deployed' + cand -n 'Namespace where the stacks or demos are deployed' + cand --namespace 'Namespace where the stacks or demos are deployed' + cand --product-ns 'Namespace where the stacks or demos are deployed' + cand --release 'Target a specific Stackable release' + cand -l 'Log level this application uses' + cand --log-level 'Log level this application uses' + cand -d 'Provide one or more additional (custom) demo file(s)' + cand --demo-file 'Provide one or more additional (custom) demo file(s)' + cand -s 'Provide one or more additional (custom) stack file(s)' + cand --stack-file 'Provide one or more additional (custom) stack file(s)' + cand -r 'Provide one or more additional (custom) release file(s)' + cand --release-file 'Provide one or more additional (custom) release file(s)' + cand -f 'Path to a Helm values file that will be used for the installation of operators' + cand --operator-values 'Path to a Helm values file that will be used for the installation of operators' + cand --helm-repo-stable 'Provide a custom Helm stable repository URL' + cand --helm-repo-test 'Provide a custom Helm test repository URL' + cand --helm-repo-dev 'Provide a custom Helm dev repository URL' + cand --chart-source 'Source the charts from either a OCI registry or from index.yaml-based repositories' + cand --listener-class-preset 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' + cand --skip-operators-and-crds 'Skip uninstalling Stackable operators and CRDs' + cand --no-cache 'Do not cache the remote (default) demo, stack and release files' + cand -h 'Print help (see more with ''--help'')' + cand --help 'Print help (see more with ''--help'')' + cand -V 'Print version' + cand --version 'Print version' + } &'stackablectl;demo;help'= { cand list 'List available demos' cand describe 'Print out detailed demo information' cand install 'Install a specific demo' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' cand help 'Print this message or the help of the given subcommand(s)' } &'stackablectl;demo;help;list'= { @@ -746,6 +810,8 @@ set edit:completion:arg-completer[stackablectl] = {|@words| } &'stackablectl;demo;help;install'= { } + &'stackablectl;demo;help;uninstall'= { + } &'stackablectl;demo;help;help'= { } &'stackablectl;completions'= { @@ -1119,6 +1185,7 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand list 'List available stacks' cand describe 'Describe a specific stack' cand install 'Install a specific stack' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' } &'stackablectl;help;stack;list'= { } @@ -1126,6 +1193,8 @@ set edit:completion:arg-completer[stackablectl] = {|@words| } &'stackablectl;help;stack;install'= { } + &'stackablectl;help;stack;uninstall'= { + } &'stackablectl;help;stacklet'= { cand credentials 'Display credentials for a stacklet' cand list 'List deployed stacklets' @@ -1138,6 +1207,7 @@ set edit:completion:arg-completer[stackablectl] = {|@words| cand list 'List available demos' cand describe 'Print out detailed demo information' cand install 'Install a specific demo' + cand uninstall 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' } &'stackablectl;help;demo;list'= { } @@ -1145,6 +1215,8 @@ set edit:completion:arg-completer[stackablectl] = {|@words| } &'stackablectl;help;demo;install'= { } + &'stackablectl;help;demo;uninstall'= { + } &'stackablectl;help;completions'= { cand bash 'Generate shell completions for Bash' cand elvish 'Generate shell completions for Elvish' diff --git a/extra/completions/stackablectl.fish b/extra/completions/stackablectl.fish index ba0bb555..d60c7d99 100644 --- a/extra/completions/stackablectl.fish +++ b/extra/completions/stackablectl.fish @@ -306,27 +306,28 @@ complete -c stackablectl -n "__fish_stackablectl_using_subcommand release; and _ complete -c stackablectl -n "__fish_stackablectl_using_subcommand release; and __fish_seen_subcommand_from help" -f -a "uninstall" -d 'Uninstall a release' complete -c stackablectl -n "__fish_stackablectl_using_subcommand release; and __fish_seen_subcommand_from help" -f -a "upgrade" -d 'Upgrade a release' complete -c stackablectl -n "__fish_stackablectl_using_subcommand release; and __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_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l release -d 'Target a specific Stackable release' -r -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s l -l log-level -d 'Log level this application uses' -r -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' -repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' -stable-nodes\t'' -ephemeral-nodes\t''" -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s h -l help -d 'Print help (see more with \'--help\')' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -s V -l version -d 'Print version' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -f -a "list" -d 'List available stacks' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -f -a "describe" -d 'Describe a specific stack' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -f -a "install" -d 'Install a specific stack' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l release -d 'Target a specific Stackable release' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s l -l log-level -d 'Log level this application uses' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' +repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' +stable-nodes\t'' +ephemeral-nodes\t''" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s h -l help -d 'Print help (see more with \'--help\')' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -s V -l version -d 'Print version' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "list" -d 'List available stacks' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "describe" -d 'Describe a specific stack' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "install" -d 'Install a specific stack' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from list" -s o -l output -r -f -a "plain\t'Print output formatted as plain text' table\t'Print output formatted as a table' json\t'Print output formatted as JSON' @@ -396,9 +397,30 @@ complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __f complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from install" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from install" -s h -l help -d 'Print help (see more with \'--help\')' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from install" -s V -l version -d 'Print version' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l operator-namespace -l operator-ns -d 'Namespace where the operators are deployed' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s n -l namespace -l product-ns -d 'Namespace where the stacks or demos are deployed' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l release -d 'Target a specific Stackable release' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s l -l log-level -d 'Log level this application uses' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' +repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' +stable-nodes\t'' +ephemeral-nodes\t''" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l skip-operators-and-crds -d 'Skip uninstalling Stackable operators and CRDs' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s h -l help -d 'Print help (see more with \'--help\')' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from uninstall" -s V -l version -d 'Print version' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from help" -f -a "list" -d 'List available stacks' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from help" -f -a "describe" -d 'Describe a specific stack' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from help" -f -a "install" -d 'Install a specific stack' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __fish_seen_subcommand_from help" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stack; and __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_stackablectl_using_subcommand stacklet; and not __fish_seen_subcommand_from credentials list help" -s l -l log-level -d 'Log level this application uses' -r complete -c stackablectl -n "__fish_stackablectl_using_subcommand stacklet; and not __fish_seen_subcommand_from credentials list help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F @@ -461,27 +483,28 @@ complete -c stackablectl -n "__fish_stackablectl_using_subcommand stacklet; and complete -c stackablectl -n "__fish_stackablectl_using_subcommand stacklet; and __fish_seen_subcommand_from help" -f -a "credentials" -d 'Display credentials for a stacklet' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stacklet; and __fish_seen_subcommand_from help" -f -a "list" -d 'List deployed stacklets' complete -c stackablectl -n "__fish_stackablectl_using_subcommand stacklet; and __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_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l release -d 'Target a specific Stackable release' -r -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s l -l log-level -d 'Log level this application uses' -r -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' -repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' -stable-nodes\t'' -ephemeral-nodes\t''" -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s h -l help -d 'Print help (see more with \'--help\')' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -s V -l version -d 'Print version' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -f -a "list" -d 'List available demos' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -f -a "describe" -d 'Print out detailed demo information' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -f -a "install" -d 'Install a specific demo' -complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l release -d 'Target a specific Stackable release' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s l -l log-level -d 'Log level this application uses' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' +repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' +stable-nodes\t'' +ephemeral-nodes\t''" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s h -l help -d 'Print help (see more with \'--help\')' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -s V -l version -d 'Print version' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "list" -d 'List available demos' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "describe" -d 'Print out detailed demo information' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "install" -d 'Install a specific demo' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and not __fish_seen_subcommand_from list describe install uninstall help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from list" -s o -l output -r -f -a "plain\t'Print output formatted as plain text' table\t'Print output formatted as a table' json\t'Print output formatted as JSON' @@ -551,9 +574,30 @@ complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fi complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from install" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from install" -s h -l help -d 'Print help (see more with \'--help\')' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from install" -s V -l version -d 'Print version' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l operator-namespace -l operator-ns -d 'Namespace where the operators are deployed' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s n -l namespace -l product-ns -d 'Namespace where the stacks or demos are deployed' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l release -d 'Target a specific Stackable release' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s l -l log-level -d 'Log level this application uses' -r +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s s -l stack-file -d 'Provide one or more additional (custom) stack file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s r -l release-file -d 'Provide one or more additional (custom) release file(s)' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s f -l operator-values -d 'Path to a Helm values file that will be used for the installation of operators' -r -F +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l helm-repo-stable -d 'Provide a custom Helm stable repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l helm-repo-test -d 'Provide a custom Helm test repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l helm-repo-dev -d 'Provide a custom Helm dev repository URL' -r -f +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l chart-source -d 'Source the charts from either a OCI registry or from index.yaml-based repositories' -r -f -a "oci\t'OCI registry' +repo\t'index.yaml-based repositories: resolution (dev, test, stable) is based on the version and thus will be operator-specific'" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l listener-class-preset -d 'Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`)' -r -f -a "none\t'' +stable-nodes\t'' +ephemeral-nodes\t''" +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l skip-operators-and-crds -d 'Skip uninstalling Stackable operators and CRDs' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -l no-cache -d 'Do not cache the remote (default) demo, stack and release files' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s h -l help -d 'Print help (see more with \'--help\')' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from uninstall" -s V -l version -d 'Print version' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from help" -f -a "list" -d 'List available demos' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from help" -f -a "describe" -d 'Print out detailed demo information' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from help" -f -a "install" -d 'Install a specific demo' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __fish_seen_subcommand_from help" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' complete -c stackablectl -n "__fish_stackablectl_using_subcommand demo; and __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_stackablectl_using_subcommand completions; and not __fish_seen_subcommand_from bash elvish fish nushell zsh help" -s l -l log-level -d 'Log level this application uses' -r complete -c stackablectl -n "__fish_stackablectl_using_subcommand completions; and not __fish_seen_subcommand_from bash elvish fish nushell zsh help" -s d -l demo-file -d 'Provide one or more additional (custom) demo file(s)' -r -F @@ -796,11 +840,13 @@ complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fi complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stack" -f -a "list" -d 'List available stacks' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stack" -f -a "describe" -d 'Describe a specific stack' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stack" -f -a "install" -d 'Install a specific stack' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stack" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stacklet" -f -a "credentials" -d 'Display credentials for a stacklet' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from stacklet" -f -a "list" -d 'List deployed stacklets' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from demo" -f -a "list" -d 'List available demos' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from demo" -f -a "describe" -d 'Print out detailed demo information' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from demo" -f -a "install" -d 'Install a specific demo' +complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from demo" -f -a "uninstall" -d 'Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from completions" -f -a "bash" -d 'Generate shell completions for Bash' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from completions" -f -a "elvish" -d 'Generate shell completions for Elvish' complete -c stackablectl -n "__fish_stackablectl_using_subcommand help; and __fish_seen_subcommand_from completions" -f -a "fish" -d 'Generate shell completions for Fish' diff --git a/extra/completions/stackablectl.nu b/extra/completions/stackablectl.nu index ee82490f..b5b95011 100644 --- a/extra/completions/stackablectl.nu +++ b/extra/completions/stackablectl.nu @@ -573,7 +573,39 @@ module completions { --listener-class-preset: string@"nu-complete stackablectl stack install listener_class_preset" # Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`) --help(-h) # Print help (see more with '--help') --version(-V) # Print version - stack_name: string # Name of the stack to describe + stack_name: string # Name of the stack to install + ] + + def "nu-complete stackablectl stack uninstall chart_source" [] { + [ "oci" "repo" ] + } + + def "nu-complete stackablectl stack uninstall listener_class_preset" [] { + [ "none" "stable-nodes" "ephemeral-nodes" ] + } + + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl stack uninstall" [ + --operator-namespace: string # Namespace where the operators are deployed + --operator-ns: string # Namespace where the operators are deployed + --namespace(-n): string # Namespace where the stacks or demos are deployed + --product-ns: string # Namespace where the stacks or demos are deployed + --skip-operators-and-crds # Skip uninstalling Stackable operators and CRDs + --release: string # Target a specific Stackable release + --log-level(-l): string # Log level this application uses + --no-cache # Do not cache the remote (default) demo, stack and release files + --demo-file(-d): path # Provide one or more additional (custom) demo file(s) + --stack-file(-s): path # Provide one or more additional (custom) stack file(s) + --release-file(-r): path # Provide one or more additional (custom) release file(s) + --operator-values(-f): path # Path to a Helm values file that will be used for the installation of operators + --helm-repo-stable: string # Provide a custom Helm stable repository URL + --helm-repo-test: string # Provide a custom Helm test repository URL + --helm-repo-dev: string # Provide a custom Helm dev repository URL + --chart-source: string@"nu-complete stackablectl stack uninstall chart_source" # Source the charts from either a OCI registry or from index.yaml-based repositories + --listener-class-preset: string@"nu-complete stackablectl stack uninstall listener_class_preset" # Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`) + --help(-h) # Print help (see more with '--help') + --version(-V) # Print version + stack_name: string # Name of the stack to uninstall ] # Print this message or the help of the given subcommand(s) @@ -592,6 +624,10 @@ module completions { export extern "stackablectl stack help install" [ ] + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl stack help uninstall" [ + ] + # Print this message or the help of the given subcommand(s) export extern "stackablectl stack help help" [ ] @@ -830,6 +866,38 @@ module completions { DEMO: string # Demo to install ] + def "nu-complete stackablectl demo uninstall chart_source" [] { + [ "oci" "repo" ] + } + + def "nu-complete stackablectl demo uninstall listener_class_preset" [] { + [ "none" "stable-nodes" "ephemeral-nodes" ] + } + + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl demo uninstall" [ + --operator-namespace: string # Namespace where the operators are deployed + --operator-ns: string # Namespace where the operators are deployed + --namespace(-n): string # Namespace where the stacks or demos are deployed + --product-ns: string # Namespace where the stacks or demos are deployed + --skip-operators-and-crds # Skip uninstalling Stackable operators and CRDs + --release: string # Target a specific Stackable release + --log-level(-l): string # Log level this application uses + --no-cache # Do not cache the remote (default) demo, stack and release files + --demo-file(-d): path # Provide one or more additional (custom) demo file(s) + --stack-file(-s): path # Provide one or more additional (custom) stack file(s) + --release-file(-r): path # Provide one or more additional (custom) release file(s) + --operator-values(-f): path # Path to a Helm values file that will be used for the installation of operators + --helm-repo-stable: string # Provide a custom Helm stable repository URL + --helm-repo-test: string # Provide a custom Helm test repository URL + --helm-repo-dev: string # Provide a custom Helm dev repository URL + --chart-source: string@"nu-complete stackablectl demo uninstall chart_source" # Source the charts from either a OCI registry or from index.yaml-based repositories + --listener-class-preset: string@"nu-complete stackablectl demo uninstall listener_class_preset" # Choose the ListenerClass preset (`none`, `ephemeral-nodes` or `stable-nodes`) + --help(-h) # Print help (see more with '--help') + --version(-V) # Print version + demo_name: string # Demo to uninstall + ] + # Print this message or the help of the given subcommand(s) export extern "stackablectl demo help" [ ] @@ -846,6 +914,10 @@ module completions { export extern "stackablectl demo help install" [ ] + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl demo help uninstall" [ + ] + # Print this message or the help of the given subcommand(s) export extern "stackablectl demo help help" [ ] @@ -1281,6 +1353,10 @@ module completions { export extern "stackablectl help stack install" [ ] + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl help stack uninstall" [ + ] + # Interact with deployed stacklets, which are bundles of resources and containers required to run the product export extern "stackablectl help stacklet" [ ] @@ -1309,6 +1385,10 @@ module completions { export extern "stackablectl help demo install" [ ] + # Uninstall a specific stack. Caution: This will delete the provided stack namespace, the operators and provided operator namespace, and all Stackable CRDs + export extern "stackablectl help demo uninstall" [ + ] + # Generate shell completions for this tool export extern "stackablectl help completions" [ ] diff --git a/rust/stackable-cockpit/Cargo.toml b/rust/stackable-cockpit/Cargo.toml index f6292a8e..15ec1139 100644 --- a/rust/stackable-cockpit/Cargo.toml +++ b/rust/stackable-cockpit/Cargo.toml @@ -17,6 +17,7 @@ helm-sys = { path = "../helm-sys" } bcrypt.workspace = true clap.workspace = true +either.workspace = true indexmap.workspace = true rand.workspace = true reqwest.workspace = true diff --git a/rust/stackable-cockpit/src/platform/demo/params.rs b/rust/stackable-cockpit/src/platform/demo/params.rs index 84f54d2b..33958bdd 100644 --- a/rust/stackable-cockpit/src/platform/demo/params.rs +++ b/rust/stackable-cockpit/src/platform/demo/params.rs @@ -4,6 +4,8 @@ use stackable_operator::kvp::Labels; use crate::platform::operator::ChartSourceType; pub struct DemoInstallParameters { + pub demo_name: String, + pub operator_namespace: String, pub demo_namespace: String, @@ -16,3 +18,13 @@ pub struct DemoInstallParameters { pub chart_source: ChartSourceType, pub operator_values: Mapping, } + +pub struct DemoUninstallParameters { + pub demo_name: String, + + pub operator_namespace: String, + pub demo_namespace: String, + + pub skip_operators: bool, + pub skip_crds: bool, +} diff --git a/rust/stackable-cockpit/src/platform/demo/spec.rs b/rust/stackable-cockpit/src/platform/demo/spec.rs index 96107d49..69f86af6 100644 --- a/rust/stackable-cockpit/src/platform/demo/spec.rs +++ b/rust/stackable-cockpit/src/platform/demo/spec.rs @@ -1,5 +1,6 @@ use serde::{Deserialize, Serialize}; use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_operator::kube::api::{ApiResource, GroupVersionKind}; use tracing::{Span, debug, info, instrument, warn}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(feature = "openapi")] @@ -9,13 +10,13 @@ use crate::{ common::manifest::ManifestSpec, platform::{ cluster::{ResourceRequests, ResourceRequestsError}, - demo::DemoInstallParameters, + demo::{DemoInstallParameters, DemoUninstallParameters}, manifests::{self, InstallManifestsExt}, release::ReleaseList, - stack::{self, StackInstallParameters, StackList}, + stack::{self, StackInstallParameters, StackList, StackSpec}, }, utils::{ - k8s::Client, + k8s::{self, Client}, params::{ IntoParameters, IntoParametersError, Parameter, RawParameter, RawParameterParseError, }, @@ -47,8 +48,18 @@ pub enum Error { #[snafu(display("failed to install stack"))] InstallStack { source: stack::Error }, + /// This error indicates that the release failed to uninstall. + #[snafu(display("failed to uninstall release"))] + UninstallRelease { source: stack::Error }, + #[snafu(display("failed to install stack manifests"))] InstallManifests { source: manifests::Error }, + + #[snafu(display("failed to uninstall Helm manifests"))] + UninstallHelmManifests { source: manifests::Error }, + + #[snafu(display("failed to delete object"))] + DeleteObject { source: k8s::Error }, } impl InstallManifestsExt for DemoSpec {} @@ -159,7 +170,6 @@ impl DemoSpec { labels: install_parameters.stack_labels.clone(), skip_release: install_parameters.skip_release, stack_name: self.stack.clone(), - demo_name: None, chart_source: install_parameters.chart_source.clone(), operator_values: install_parameters.operator_values.clone(), }; @@ -180,31 +190,136 @@ impl DemoSpec { } #[instrument(skip_all, fields( + demo_name = %uninstall_parameters.demo_name, + demo_namespace = %uninstall_parameters.demo_namespace, stack_name = %self.stack, - operator_namespace = %install_params.operator_namespace, - demo_namespace = %install_params.demo_namespace, + ))] + pub async fn uninstall( + &self, + release_list: ReleaseList, + uninstall_parameters: DemoUninstallParameters, + client: &Client, + transfer_client: &xfer::Client, + stack: StackSpec, + ) -> Result<(), Error> { + // Uninstall Helm Charts + let parameters = &mut Vec::new() + .into_params(self.parameters.clone()) + .context(ParseParametersSnafu)?; + + // We add the DEMO parameter, so that demos can use that to render e.g. the demo label + parameters.insert("DEMO".to_owned(), uninstall_parameters.demo_name.clone()); + + Self::uninstall_helm_manifests( + &self.manifests, + parameters, + &uninstall_parameters.demo_namespace.to_owned(), + transfer_client, + ) + .await + .context(UninstallHelmManifestsSnafu)?; + + let stack_parameters = &mut Vec::new() + .into_params(stack.parameters.clone()) + .context(ParseParametersSnafu)?; + + // We add the STACK parameter, so that stacks can use that to render e.g. the stack label + stack_parameters.insert("STACK".to_owned(), self.stack.clone()); + + Self::uninstall_helm_manifests( + &stack.manifests, + stack_parameters, + &uninstall_parameters.demo_namespace.to_owned(), + transfer_client, + ) + .await + .context(UninstallHelmManifestsSnafu)?; + + // Delete demo namespace + client + .delete_object( + &uninstall_parameters.demo_namespace, + &ApiResource::from_gvk(&GroupVersionKind { + group: "".to_owned(), + version: "v1".to_owned(), + kind: "Namespace".to_owned(), + }), + None, + ) + .await + .context(DeleteObjectSnafu)?; + + // Delete remaining objects not namespace scoped + client + .delete_all_objects_with_label( + "stackable.tech/demo", + &uninstall_parameters.demo_name, + None, + ) + .await + .context(DeleteObjectSnafu)?; + + // Delete operators and the operator namespace + if !uninstall_parameters.skip_operators { + stack + .uninstall_release(release_list, &uninstall_parameters.operator_namespace) + .await + .context(UninstallReleaseSnafu)?; + + client + .delete_object( + &uninstall_parameters.operator_namespace, + &ApiResource::from_gvk(&GroupVersionKind { + group: "".to_owned(), + version: "v1".to_owned(), + kind: "Namespace".to_owned(), + }), + None, + ) + .await + .context(DeleteObjectSnafu)?; + } + + // Delete CRDs + if !uninstall_parameters.skip_crds { + client + .delete_crds_with_group_suffix("stackable.tech") + .await + .context(DeleteObjectSnafu)?; + } + + Ok(()) + } + + #[instrument(skip_all, fields( + stack_name = %self.stack, + operator_namespace = %install_parameters.operator_namespace, + demo_namespace = %install_parameters.demo_namespace, indicatif.pb_show = true ))] async fn prepare_manifests( &self, - install_params: DemoInstallParameters, + install_parameters: DemoInstallParameters, client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing demo manifests"); Span::current().pb_set_message("Installing manifests"); - let params = install_params + let mut parameters = install_parameters .parameters .to_owned() .into_params(&self.parameters) .context(ParseParametersSnafu)?; + // We add the DEMO parameter, so that demos can use that to render e.g. the demo label + parameters.insert("DEMO".to_owned(), install_parameters.demo_name); + Self::install_manifests( &self.manifests, - ¶ms, - &install_params.demo_namespace, - install_params.labels, + ¶meters, + &install_parameters.demo_namespace, + install_parameters.labels, client, transfer_client, ) diff --git a/rust/stackable-cockpit/src/platform/manifests.rs b/rust/stackable-cockpit/src/platform/manifests.rs index 15fcf306..1a43d1d2 100644 --- a/rust/stackable-cockpit/src/platform/manifests.rs +++ b/rust/stackable-cockpit/src/platform/manifests.rs @@ -40,7 +40,7 @@ pub enum Error { repo_name: String, }, - /// This error indicates that the Hlm wrapper failed to install the Helm + /// This error indicates that the Helm wrapper failed to install the Helm /// release. #[snafu(display("failed to install Helm release {release_name}"))] InstallHelmRelease { @@ -48,6 +48,14 @@ pub enum Error { source: helm::Error, }, + /// This error indicates that the Helm wrapper failed to uninstall the Helm + /// release. + #[snafu(display("failed to uninstall Helm chart"))] + UninstallHelmRelease { + release_name: String, + source: helm::Error, + }, + /// This error indicates that Helm chart options could not be serialized /// into YAML. #[snafu(display("failed to serialize Helm chart options"))] @@ -86,24 +94,12 @@ pub trait InstallManifestsExt { for manifest in manifests { let parameters = parameters.clone(); - let labels = labels.clone(); match manifest { ManifestSpec::HelmChart(helm_file) => { debug!(helm_file, "Installing manifest from Helm chart"); - // Read Helm chart YAML and apply templating - let helm_file = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { - path_or_url: helm_file.clone(), - })?; - - let helm_chart: helm::Chart = transfer_client - .get( - &helm_file, - &Template::new(¶meters).then(Yaml::default()), - ) - .await - .context(FileTransferSnafu)?; + let helm_chart = get_helmchart(helm_file, transfer_client, ¶meters).await?; info!(helm_chart.name, helm_chart.version, "Installing Helm chart",); @@ -162,4 +158,65 @@ pub trait InstallManifestsExt { Ok(()) } + + #[instrument(skip_all, fields(%namespace, indicatif.pb_show = true))] + #[allow(async_fn_in_trait)] + async fn uninstall_helm_manifests( + manifests: &[ManifestSpec], + parameters: &mut HashMap, + namespace: &str, + transfer_client: &xfer::Client, + ) -> Result<(), Error> { + debug!("Uninstalling Helm manifests"); + Span::current().pb_set_message("Uninstalling Helm charts"); + + // We add the NAMESPACE parameter, so that stacks/demos can use that to render e.g. the + // fqdn service names [which contain the namespace]. + parameters.insert("NAMESPACE".to_owned(), namespace.to_owned()); + + for manifest in manifests { + match manifest { + ManifestSpec::HelmChart(helm_file) => { + debug!(helm_file, "Uninstalling manifest from Helm chart"); + + let helm_chart = get_helmchart(helm_file, transfer_client, parameters).await?; + + info!( + helm_chart.name, + helm_chart.version, "Uninstalling Helm chart", + ); + + helm::uninstall_release(&helm_chart.release_name, namespace, true).context( + UninstallHelmReleaseSnafu { + release_name: &helm_chart.release_name, + }, + )?; + } + ManifestSpec::PlainYaml(_) => {} + } + } + + Ok(()) + } +} + +pub async fn get_helmchart( + helm_file: &str, + transfer_client: &xfer::Client, + parameters: &HashMap, +) -> Result { + // Read Helm chart YAML and apply templating + let helm_file_location = helm_file.into_path_or_url().context(ParsePathOrUrlSnafu { + path_or_url: helm_file, + })?; + + let helmchart = transfer_client + .get( + &helm_file_location, + &Template::new(parameters).then(Yaml::default()), + ) + .await + .context(FileTransferSnafu)?; + + Ok(helmchart) } diff --git a/rust/stackable-cockpit/src/platform/stack/params.rs b/rust/stackable-cockpit/src/platform/stack/params.rs index 0688eba2..500b9c72 100644 --- a/rust/stackable-cockpit/src/platform/stack/params.rs +++ b/rust/stackable-cockpit/src/platform/stack/params.rs @@ -5,7 +5,6 @@ use crate::platform::operator::ChartSourceType; #[derive(Debug)] pub struct StackInstallParameters { - pub demo_name: Option, pub stack_name: String, pub operator_namespace: String, @@ -17,3 +16,13 @@ pub struct StackInstallParameters { pub chart_source: ChartSourceType, pub operator_values: Mapping, } + +pub struct StackUninstallParameters { + pub stack_name: String, + + pub operator_namespace: String, + pub stack_namespace: String, + + pub skip_operators: bool, + pub skip_crds: bool, +} diff --git a/rust/stackable-cockpit/src/platform/stack/spec.rs b/rust/stackable-cockpit/src/platform/stack/spec.rs index 2bb39d62..b3260323 100644 --- a/rust/stackable-cockpit/src/platform/stack/spec.rs +++ b/rust/stackable-cockpit/src/platform/stack/spec.rs @@ -1,6 +1,7 @@ use serde::{Deserialize, Serialize}; use serde_yaml::Mapping; use snafu::{OptionExt, ResultExt, Snafu}; +use stackable_operator::kube::api::{ApiResource, GroupVersionKind}; use tracing::{Span, debug, info, instrument, log::warn}; use tracing_indicatif::span_ext::IndicatifSpanExt as _; #[cfg(feature = "openapi")] @@ -14,10 +15,10 @@ use crate::{ namespace, operator::ChartSourceType, release, - stack::StackInstallParameters, + stack::{StackInstallParameters, StackUninstallParameters}, }, utils::{ - k8s::Client, + k8s::{self, Client}, params::{ IntoParameters, IntoParametersError, Parameter, RawParameter, RawParameterParseError, }, @@ -45,6 +46,10 @@ pub enum Error { #[snafu(display("failed to install release"))] InstallRelease { source: release::Error }, + /// This error indicates that the release failed to uninstall. + #[snafu(display("failed to uninstall release"))] + UninstallRelease { source: release::Error }, + #[snafu(display("stack resource requests error"), context(false))] StackResourceRequests { source: ResourceRequestsError }, @@ -64,6 +69,12 @@ pub enum Error { #[snafu(display("failed to install stack manifests"))] InstallManifests { source: manifests::Error }, + + #[snafu(display("failed to uninstall Helm manifests"))] + UninstallHelmManifests { source: manifests::Error }, + + #[snafu(display("failed to delete object"))] + DeleteObject { source: k8s::Error }, } /// This struct describes a stack with the v2 spec @@ -71,7 +82,7 @@ pub enum Error { #[serde(rename_all = "camelCase")] #[cfg_attr(feature = "openapi", derive(ToSchema))] pub struct StackSpec { - /// A short description of the demo + /// A short description of the stack pub description: String, /// The release used by the stack, e.g. 23.4 @@ -150,10 +161,7 @@ impl StackSpec { // TODO (Techassi): Can we get rid of the release list and just use the release spec instead #[instrument(skip_all, fields( stack_name = %install_parameters.stack_name, - // NOTE (@NickLarsenNZ): Option doesn't impl Display, so we need to call - // display for the inner type if it exists. Otherwise we gte the Debug - // impl for the whole Option. - demo_name = install_parameters.demo_name.as_ref().map(tracing::field::display), + stack_namespace = %install_parameters.stack_namespace, ))] pub async fn install( &self, @@ -177,7 +185,6 @@ impl StackSpec { self.install_release( release_list, &install_parameters.operator_namespace, - &install_parameters.stack_namespace, &install_parameters.chart_source, &install_parameters.operator_values, ) @@ -197,12 +204,93 @@ impl StackSpec { .await } + #[instrument(skip_all, fields( + stack_name = %uninstall_parameters.stack_name, + stack_namespace = %uninstall_parameters.stack_namespace, + ))] + pub async fn uninstall( + &self, + release_list: release::ReleaseList, + uninstall_parameters: StackUninstallParameters, + client: &Client, + transfer_client: &xfer::Client, + ) -> Result<(), Error> { + // Uninstall Helm Charts + let parameters = &mut Vec::new() + .into_params(self.parameters.clone()) + .context(ParseParametersSnafu)?; + + // We add the STACK parameter, so that stacks can use that to render e.g. the stack label + parameters.insert("STACK".to_owned(), uninstall_parameters.stack_name.clone()); + + Self::uninstall_helm_manifests( + &self.manifests, + parameters, + &uninstall_parameters.stack_namespace.to_owned(), + transfer_client, + ) + .await + .context(UninstallHelmManifestsSnafu)?; + + // Delete stack namespace + client + .delete_object( + &uninstall_parameters.stack_namespace, + &ApiResource::from_gvk(&GroupVersionKind { + group: "".to_owned(), + version: "v1".to_owned(), + kind: "Namespace".to_owned(), + }), + None, + ) + .await + .context(DeleteObjectSnafu)?; + + // Delete remaining objects not namespace scoped + client + .delete_all_objects_with_label( + "stackable.tech/stack", + &uninstall_parameters.stack_name, + None, + ) + .await + .context(DeleteObjectSnafu)?; + + // Delete operators and the operator namespace + if !uninstall_parameters.skip_operators { + self.uninstall_release(release_list, &uninstall_parameters.operator_namespace) + .await?; + + client + .delete_object( + &uninstall_parameters.operator_namespace, + &ApiResource::from_gvk(&GroupVersionKind { + group: "".to_owned(), + version: "v1".to_owned(), + kind: "Namespace".to_owned(), + }), + None, + ) + .await + .context(DeleteObjectSnafu)?; + } + + // Delete CRDs + if !uninstall_parameters.skip_crds { + client + .delete_crds_with_group_suffix("stackable.tech") + .await + .context(DeleteObjectSnafu)?; + } + + Ok(()) + } + #[instrument(skip_all, fields(release = %self.release, %operator_namespace, indicatif.pb_show = true))] pub async fn install_release( &self, release_list: release::ReleaseList, operator_namespace: &str, - _namespace: &str, // TODO (@NickLarsenNZ): remove this field chart_source: &ChartSourceType, operator_values: &Mapping, ) -> Result<(), Error> { @@ -229,27 +317,52 @@ impl StackSpec { .context(InstallReleaseSnafu) } + #[instrument(skip_all, fields(release = %self.release, %operator_namespace, indicatif.pb_show = true))] + pub async fn uninstall_release( + &self, + release_list: release::ReleaseList, + operator_namespace: &str, + ) -> Result<(), Error> { + info!(self.release, "Trying to uninstall release"); + Span::current().pb_set_message("Uninstalling operators"); + + // Get the release by name + let release = release_list + .get(&self.release) + .context(NoSuchReleaseSnafu { + name: self.release.clone(), + })?; + + // Uninstall the release + release + .uninstall(&self.operators, &[], operator_namespace) + .context(UninstallReleaseSnafu) + } + #[instrument(skip_all, fields(indicatif.pb_show = true))] pub async fn prepare_manifests( &self, - install_params: StackInstallParameters, + install_parameters: StackInstallParameters, client: &Client, transfer_client: &xfer::Client, ) -> Result<(), Error> { info!("Installing stack manifests"); Span::current().pb_set_message("Installing manifests"); - let parameters = install_params + let mut parameters = install_parameters .parameters .to_owned() .into_params(&self.parameters) .context(ParseParametersSnafu)?; + // We add the STACK parameter, so that stacks can use that to render e.g. the stack label + parameters.insert("STACK".to_owned(), install_parameters.stack_name); + Self::install_manifests( &self.manifests, ¶meters, - &install_params.stack_namespace, - install_params.labels, + &install_parameters.stack_namespace, + install_parameters.labels, client, transfer_client, ) diff --git a/rust/stackable-cockpit/src/utils/k8s/client.rs b/rust/stackable-cockpit/src/utils/k8s/client.rs index 6fb44d6f..330f293b 100644 --- a/rust/stackable-cockpit/src/utils/k8s/client.rs +++ b/rust/stackable-cockpit/src/utils/k8s/client.rs @@ -1,22 +1,29 @@ use std::{collections::BTreeMap, string::FromUtf8Error}; +use reqwest::StatusCode; use serde::Deserialize; use snafu::{OptionExt, ResultExt, Snafu}; use stackable_operator::{ crd::listener::v1alpha1::Listener, - k8s_openapi::api::{ - apps::v1::{Deployment, StatefulSet}, - core::v1::{Endpoints, Namespace, Node, Secret, Service}, + k8s_openapi::{ + api::{ + apps::v1::{Deployment, StatefulSet}, + core::v1::{Endpoints, Namespace, Node, Secret, Service}, + }, + apiextensions_apiserver::pkg::apis::apiextensions::v1::CustomResourceDefinition, }, kube::{ self, Api, Discovery, ResourceExt, - api::{ListParams, Patch, PatchParams, PostParams}, + api::{DeleteParams, ListParams, Patch, PatchParams, PostParams}, core::{DynamicObject, GroupVersionKind, ObjectList, ObjectMeta, TypeMeta}, - discovery::{ApiCapabilities, ApiResource, Scope}, + discovery::{self, ApiCapabilities, ApiResource, Scope}, }, kvp::Labels, }; -use tokio::sync::RwLock; +use tokio::{ + sync::RwLock, + time::{self, sleep}, +}; use tracing::{Span, info, instrument}; use tracing_indicatif::{indicatif_eprintln, span_ext::IndicatifSpanExt as _}; @@ -47,6 +54,9 @@ pub enum Error { gvk: GroupVersionKind, }, + #[snafu(display("failed to delete object"))] + KubeClientDelete { source: kube::error::Error }, + #[snafu(display("failed to deserialize YAML data"))] DeserializeYaml { source: serde_yaml::Error }, @@ -237,6 +247,28 @@ impl Client { Ok(()) } + /// Deletes CRDs for the given group suffix + pub async fn delete_crds_with_group_suffix(&self, group_suffix: &str) -> Result<()> { + let api_client = Api::::all(self.client.clone()); + + for crd in api_client + .list(&ListParams::default()) + .await + .context(KubeClientFetchSnafu)? + { + if crd.spec.group.ends_with(group_suffix) { + if let Some(name) = crd.metadata.name { + api_client + .delete(&name, &DeleteParams::default()) + .await + .context(KubeClientDeleteSnafu)?; + } + } + } + + Ok(()) + } + /// Lists objects by looking up a GVK via the discovery. It returns an /// optional list of dynamic objects. The method returns `Ok(None)` /// if the client was unable to resolve the GVK. An error is returned @@ -287,6 +319,116 @@ impl Client { )) } + /// Deletes all objects with a given label in the provided namespace. + /// If no namespace is provided, deletes all clusterwide objects with the given label. + pub async fn delete_all_objects_with_label( + &self, + label_key: &str, + label_value: &str, + namespace: Option<&str>, + ) -> Result<(), Error> { + let api_resources = self + .get_api_resources() + .await + .into_iter() + .filter(|(_, capability)| { + capability.supports_operation(discovery::verbs::LIST) + && match namespace { + Some(_) => capability.scope == kube::discovery::Scope::Namespaced, + None => capability.scope == kube::discovery::Scope::Cluster, + } + }); + + for (api_resource, _) in api_resources { + let objects = self + .list_objects( + &GroupVersionKind { + group: api_resource.group.clone(), + version: api_resource.version.clone(), + kind: api_resource.kind.clone(), + }, + namespace, + ) + .await?; + + if let Some(objectlist) = objects { + for object in objectlist { + if let Some(value) = object.labels().get(label_key) { + if value.eq(label_value) { + self.delete_object( + &object.metadata.name.unwrap(), + &api_resource, + object.metadata.namespace.as_deref(), + ) + .await?; + } + } + } + } + } + + Ok(()) + } + + #[instrument(skip_all, fields(indicatif.pb_show = true))] + pub async fn delete_object( + &self, + object_name: &str, + api_resource: &ApiResource, + namespace: Option<&str>, + ) -> Result<(), Error> { + let object_api = match namespace { + Some(namespace) => { + Api::::namespaced_with(self.client.clone(), namespace, api_resource) + } + None => Api::::all_with(self.client.clone(), api_resource), + }; + + let mut delete_request = object_api + .delete(object_name, &DeleteParams::foreground()) + .await; + + // Wait for object to be deleted + // Otherwise might result in race condition scenarios + while let Ok(delete_status) = delete_request { + match delete_status { + // Left side of Either, when deletion is in progress + either::Either::Left(_) => { + Span::current() + .pb_set_message(&format!("Deleting {} {}", api_resource.kind, object_name)); + // Short sleep to reduce number of requests + sleep(time::Duration::from_millis(600)).await; + // Resend request to get deletion status + delete_request = object_api + .delete(object_name, &DeleteParams::foreground()) + .await; + } + // Right side of Either, when deletion is done + either::Either::Right(_) => { + return Ok(()); + } + } + } + + if let Err(error) = delete_request { + match error { + kube::Error::Api(ref error_response) => { + // If object is already deleted/gone, delete operation is done + if error_response.code == StatusCode::NOT_FOUND.as_u16() { + return Ok(()); + } else { + return Err(error).context(KubeClientDeleteSnafu); + } + } + _ => { + return Err(error).context(KubeClientDeleteSnafu); + } + } + } + + Ok(()) + } + /// Lists [`Service`]s by matching labels. The Services can be matched by /// the product labels. [`ListParamsExt`] provides a utility function to /// create [`ListParams`] based on a product name and optional instance @@ -482,6 +624,16 @@ impl Client { endpoints_api.get(name).await.context(KubeClientFetchSnafu) } + pub async fn get_api_resources(&self) -> Vec<(ApiResource, ApiCapabilities)> { + let mut api_resources = Vec::new(); + + for group in self.discovery.read().await.groups() { + api_resources.append(group.recommended_resources().as_mut()); + } + + api_resources + } + /// Try to resolve the given [`GroupVersionKind`]. In case the resolution fails a discovery is run to pull in new /// GVKs that are not present in the [`Discovery`] cache. Afterwards a normal resolution is issued. async fn resolve_gvk( diff --git a/rust/stackablectl/CHANGELOG.md b/rust/stackablectl/CHANGELOG.md index 989981b9..6f76d624 100644 --- a/rust/stackablectl/CHANGELOG.md +++ b/rust/stackablectl/CHANGELOG.md @@ -4,12 +4,17 @@ All notable changes to this project will be documented in this file. ## [Unreleased] +### Added + +- Add `uninstall` subcommand for `demo`/`stack` commands ([#429]). + ### Changed - Bump Rust to `1.93.0` as well as dependencies ([#426]). - Bump Go to `1.26.0` as well as dependencies ([#426]). [#426]: https://github.com/stackabletech/stackable-cockpit/pull/426 +[#429]: https://github.com/stackabletech/stackable-cockpit/pull/429 ## [1.2.2] - 2025-12-03 diff --git a/rust/stackablectl/Cargo.toml b/rust/stackablectl/Cargo.toml index da0e47d7..29dcead3 100644 --- a/rust/stackablectl/Cargo.toml +++ b/rust/stackablectl/Cargo.toml @@ -17,6 +17,7 @@ clap_complete.workspace = true clap_complete_nushell.workspace = true clap.workspace = true comfy-table.workspace = true +dialoguer.workspace = true directories.workspace = true dotenvy.workspace = true indexmap.workspace = true diff --git a/rust/stackablectl/src/cmds/demo.rs b/rust/stackablectl/src/cmds/demo.rs index 251a94fe..b05d059d 100644 --- a/rust/stackablectl/src/cmds/demo.rs +++ b/rust/stackablectl/src/cmds/demo.rs @@ -5,12 +5,13 @@ use comfy_table::{ ContentArrangement, Row, Table, presets::{NOTHING, UTF8_FULL}, }; +use dialoguer::Confirm; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, constants::{DEFAULT_NAMESPACE, DEFAULT_OPERATOR_NAMESPACE}, platform::{ - demo::{self, DemoInstallParameters}, + demo::{self, DemoInstallParameters, DemoUninstallParameters}, operator::ChartSourceType, release, stack, }, @@ -22,7 +23,7 @@ use stackable_cockpit::{ }; use stackable_operator::kvp::{LabelError, Labels}; use tracing::{Span, debug, info, instrument}; -use tracing_indicatif::span_ext::IndicatifSpanExt as _; +use tracing_indicatif::{self, span_ext::IndicatifSpanExt as _}; use crate::{ args::{CommonClusterArgs, CommonClusterArgsError, CommonNamespaceArgs}, @@ -53,6 +54,11 @@ pub enum DemoCommands { /// Install a specific demo #[command(aliases(["i", "in"]))] Install(DemoInstallArgs), + + /// Uninstall a specific stack. Caution: This will delete the provided stack namespace, + /// the operators and provided operator namespace, and all Stackable CRDs + #[command(aliases(["u", "un"]))] + Uninstall(DemoUninstallArgs), } #[derive(Debug, Args)] @@ -118,7 +124,17 @@ to specify operator versions." } #[derive(Debug, Args)] -pub struct DemoUninstallArgs {} +pub struct DemoUninstallArgs { + /// Demo to uninstall + demo_name: String, + + #[command(flatten)] + namespaces: CommonNamespaceArgs, + + /// Skip uninstalling Stackable operators and CRDs + #[arg(long)] + skip_operators_and_crds: bool, +} #[derive(Debug, Snafu)] pub enum CmdError { @@ -155,6 +171,15 @@ pub enum CmdError { demo_name: String, }, + #[snafu(display("failed to confirm user input"))] + ConfirmDialog { source: dialoguer::Error }, + + #[snafu(display("failed to uninstall demo {demo_name:?}"))] + UninstallDemo { + source: demo::Error, + demo_name: String, + }, + #[snafu(display("failed to build labels for demo resources"))] BuildLabels { source: LabelError }, @@ -214,6 +239,9 @@ impl DemoArgs { DemoCommands::Install(args) => { install_cmd(args, cli, list, &transfer_client, &release_branch).await } + DemoCommands::Uninstall(args) => { + uninstall_cmd(args, cli, list, &transfer_client, &release_branch).await + } } } } @@ -338,7 +366,7 @@ async fn install_cmd( release_branch: &str, ) -> Result { info!(demo_name = %args.demo_name, "Installing demo"); - Span::current().pb_set_message("Installing demo"); + Span::current().pb_set_message(&format!("Installing demo {}", args.demo_name)); // Init result output and progress output let mut output = Cli::result(); @@ -382,14 +410,42 @@ async fn install_cmd( .parse_insert(("stackable.tech/stack", &demo.stack)) .context(BuildLabelsSnafu)?; + // `stackablectl demo uninstall` relies on namespace deletion, suggest installing in a non-default namespace + // It should still be possible to skip that if either uninstall is not needed + // or installing an older version of the demo which only supports the 'default' namespace + let demo_namespace = tracing_indicatif::suspend_tracing_indicatif( + || -> Result { + if args.namespaces.namespace == DEFAULT_NAMESPACE { + if Confirm::new() + .with_prompt( + format!( + "Demos installed in the '{DEFAULT_NAMESPACE}' namespace cannot be deleted with stackablectl. Install the demo in the '{demo_namespace}' namespace instead?", + demo_namespace = args.demo_name.clone()) + ) + .default(true) + .interact() + .context(ConfirmDialogSnafu)? { + // User selected to install in suggested namespace + Ok(args.demo_name.clone()) + } else { + // User selected to install in default namespace + Ok(args.namespaces.namespace.clone()) + } + } else { + Ok(args.namespaces.namespace.clone()) + } + }, + )?; + let values_file = cli.get_values_file().context(PathOrUrlParseSnafu)?; let operator_values = load_operator_values(values_file.as_ref(), transfer_client) .await .context(LoadOperatorValuesSnafu)?; let install_parameters = DemoInstallParameters { + demo_name: args.demo_name.clone(), operator_namespace: args.namespaces.operator_namespace.clone(), - demo_namespace: args.namespaces.namespace.clone(), + demo_namespace: demo_namespace.clone(), stack_parameters: args.stack_parameters.clone(), parameters: args.parameters.clone(), skip_release: args.skip_release, @@ -425,11 +481,8 @@ async fn install_cmd( let stacklet_cmd = format!( "stackablectl stacklet list{option}", - option = if args.namespaces.namespace != DEFAULT_NAMESPACE { - format!( - " --namespace {namespace}", - namespace = args.namespaces.namespace - ) + option = if demo_namespace != DEFAULT_NAMESPACE { + format!(" --namespace {namespace}", namespace = demo_namespace) } else { "".into() } @@ -445,3 +498,70 @@ async fn install_cmd( Ok(output.render()) } + +#[instrument(skip_all, fields( + demo_name = %args.demo_name, + %release_branch, + indicatif.pb_show = true +))] +async fn uninstall_cmd( + args: &DemoUninstallArgs, + cli: &Cli, + list: demo::List, + transfer_client: &xfer::Client, + release_branch: &str, +) -> Result { + info!(demo_name = %args.demo_name, "Uninstalling demo"); + Span::current().pb_set_message(&format!("Uninstalling demo {}", args.demo_name)); + + // Init result output and progress output + let mut output = Cli::result(); + + let demo = list.get(&args.demo_name).ok_or(CmdError::NoSuchDemo { + name: args.demo_name.clone(), + })?; + + let stack_files = cli + .get_stack_files(release_branch) + .context(PathOrUrlParseSnafu)?; + let stack_list = stack::StackList::build(&stack_files, transfer_client) + .await + .context(BuildListSnafu)?; + + // Get the stack spec based on the name defined in the demo spec + let stack = stack_list.get(&demo.stack).context(NoSuchStackSnafu { + name: demo.stack.clone(), + })?; + + let client = Client::new().await.context(KubeClientCreateSnafu)?; + + let release_files = cli.get_release_files().context(PathOrUrlParseSnafu)?; + let release_list = release::ReleaseList::build(&release_files, transfer_client) + .await + .context(BuildListSnafu)?; + + demo.uninstall( + release_list, + DemoUninstallParameters { + demo_name: args.demo_name.clone(), + operator_namespace: args.namespaces.operator_namespace.clone(), + demo_namespace: args.namespaces.namespace.clone(), + skip_operators: args.skip_operators_and_crds, + skip_crds: args.skip_operators_and_crds, + }, + &client, + transfer_client, + stack.to_owned(), + ) + .await + .context(UninstallDemoSnafu { + demo_name: args.demo_name.clone(), + })?; + + output.with_output(format!( + "Uninstalled demo {demo_name:?}", + demo_name = args.demo_name + )); + + Ok(output.render()) +} diff --git a/rust/stackablectl/src/cmds/stack.rs b/rust/stackablectl/src/cmds/stack.rs index f4045f9a..0c371bf0 100644 --- a/rust/stackablectl/src/cmds/stack.rs +++ b/rust/stackablectl/src/cmds/stack.rs @@ -5,6 +5,7 @@ use comfy_table::{ ContentArrangement, Table, presets::{NOTHING, UTF8_FULL}, }; +use dialoguer::Confirm; use snafu::{OptionExt as _, ResultExt, Snafu, ensure}; use stackable_cockpit::{ common::list, @@ -12,7 +13,7 @@ use stackable_cockpit::{ platform::{ operator::ChartSourceType, release, - stack::{self, StackInstallParameters}, + stack::{self, StackInstallParameters, StackUninstallParameters}, }, utils::{ k8s::{self, Client}, @@ -53,6 +54,11 @@ pub enum StackCommands { /// Install a specific stack #[command(aliases(["i", "in"]))] Install(StackInstallArgs), + + /// Uninstall a specific stack. Caution: This will delete the provided stack namespace, + /// the operators and provided operator namespace, and all Stackable CRDs + #[command(aliases(["u", "un"]))] + Uninstall(StackUninstallArgs), } #[derive(Debug, Args)] @@ -72,7 +78,7 @@ pub struct StackDescribeArgs { #[derive(Debug, Args)] pub struct StackInstallArgs { - /// Name of the stack to describe + /// Name of the stack to install stack_name: String, /// Skip the installation of the release during the stack install process @@ -113,6 +119,19 @@ Use \"stackablectl stack describe \" to list available parameters for eac namespaces: CommonNamespaceArgs, } +#[derive(Debug, Args)] +pub struct StackUninstallArgs { + /// Name of the stack to uninstall + stack_name: String, + + #[command(flatten)] + namespaces: CommonNamespaceArgs, + + /// Skip uninstalling Stackable operators and CRDs + #[arg(long)] + skip_operators_and_crds: bool, +} + #[derive(Debug, Snafu)] pub enum CmdError { #[snafu(display("path/url parse error"))] @@ -143,6 +162,16 @@ pub enum CmdError { stack_name: String, }, + #[snafu(display("failed to confirm user input"))] + ConfirmDialog { source: dialoguer::Error }, + + #[snafu(display("failed to uninstall stack {stack_name:?}"))] + UninstallStack { + #[snafu(source(from(stack::Error, Box::new)))] + source: Box, + stack_name: String, + }, + #[snafu(display("failed to build labels for stack resources"))] BuildLabels { source: LabelError }, @@ -201,6 +230,9 @@ impl StackArgs { StackCommands::Install(args) => { install_cmd(args, cli, stack_list, &transfer_client).await } + StackCommands::Uninstall(args) => { + uninstall_cmd(args, cli, stack_list, &transfer_client).await + } } } } @@ -325,7 +357,7 @@ async fn install_cmd( transfer_client: &xfer::Client, ) -> Result { info!(stack_name = %args.stack_name, "Installing stack"); - Span::current().pb_set_message("Installing stack"); + Span::current().pb_set_message(&format!("Installing stack {}", args.stack_name)); let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; let release_list = release::ReleaseList::build(&files, transfer_client) @@ -353,6 +385,33 @@ async fn install_cmd( ]) .context(BuildLabelsSnafu)?; + // `stackablectl stack uninstall` relies on namespace deletion, suggest installing in a non-default namespace + // It should still be possible to skip that if either uninstall is not needed + // or installing an older version of the stack which only supports the 'default' namespace + let stack_namespace = tracing_indicatif::suspend_tracing_indicatif( + || -> Result { + if args.namespaces.namespace == DEFAULT_NAMESPACE { + if Confirm::new() + .with_prompt( + format!( + "Stacks installed in the '{DEFAULT_NAMESPACE}' namespace cannot be deleted with stackablectl. Install the stack in the '{stack_namespace}' namespace instead?", + stack_namespace = args.stack_name.clone()) + ) + .default(true) + .interact() + .context(ConfirmDialogSnafu)? { + // User selected to install in suggested namespace + Ok(args.stack_name.clone()) + } else { + // User selected to install in default namespace + Ok(args.namespaces.namespace.clone()) + } + } else { + Ok(args.namespaces.namespace.clone()) + } + }, + )?; + let values_file = cli.get_values_file().context(PathOrUrlParseSnafu)?; let operator_values = load_operator_values(values_file.as_ref(), transfer_client) .await @@ -360,11 +419,10 @@ async fn install_cmd( let install_parameters = StackInstallParameters { operator_namespace: args.namespaces.operator_namespace.clone(), - stack_namespace: args.namespaces.namespace.clone(), - stack_name: args.stack_name.clone(), + stack_namespace: stack_namespace.clone(), + stack_name: stack_namespace.clone(), parameters: args.parameters.clone(), skip_release: args.skip_release, - demo_name: None, labels, chart_source: ChartSourceType::from(cli.chart_type()), operator_values, @@ -391,11 +449,8 @@ async fn install_cmd( let stacklet_cmd = format!( "stackablectl stacklet list{option}", - option = if args.namespaces.namespace != DEFAULT_NAMESPACE { - format!( - " --namespace {namespace}", - namespace = args.namespaces.namespace - ) + option = if stack_namespace != DEFAULT_NAMESPACE { + format!(" --namespace {namespace}", namespace = stack_namespace) } else { "".into() } @@ -414,3 +469,52 @@ async fn install_cmd( None => Ok("No such stack".into()), } } + +#[instrument(skip(cli, stack_list, transfer_client), fields(indicatif.pb_show = true))] +async fn uninstall_cmd( + args: &StackUninstallArgs, + cli: &Cli, + stack_list: stack::StackList, + transfer_client: &xfer::Client, +) -> Result { + info!(stack_name = %args.stack_name, "Uninstalling stack"); + Span::current().pb_set_message(&format!("Uninstalling stack {}", args.stack_name)); + + match stack_list.get(&args.stack_name) { + Some(stack) => { + let mut output = Cli::result(); + let client = Client::new().await.context(KubeClientCreateSnafu)?; + + let files = cli.get_release_files().context(PathOrUrlParseSnafu)?; + let release_list = release::ReleaseList::build(&files, transfer_client) + .await + .context(BuildListSnafu)?; + + stack + .uninstall( + release_list, + StackUninstallParameters { + stack_name: args.stack_name.clone(), + operator_namespace: args.namespaces.operator_namespace.clone(), + stack_namespace: args.namespaces.namespace.clone(), + skip_operators: args.skip_operators_and_crds, + skip_crds: args.skip_operators_and_crds, + }, + &client, + transfer_client, + ) + .await + .context(UninstallStackSnafu { + stack_name: args.stack_name.clone(), + })?; + + output.with_output(format!( + "Uninstalled stack {stack_name:?}", + stack_name = args.stack_name + )); + + Ok(output.render()) + } + None => Ok("No such stack".into()), + } +}