File: //lib/python3/dist-packages/awscli/customizations/eks/__pycache__/update_kubeconfig.cpython-310.pyc
o
.&�aS/ � @ s� d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z d dl
mZmZm
Z
mZmZmZ d dlmZ e�e�Ze j�d�Zd ZG d
d� de�ZG dd
� d
e�ZG dd� de�ZdS )� N)�OrderedDict)�BasicCommand)� uni_print)�EKSClusterError)�
Kubeconfig�KubeconfigError�KubeconfigLoader�KubeconfigWriter�KubeconfigValidator�KubeconfigAppender)�ordered_yaml_dumpz~/.kube/configz%client.authentication.k8s.io/v1alpha1c @ st e Zd ZdZe�ddd�Zdddd�dd d
d�ddd
d�d
dd
dd
d�ddd
dd�ddd
d�gZdd� Zdd� Z dS )�UpdateKubeconfigCommandzupdate-kubeconfig�eksz_description.rst�namez�The name of the cluster for which to create a kubeconfig entry. This cluster must exist in your account and in the specified or configured default Region for your AWS CLI installation.T)r � help_text�required�
kubeconfiga Optionally specify a kubeconfig file to append with your configuration. By default, the configuration is written to the first file path in the KUBECONFIG environment variable (if it is set) or the default kubeconfig path (.kube/config) in your home directory.Fzrole-arnz�To assume a role for cluster authentication, specify an IAM role ARN with this option. For example, if you created a cluster while assuming an IAM role, then you must also assume that role to connect to the cluster the first time.zdry-run�
store_truezRPrint the merged kubeconfig to stdout instead of writing it to the specified file.)r �action�defaultr r �verbosez_Print more detailed output when writing to the kubeconfig file, including the appended entries.)r r r r �aliaszBAlias for the cluster context name. Defaults to match cluster ARN.c C s* t d� |D ]}t t|�� t d� qdS )z�
Display entries in yaml format
:param entries: a list of OrderedDicts to be printed
:type entries: list
z
Entries:
�
N)r r )�self�entries�entry� r �M/usr/lib/python3/dist-packages/awscli/customizations/eks/update_kubeconfig.py�_display_entriesg s
�z(UpdateKubeconfigCommand._display_entriesc C s� t | j|j|j|�}|�� }|�� }ttj� dd�|j
�}|�|d �}|�|d �}t
� } | �||||j�}
|jrBt|�� � d S t� }|�|� |rXtd�|
d |j�� ntd�|
d |j�� |jrp| �|
||g� d S d S )N�
KUBECONFIG� r zUpdated context {0} in {1}
zAdded new context {0} to {1}
)� EKSClient�_sessionr �role_arn�get_cluster_entry�get_user_entry�KubeconfigSelector�os�environ�getr �choose_kubeconfig�has_clusterr �insert_cluster_user_pairr �dry_runr �dump_contentr �write_kubeconfig�format�pathr r )r �parsed_args�parsed_globals�client�new_cluster_dict�
new_user_dict�config_selector�config�updating_existing�appender�new_context_dict�writerr r r � _run_mains sN ����
�
�
��z!UpdateKubeconfigCommand._run_mainN)
�__name__�
__module__�__qualname__�NAMEr � FROM_FILE�DESCRIPTION� ARG_TABLEr r= r r r r r
'