
    	                         d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddl	m
Z
 ddlmZ  G d	 d
ej                        Z G d dej                        Z G d dej                        Z	 	 ddZddZddZy)z=Command line flags for parsing kubectl config files commands.    )absolute_import)division)unicode_literalsN)
kubeconfig)base)
exceptionsc                       e Zd ZdZy)MissingEnvVarErrorzDAn exception raised when required environment variables are missing.N__name__
__module____qualname____doc__     :lib/googlecloudsdk/command_lib/anthos/common/kube_flags.pyr
   r
      s    Lr   r
   c                       e Zd ZdZy)ConfigParsingErrorz1An exception raised when parsing kubeconfig file.Nr   r   r   r   r   r       s    9r   r   c                       e Zd ZdZy)MissingConfigErrorz4An exception raised when kubeconfig file is missing.Nr   r   r   r   r   r   $   s    <r   r   c                 2    t        j                  d||       S )Nz--kubeconfigrequiredhelpr   Argument)help_txtr   s     r   GetKubeConfigFlagr   (   s     

 r   c                 2    t        j                  dd|       S )Nz	--contextFr   r   )r   s    r   GetKubeContextFlagr    1   s    	E
2 2r   c                    | xs t         j                  j                         }|r$t        j                  |t        j
                        st        dj                  |            |xs d}t         j                  j                  |      }|dk(  r|j                  }||fS ||j                  vrt        dj                  ||             ||fS )z$Get the Kubeconfig path and context.z3kubeconfig file not found or is not readable : [{}]zcurrent-contextz.context [{}] does not exist in kubeconfig [{}])kconfig
KubeconfigDefaultPathosaccessR_OKr   formatLoadFromFilecurrent_contextcontextsr   )r   contextconfigcontext_namekcs        r   GetKubeconfigAndContextr0   6   s    9++779&	ryy1
=DDVLN N --,&&v."&&%%L
 
		 2;;&
8??*	&' ' 
	r   )z'The path to the Kubeconfig file to use.F)zThe Kubernetes context to use.)NN)r   
__future__r   r   r   r%    googlecloudsdk.api_lib.containerr   r"   googlecloudsdk.callioper   googlecloudsdk.corer   core_exceptionsErrorr
   r   r   r   r    r0   r   r   r   <module>r7      so    D &  ' 	 B ( =M.. M:.. :=.. =
 72
r   