Skip to content

Commit

Permalink
fix(deployment): inspect deployment with guid
Browse files Browse the repository at this point in the history
  • Loading branch information
YaswanthKumar-eng committed Sep 6, 2024
1 parent 1ef30e6 commit 38bd720
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions riocli/deployment/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import re

import click
from click_help_colors import HelpColorsCommand
from munch import unmunchify, munchify
import re

from riocli.config import new_v2_client
from riocli.constants import Colors
from riocli.utils import inspect_with_format

DEPLOYMENT_GUID_PATTERN = r'^dep-[a-z0-9]+$'

@click.command(
'inspect',
Expand All @@ -40,11 +43,11 @@ def inspect_deployment(
client = new_v2_client()
deployment_obj = munchify({})

deployment_pattern = r'^dep-[a-z0-9]+$'
if re.fullmatch(deployment_pattern,deployment_name):
list_dep = client.list_deployments(query={'guids': [deployment_name]})
deployment_obj = list_dep[0]
else :
if re.fullmatch(DEPLOYMENT_GUID_PATTERN, deployment_name):
deployments = client.list_deployments(query={'guids': [deployment_name]})
if deployments:
deployment_obj = deployments[0]
else:
deployment_obj = client.get_deployment(deployment_name)

if not deployment_obj:
Expand Down

0 comments on commit 38bd720

Please sign in to comment.