44import typer
55
66from epics_containers_cli .git import versions
7+ from epics_containers_cli .globals import LOCAL_NAMESPACE
78from epics_containers_cli .ioc .k8s_commands import IocK8sCommands
89from epics_containers_cli .ioc .local_commands import IocLocalCommands
910from epics_containers_cli .logging import log
@@ -19,7 +20,7 @@ def attach(
1920 """
2021 Attach to the IOC shell of a live IOC
2122 """
22- if ctx .obj .namespace == "" :
23+ if ctx .obj .namespace == LOCAL_NAMESPACE :
2324 IocLocalCommands (ctx .obj , ioc_name ).attach ()
2425 else :
2526 IocK8sCommands (ctx .obj , ioc_name ).attach ()
@@ -33,7 +34,7 @@ def delete(
3334 """
3435 Remove an IOC helm deployment from the cluster
3536 """
36- if ctx .obj .namespace == "" :
37+ if ctx .obj .namespace == LOCAL_NAMESPACE :
3738 IocLocalCommands (ctx .obj , ioc_name ).delete ()
3839 else :
3940 IocK8sCommands (ctx .obj , ioc_name ).delete ()
@@ -54,7 +55,7 @@ def template(
5455 """
5556 print out the helm template generated from a local ioc instance
5657 """
57- if ctx .obj .namespace == "" :
58+ if ctx .obj .namespace == LOCAL_NAMESPACE :
5859 typer .echo ("Not applicable to local deployments" )
5960 else :
6061 IocK8sCommands (ctx .obj ).template (ioc_instance , args )
@@ -76,7 +77,7 @@ def deploy_local(
7677 """
7778 Deploy a local IOC helm chart directly to the cluster with dated beta version
7879 """
79- if ctx .obj .namespace == "" :
80+ if ctx .obj .namespace == LOCAL_NAMESPACE :
8081 IocLocalCommands (ctx .obj ).deploy_local (ioc_instance , yes , args )
8182 else :
8283 IocK8sCommands (ctx .obj ).deploy_local (ioc_instance , yes , args )
@@ -94,7 +95,7 @@ def deploy(
9495 """
9596 Pull an IOC helm chart version from the domain repo and deploy it to the cluster
9697 """
97- if ctx .obj .namespace == "" :
98+ if ctx .obj .namespace == LOCAL_NAMESPACE :
9899 IocLocalCommands (ctx .obj , ioc_name ).deploy (ioc_name , version , args )
99100 else :
100101 IocK8sCommands (ctx .obj , ioc_name ).deploy (ioc_name , version , args )
@@ -116,7 +117,7 @@ def exec(
116117 ioc_name : str = typer .Argument (..., help = "Name of the IOC container to run in" ),
117118):
118119 """Execute a bash prompt in a live IOC's container"""
119- if ctx .obj .namespace == "" :
120+ if ctx .obj .namespace == LOCAL_NAMESPACE :
120121 IocLocalCommands (ctx .obj , ioc_name ).exec ()
121122 else :
122123 IocK8sCommands (ctx .obj , ioc_name ).exec ()
@@ -143,7 +144,7 @@ def logs(
143144 follow : bool = typer .Option (False , "--follow" , "-f" , help = "Follow the log stream" ),
144145):
145146 """Show logs for current and previous instances of an IOC"""
146- if ctx .obj .namespace == "" :
147+ if ctx .obj .namespace == LOCAL_NAMESPACE :
147148 IocLocalCommands (ctx .obj , ioc_name ).logs (prev , follow )
148149 else :
149150 IocK8sCommands (ctx .obj , ioc_name ).logs (prev , follow )
@@ -155,7 +156,7 @@ def restart(
155156 ioc_name : str = typer .Argument (..., help = "Name of the IOC container to restart" ),
156157):
157158 """Restart an IOC"""
158- if ctx .obj .namespace == "" :
159+ if ctx .obj .namespace == LOCAL_NAMESPACE :
159160 IocLocalCommands (ctx .obj , ioc_name ).restart ()
160161 else :
161162 IocK8sCommands (ctx .obj , ioc_name ).restart ()
@@ -168,7 +169,7 @@ def start(
168169):
169170 """Start an IOC"""
170171 log .debug ("Starting IOC with LOCAL={ctx.obj.namespace == " "}" )
171- if ctx .obj .namespace == "" :
172+ if ctx .obj .namespace == LOCAL_NAMESPACE :
172173 IocLocalCommands (ctx .obj , ioc_name ).start ()
173174 else :
174175 IocK8sCommands (ctx .obj , ioc_name ).start ()
@@ -180,7 +181,7 @@ def stop(
180181 ioc_name : str = typer .Argument (..., help = "Name of the IOC container to stop" ),
181182):
182183 """Stop an IOC"""
183- if ctx .obj .namespace == "" :
184+ if ctx .obj .namespace == LOCAL_NAMESPACE :
184185 IocLocalCommands (ctx .obj , ioc_name ).stop ()
185186 else :
186187 IocK8sCommands (ctx .obj , ioc_name ).stop ()
0 commit comments