Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions oks_cli/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,21 @@ def setup_worker_pool(ctx, nodepool_name, count, vmtype, zone, output, dry_run,

@nodepool.command('delete')
@click.option('--nodepool-name', '-n', required=True, help="Nodepool Name")
@click.option('--force', is_flag=True, help="Delete without confirmation")
@click.pass_context
def delete_worker_pool(ctx, nodepool_name):
def delete_worker_pool(ctx, nodepool_name, force):
"""Delete a nodepool by name from the cluster."""
_run_kubectl(ctx.obj['project_id'], ctx.obj['cluster_id'], ctx.obj['user'], ctx.obj['group'], [
'delete', 'nodepool', nodepool_name])

if not force:
click.confirm(
f"Are you sure you want to delete the nodepool '{nodepool_name}'?",
abort=True
)

_run_kubectl(
ctx.obj['project_id'],
ctx.obj['cluster_id'],
ctx.obj['user'],
ctx.obj['group'],
['delete', 'nodepool', nodepool_name]
)
2 changes: 1 addition & 1 deletion tests/test_nodepool.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def test_nodepool_delete_command(mock_request, mock_run, add_default_profile):
]

runner = CliRunner()
result = runner.invoke(cli, ["cluster", "nodepool", "-p", "test", "-c", "test", "delete", '-n', 'test'])
result = runner.invoke(cli, ["cluster", "nodepool", "-p", "test", "-c", "test", "delete", '-n', 'test', '--force'])
mock_run.assert_called()

args, kwargs = mock_run.call_args
Expand Down