Skip to content

Commit

Permalink
Add confirmation to delete Che server (#506)
Browse files Browse the repository at this point in the history
Signed-off-by: Anatoliy Bazko <[email protected]>
  • Loading branch information
tolusha authored Feb 13, 2020
1 parent 7812791 commit 1c21d6c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ EXAMPLES
$ chectl autocomplete --refresh-cache
```

_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.1.4/src/commands/autocomplete/index.ts)_
_See code: [@oclif/plugin-autocomplete](https://github.com/oclif/plugin-autocomplete/blob/v0.1.5/src/commands/autocomplete/index.ts)_

## `chectl devfile:generate`

Expand Down Expand Up @@ -167,7 +167,7 @@ OPTIONS
--all see all commands in CLI
```

_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.1/src/commands/help.ts)_
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v2.2.3/src/commands/help.ts)_

## `chectl server:debug`

Expand Down Expand Up @@ -205,6 +205,8 @@ OPTIONS
be deployed
--listr-renderer=default|silent|verbose [default: default] Listr renderer
--skip-deletion-check Skip user confirmation on deletion check
```

_See code: [src/commands/server/delete.ts](https://github.com/che-incubator/chectl/blob/v0.0.2/src/commands/server/delete.ts)_
Expand Down
22 changes: 21 additions & 1 deletion src/commands/server/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/

import { KubeConfig } from '@kubernetes/client-node'
import { Command, flags } from '@oclif/command'
import { boolean } from '@oclif/command/lib/flags'
import { cli } from 'cli-ux'
import * as Listrq from 'listr'

import { cheNamespace, listrRenderer } from '../../common-flags'
Expand All @@ -24,7 +27,11 @@ export default class Delete extends Command {
static flags = {
help: flags.help({ char: 'h' }),
chenamespace: cheNamespace,
'listr-renderer': listrRenderer
'listr-renderer': listrRenderer,
'skip-deletion-check': boolean({
description: 'Skip user confirmation on deletion check',
default: false
}),
}

async run() {
Expand All @@ -48,6 +55,19 @@ export default class Delete extends Command {
tasks.add(helmTasks.deleteTasks(flags))
tasks.add(msAddonTasks.deleteTasks(flags))

const kc = new KubeConfig()
kc.loadFromDefault()

const cluster = kc.getCurrentCluster()
const context = kc.getContextObject(kc.getCurrentContext())

if (!flags['skip-deletion-check']) {
const confirmed = await cli.confirm(`You're going to remove Eclipse Che server in namespace '${context ? context.namespace : ''}' on server '${cluster ? cluster.server : ''}'. If you want to continue - press Y`)
if (!confirmed) {
this.exit(0)
}
}

await tasks.run()

notifier.notify({
Expand Down
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1676,11 +1676,11 @@ ecc-jsbn@~0.1.1:

"eclipse-che-operator@git://github.com/eclipse/che-operator#master":
version "0.0.0"
resolved "git://github.com/eclipse/che-operator#29198304be0cb89d823b725fba72eafb78d9fd9a"
resolved "git://github.com/eclipse/che-operator#41f00fff311ce341623d1682ac349a0d0d1826e5"

"eclipse-che@git://github.com/eclipse/che#master":
version "0.0.0"
resolved "git://github.com/eclipse/che#95754848f677f735203b75d517e26cde12dd14cf"
resolved "git://github.com/eclipse/che#980379f3865dc339fd22c8aeaa8785c70012fd37"

editorconfig@^0.15.0:
version "0.15.3"
Expand Down

0 comments on commit 1c21d6c

Please sign in to comment.