o
    O6ufî  ã                   @   s&   d dl mZmZ G dd„ deeƒZdS )é    )ÚPluginÚUbuntuPluginc                   @   s4   e Zd ZdZdZdZdZdZdZdd„ Z	dd	„ Z
d
S )ÚMicrok8sa  The Microk8s plugin collects the current status of the microk8s
    snap on a Ubuntu machine.

    It will collect logs from journald related to the snap.microk8s
    units as well as run microk8s commands to retrieve the configuration,
    status, version and loaded plugins.
    zThe lightweight KubernetesÚmicrok8s)Ú	container)r   c                 C   s6   | j dd� g d¢}|  d¡ |  dd„ |D ƒ¡ d S )Nzsnap.microk8s.*)Úunits)zaddons repo listÚconfigzctr plugins lszctr plugins ls -dÚstatusÚversionú4/var/snap/microk8s/current/credentials/client.configc                 S   s   g | ]}d |› �‘qS )z	microk8s © )Ú.0Úsubcmdr   r   ú=/usr/lib/python3/dist-packages/sos/report/plugins/microk8s.pyÚ
<listcomp>/   s    
ÿz"Microk8s.setup.<locals>.<listcomp>)Úadd_journalÚadd_copy_specÚadd_cmd_output)ÚselfÚmicrok8s_subcmdsr   r   r   Úsetup    s   ÿ
ÿzMicrok8s.setupc                 C   s>   d}|   d|d¡ g d¢}dd |¡› d�}|  d|d	¡ d S )
Nz((certificate-authority-data:|token:)\s.*r   z\1 "**********")zcertificate-authority-datazclient-certificate-datazclient-key-dataz(^\s*(ú|z)\s*:\s*)(.*)r   z\1*********)Údo_cmd_output_subÚjoinÚdo_path_regex_sub)r   ÚrsubÚprotect_keysÚ	key_regexr   r   r   Úpostproc3   s   þzMicrok8s.postprocN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚpackagesÚmicrok8s_cmdr   r   r   r   r   r   r      s    r   N)Úsos.report.pluginsr   r   r   r   r   r   r   Ú<module>   s   