Skip to content

Commit

Permalink
fix(project): skips update if VPN already enabled
Browse files Browse the repository at this point in the history
The rio project features vpn command updates a project regardless of the
status of VPN on the project. This commit fixes the flow by skipping the
update call if VPN state is already the one desired.

Wrike Ticket: https://www.wrike.com/open.htm?id=1128159743
  • Loading branch information
pallabpain committed Jan 23, 2024
1 parent 3aa3ea5 commit 51b0222
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion riocli/project/features/vpn.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023 Rapyuta Robotics
# Copyright 2024 Rapyuta Robotics
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -59,6 +59,13 @@ def vpn(
spinner.red.fail(Symbols.ERROR)
raise SystemExit(1) from e

# Check the current state of VPN and avoid making the update call.
if project['spec']['features']['vpn'].get('enabled', False) == enable:
expected_state = "enabled" if enable else "disabled"
spinner.text = click.style('VPN is already {}.'.format(expected_state), fg=Colors.GREEN)
spinner.green.ok(Symbols.SUCCESS)
return

project["spec"]["features"]["vpn"] = {
"enabled": enable,
"subnets": (subnets or []) if enable else []
Expand Down

0 comments on commit 51b0222

Please sign in to comment.