File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change 3333
3434Options:
3535 -n, --namespace='': If present, the namespace scope for this CLI request
36+ --dry-run: If true, only print the object that would be pruned, without deleting it.
3637 -h, --help: Display this help
3738```
3839
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ function usage() {
1616 echo " "
1717 echo " Options:"
1818 echo " -n, --namespace='': If present, the namespace scope for this CLI request"
19+ echo " --dry-run: If true, only print the object that would be pruned, without deleting it."
1920 echo " -h, --help: Display this help"
2021 exit 0
2122}
2627fi
2728
2829resource=$1
30+ dry_run=" false"
2931
3032while test $# -gt 1
3133do
4042 fi
4143 shift
4244 ;;
45+ --dry-run)
46+ dry_run=" true"
47+ shift
48+ ;;
4349 -h|--help)
4450 usage
4551 ;;
@@ -138,14 +144,12 @@ then
138144 exit 0
139145fi
140146
141- echo " About to delete the following $resource : ${resource_name_list} "
142-
143- # confirmation prompt
144- read -p " Delete listed resource(s)? [yes/no]: " -r
145- if [[ $REPLY =~ ^[Yy]es$ ]]
146- then
147- for resource_name in $resource_name_list
148- do
147+ for resource_name in $resource_name_list
148+ do
149+ if [ " $dry_run " == " true" ]
150+ then
151+ echo " ${resource} ${resource_name} deleted (dry run)"
152+ else
149153 kubectl delete $resource $resource_name $namespace_arg
150- done
151- fi
154+ fi
155+ done
You can’t perform that action at this time.
0 commit comments