%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/states/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/states/github.pyo

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
eje�Zd�Zdd	�Zdd
�Zdddddeddd
�Zd�Zdd�Zddddddeddddd�Zdd�ZdS(uK
Github User State Module

.. versionadded:: 2016.3.0.

This state is used to ensure presence of users in the Organization.

.. code-block:: yaml

    ensure user test is present in github:
        github.present:
            - name: 'Example TestUser1'
            - email: example@domain.com
            - username: 'gitexample'
i(tabsolute_importtunicode_literalstprint_functionN(tsix(tCommandExecutionError(trangecC@sdtkrdStS(uA
    Only load if the github module is available in __salt__
    ugithub.list_usersugithub(t__salt__tFalse(((s6/usr/lib/python2.7/site-packages/salt/states/github.pyt__virtual__!sugithubcK@s}i|d6id6dd6dd6}td|d||�}|sat|d<dj|�|d<nt|t�r�|r�d	j|�|d<t|d<n�|jd
t�r\|jd�dkr\td
r�dj|�|d<|Std|d||�}|r<|dj	dd�|dj	ddj|��t|d<qyt|d<dj|�|d<ndj|�|d<t|d<|S(u%
    Ensure a user is present

    .. code-block:: yaml

        ensure user test is present in github:
            github.present:
                - name: 'gitexample'

    The following parameters are required:

    name
        This is the github handle of the user in the organization
    unameuchangesuresultuucommentugithub.get_usertprofileuCouldnt find user {0}uUser {0} is already in the org uin_orgumembership_stateupendingutestu!User {0} will be added to the orgugithub.add_useruoldunewuUser {0} exists in the org nowu!Failed to add user {0} to the orgu"User {0} has already been invited.N(
tNoneRRtformatt
isinstancetbooltTruetgett__opts__t
setdefault(tnameR	tkwargstretttargettresult((s6/usr/lib/python2.7/site-packages/salt/states/github.pytpresent(s6


(



cK@s�|jd�}|jd�}i|d6id6dd6dj|�d6}td|d	||�}|rmt|t�s�|jd
t�rMtdr�dj|�|d<d|d<|Std
|d	||�}|r-dj|�|d<|djddj|��|djddj|��t	|d<qjdj|�|d<t|d<q�dj|�|d<t	|d<n!dj|�|d<t	|d<|S|S(uv
    Ensure a github user is absent

    .. code-block:: yaml

        ensure user test is absent in github:
            github.absent:
                - name: 'Example TestUser1'
                - email: example@domain.com
                - username: 'gitexample'

    The following parameters are required:

    name
        Github handle of the user in organization

    uemailufullnameunameuchangesuresultuUser {0} is absent.ucommentugithub.get_userR	uin_orgutestuUser {0} will be deletedugithub.remove_useruDeleted user {0}uolduUser {0} existsunewuUser {0} deleteduFailed to delete {0}u"User {0} has already been deleted!uUser {0} does not existN(
RR
RRRR
RRRR(RR	Rtemailt	full_nameRRR((s6/usr/lib/python2.7/site-packages/salt/states/github.pytabsent`s8!





usecretupullc	 K@s�i|d6id6td6dd6}
td|d||	�}g}|roi}
|d8k	rv|d|krv||
d<n|d8k	r�|d	|kr�||
d	<n|d8k	r�|d
|kr�||
d
<nt|
�dkrrtdr|jd
j|
��d8|
d<qrtd|d||
�}|rWidj|�d6dj|
�d6|
dd<qrt|
d<d|
d<|
Sn|d8k	}ttd|d|�j	��}t|p�g�}||}|r�||ng}|r�tdr|jdj|t
|���d8|
d<q�x�|D]�}td||d||	�}|rtidj||�d6dj||�d6|
d|<qt|
d<dj||�|
d<|
SqWn|r0tdr�|jdj|t
|���d8|
d<qlx�|D]�}td||d||	�}|rAidj||�d6dj||�d6|
d|<q�t|
d<dj||�|
d<|
Sq�Wq0n�tdr�dj|�|
d<d8|
d<|
Std|d |d!|d"|d#|d||	�}|ri|
dd<d8|
ddd<d$j|�|
ddd<n!t|
d<d%j|�|
d<|
S|d8k	}tjj�tj
d&|�}td'd|�}i}x3tj|p�i�D]\}}|||j�<q�Wt}td(|d|�}xRtj|p�i�D];\}}tjd)||�|j�|kr�|rNt||||�rNtdr|jd*j|��qqt}tdr�|jd+j|��d8|
d<qtd,||d||	�}|r�i|
d|<d-j||�|
d|d<d.j||�|
d|d<qt|
d<d/j||�|
d<|
Sq�q�WxA|D]9}t}||krVt|||||�}n|rh||kst|r"|r"t}tdr�|r�|jd0j|��n|jd1j|��d8|
d<q[td2||d||	�}|r4|r�d3nd}id.j||�d6d4j|||�d6|
d|<q[t|
d<d5j||�|
d<|
Sq"q"W|r�td(|d|d6t|	�nt|�dkr�d7j|�|
d<n|
S(9u�
    Ensure a team is present

    name
        This is the name of the team in the organization.

    description
        The description of the team.

    repo_names
        The names of repositories to add the team to.

    privacy
        The level of privacy for the team, can be 'secret' or 'closed'. Defaults
        to secret.

    permission
        The default permission for new repositories added to the team, can be
        'pull', 'push' or 'admin'. Defaults to pull.

    members
        The members belonging to the team, specified as a dict of member name to
        optional configuration. Options include 'enforce_mfa_from' and 'mfa_exempt'.

    enforce_mfa
        Whether to enforce MFA requirements on members of the team. If True then
        all members without `mfa_exempt: True` configured will be removed from
        the team. Note that `no_mfa_grace_seconds` may be set to allow members
        a grace period.

    no_mfa_grace_seconds
        The number of seconds of grace time that a member will have to enable MFA
        before being removed from the team. The grace period will begin from
        `enforce_mfa_from` on the member configuration, which defaults to
        1970/01/01.

    Example:

    .. code-block:: yaml

        Ensure team test is present in github:
            github.team_present:
                - name: 'test'
                - members:
                    user1: {}
                    user2: {}

        Ensure team test_mfa is present in github:
            github.team_present:
                - name: 'test_mfa'
                - members:
                    user1:
                        enforce_mfa_from: 2016/06/15
                - enforce_mfa: True

    .. versionadded:: 2016.11.0
    unameuchangesuresultuucommentugithub.get_teamR	udescriptionu
permissionuprivacyiutestu)Team properties are set to be edited: {0}ugithub.edit_teamuTeam properties were {0}uoldu&Team properties (that changed) are {0}unewuteamu!Failed to update team properties.ugithub.list_team_reposu2Team {0} will have the following repos added: {1}.ugithub.add_team_repouRepo {0} is not in team {1}uRepo {0} is in team {1}u#Failed to add repo {0} to team {1}.u4Team {0} will have the following repos removed: {1}.ugithub.remove_team_repou(Failed to remove repo {0} from team {1}.uTeam {0} is set to be created.ugithub.add_teamtdescriptiont
repo_namest
permissiontprivacyuTeam {0} has been createduFailed to create team {0}.tsecondsugithub.list_members_without_mfaugithub.list_team_membersuChecking member %s in team %suDUser {0} will not be added to the team because they do not have MFA.u%User {0} set to be added to the team.ugithub.add_team_memberuUser {0} is not in team {1}uUser {0} is in team {1}u#Failed to add user {0} to team {1}.uFUser {0} set to be removed from the team because they do not have MFA.u)User {0} set to be removed from the team.ugithub.remove_team_memberu due to MFA violationuUser {0} is not in team {1}{2}u(Failed to remove user {0} from team {1}.tignore_cacheu
N(RRR
tlenRtappendRRtsettkeystlisttdatetimetutcnowt	timedeltaRt	iteritemstlowertlogtinfot_member_violates_mfatjoin( RRRRRtmemberstenforce_mfatno_mfa_grace_secondsR	RRRt
test_commentst
parametersRtmanage_repost
current_repostrepos_to_addtrepos_to_removet	repo_nametmanage_memberstmfa_deadlinetmembers_no_mfat
members_lowertmember_nameR,t
member_changetcurrent_memberstmembertmember_infot
mfa_violationt
extra_changes((s6/usr/lib/python2.7/site-packages/salt/states/github.pytteam_present�s(D






	

"



!



!


	
""



!






$

cC@sS|jdt�rtStjj|jdd�d�}|j�|koR||kS(Nu
mfa_exemptuenforce_mfa_fromu
1970/01/01u%Y/%m/%d(RRR&tstrptimeR*(R@RAR:tmembers_without_mfatenforce_mfa_from((s6/usr/lib/python2.7/site-packages/salt/states/github.pyR-�s
	cK@s'i|d6id6dd6dd6}td|d||�}|sbdj|�|d<t|d<|Std	r�d
j|�|d<d|d<|Std|d||�}|rdj|�|d<|djd
dj|��|djddj|��t|d<ndj|�|d<t|d<|S(uK
    Ensure a team is absent.

    Example:

    .. code-block:: yaml

        ensure team test is present in github:
            github.team_absent:
                - name: 'test'


    The following parameters are required:

    name
        This is the name of the team in the organization.

    .. versionadded:: 2016.11.0
    unameuchangesuresultuucommentugithub.get_teamR	uTeam {0} does not existutestuTeam {0} will be deletedugithub.remove_teamuDeleted team {0}uolduTeam {0} existsunewuTeam {0} deleteduFailed to delete {0}N(R
RRRRRR(RR	RRRR((s6/usr/lib/python2.7/site-packages/salt/states/github.pytteam_absent�s.





c!	K@sai|d6id6td6dd6}
tdd|�ytd|d||�}Wntk
rid.}nXi	|d	6|d
6|d6|d6|d
6|d6|d6|d6|	d6}d.}|r�dddg}i}i}xptj|�D]_\}}|d.k	r�||kr�|||k	r�|||kr�|||<||||<q�q�Wt|�dkr/idj|�d6dj|�d6}tdr�||
dd<d.|
d<q�td|d||�}|r�||
dd<q�t	|
d<d|
d<|
Sq/n;id.d6dj|�d6}tdr6||
dd<d.|
d<n�t
|�}|j|�td||�}|s�t	|
d<dj|�|
d<|
Sxhtd�D]Z}t
jd�ytd |d||�}PWq�tk
r�}tjd!||�q�Xq�W|d.kr!t	|
d<d"j|�|
d<|
S||
dd<|
d.k	r]tdrU|rUg}n%|d.krztd |d|�}ntg|D]}|d^q��}x�|D]�}||
kr�id#j||�d6d$j||�d6}tdr||
d|<d.|
d<q^td%||d|�}|r7||
d|<q^t	|
d<d&j||�|
d<|
Sq�q�Wx�tj|
�D]�\}}||kr8id$j||�d6d#j||�d6}tdr�||
d|<d.|
d<qVtd'||d|d(|�}|r||
d|<qVt	|
d<d&j||�|
d<|
Sqrtd)|d|�j|j�i�jd*�} | s�t	|
d<d+j||�|
d<|
S| |krrid,j||| �d6d,j|||�d6}tdr�||
d|<d.|
d<qVtd'||d|d(|�}|r,||
d|<qVt	|
d<d-j|||�|
d<|
SqrqrWn|
S(/u
    Ensure a repository is present

    name
        This is the name of the repository.

    description
        The description of the repository.

    homepage
        The URL with more information about the repository.

    private
        The visiblity of the repository. Note that private repositories require
        a paid GitHub account.

    has_issues
        Whether to enable issues for this repository.

    has_wiki
        Whether to enable the wiki for this repository.

    has_downloads
        Whether to enable downloads for this repository.

    auto_init
        Whether to create an initial commit with an empty README.

    gitignore_template
        The desired language or platform for a .gitignore, e.g "Haskell".

    license_template
        The desired LICENSE template to apply, e.g "mit" or "mozilla".

    teams
        The teams for which this repo should belong to, specified as a dict of
        team name to permission ('pull', 'push' or 'admin').

        .. versionadded:: 2017.7.0

    Example:

    .. code-block:: yaml

        Ensure repo my-repo is present in github:
            github.repo_present:
                - name: 'my-repo'
                - description: 'My very important repository'

    .. versionadded:: 2016.11.0
    unameuchangesuresultuucommentugithub.list_reposR	ugithub.get_repo_infoudescriptionuhomepageuprivateu
has_issuesuhas_wikiu
has_downloadsu	auto_initugitignore_templateulicense_templateiuRepo properties were {0}uoldu&Repo properties (that changed) are {0}unewutesturepougithub.edit_repou!Failed to update repo properties.uRepo {0} has been createdugithub.add_repouFailed to create repo {0}.iiugithub.get_repo_teamsu&Attempt %s to fetch new repo %s failedu)Failed to verify repo {0} after creation.uRepo {0} is in team {1}uRepo {0} is not in team {1}ugithub.remove_team_repou(Failed to remove repo {0} from team {1}.ugithub.add_team_repoRugithub.list_team_reposu
permissionu?Failed to determine current permission for team {0} in repo {1}u'Repo {0} in team {1} has permission {2}u:Failed to set permission on repo {0} from team {1} to {2}.N(RRRR
RR)R!RRRtdicttupdateRttimetsleepR+R,R#RR*(!RRthomepagetprivatet
has_issuesthas_wikit
has_downloadst	auto_inittgitignore_templatetlicense_templatetteamsR	RRRtgiven_paramst
current_teamst
ignore_paramsR3told_parameterst
param_nametparam_valuetrepo_changeRt
add_paramstattempttetttcurrent_team_namest	team_nametteam_changeRtcurrent_permission((s6/usr/lib/python2.7/site-packages/salt/states/github.pytrepo_present�sA






	





	

	
	#


	


	
	


	
cK@sEi|d6id6dd6dd6}ytd|d||�}Wntk
rXd}nX|s�dj|�|d<t|d<|Std	r�d
j|�|d<d|d<|Std|d||�}|r$dj|�|d<|djd
dj|��|djddj|��t|d<ndj|�|d<t|d<|S(uO
    Ensure a repo is absent.

    Example:

    .. code-block:: yaml

        ensure repo test is absent in github:
            github.repo_absent:
                - name: 'test'

    The following parameters are required:

    name
        This is the name of the repository in the organization.

    .. versionadded:: 2016.11.0
    unameuchangesuresultuucommentugithub.get_repo_infoR	uRepo {0} does not existutestuRepo {0} will be deletedugithub.remove_repouDeleted repo {0}uolduRepo {0} existsunewuRepo {0} deleteduRFailed to delete repo {0}. Ensure the delete_repo scope is enabled if using OAuth.N(R
RRRRRRR(RR	RRRR((s6/usr/lib/python2.7/site-packages/salt/states/github.pytrepo_absent�s6








(t__doc__t
__future__RRRRKR&tloggingtsalt.extRtsalt.exceptionsRtsalt.ext.six.movesRt	getLoggert__name__R+RRRR
RRDR-RHReRf(((s6/usr/lib/python2.7/site-packages/salt/states/github.pyt<module>sB	8<�	6�

Zerion Mini Shell 1.0