o nnhc/@sdZddlmZddlZddlZddlZddlZddlZddl m Z m Z m Z ddl mZddlmZddlmZmZdd lmZmZmZmZmZmZmZejd ed ZGd d d ejZej ddGdddZ!ej ddGdddZ"GdddeZ#Gddde#Z$Gddde#Z%Gddde$Z&Gddde$Z'ejde'd Z(Gdd d e'Z)Gd!d"d"e'Z*Gd#d$d$e'Z+Gd%d&d&e$Z,dS)'zConfiguration classes.) annotationsN)verify_sys_executableversion_to_str type_guard) CommonConfig)Metadata) data_context PayloadConfig)ControllerConfigControllerHostConfig HostConfig HostSettings OriginConfig PythonConfigVirtualPythonConfig THostConfig)boundc@s0eZdZdZeZeZeZddZ dS) TerminateModezWhen to terminate instances.cCs |jSN)namelowerselfrH/usr/local/lib/python3.10/dist-packages/ansible_test/_internal/config.py__str__1s zTerminateMode.__str__N) __name__ __module__ __qualname____doc__enumautoALWAYSNEVERSUCCESSrrrrrr*s  rT)frozenc@s*eZdZUdZded<ded<ded<dS) ModulesConfigzConfiguration for modules.strpython_requirestuple[str, ...]python_versionsboolcontroller_onlyNrrrr __annotations__rrrrr'5s  r'c@s"eZdZUdZded<ded<dS) ContentConfigzConfiguration for all content.r'modulesr*r+Nr.rrrrr0>s  r0cs`eZdZdZdfdd Zedd d ZedddZdddZdddZ ed ddZ Z S)!EnvironmentConfigzEConfiguration common to all commands which execute in an environment.argst.Anycommandr(returnNonecs t|||j_|j_|j_|j_|j_d_d_ jr)d_ n&t j t  pMt j j tpMj j jttjddkpMttj j j_ |j_|j_|j_|j_|j_|j_|j_g_|j_|j_d fdd }t !|dS) NFpayload_configr r6r7cs}|jrCtj|jd}tj|jd}tj|jd}|j}|tj||f|tj||f|tj||fdSdS)z,Add the host files to the payload file list.z settings.datz state.datz config.datN) host_pathospathjoinfilesappendabspath)r9config settings_path state_path config_pathr>rrr host_callbackxsz1EnvironmentConfig.__init__..host_callbackr9r r6r7)"super__init__ host_settingsr: containers pypi_proxy pypi_endpointcontent_configcontroller_pythondelegate isinstance controllerrpythonrversionrsys version_infor,rr<docker_networkdocker_terminateremote_endpoint remote_stageremote_terminateprime_containers requirements delegate_argsdev_systemd_debugdev_probe_cgroupsr register_payload_callback)rr3r5rE __class__rrrHIs< zEnvironmentConfig.__init__r cC|jjS)z&Host configuration for the controller.)rIrQrrrrrQzEnvironmentConfig.controllerlist[HostConfig]cCrc)z#Host configuration for the targets.)rItargetsrrrrrfrdzEnvironmentConfig.targets target_typet.Type[THostConfig]rcCsNt|j}t|dkrtd|}t||s%tdt|d|d|S)z Return the host configuration for the target. Requires that there is exactly one target of the specified type. rz!There must be exactly one target.z Target is z instead of .)listrflen ExceptionpoprPtype)rrgrftargetrrr only_targets   zEnvironmentConfig.only_targetlist[THostConfig]cCs0|jstdt|j|sJttt|jS)z Return a list of target host configurations. Requires that there are one or more targets, all the specified type. z"There must be one or more targets.)rfrlrtcastrjr)rrgrrr only_targetsszEnvironmentConfig.only_targetst.Type[HostConfig]cCsHtdd|jD}t|dkrtd|}t|tr"t|j}|S)z The true type of the target(s). If the target is the controller, the controller type is returned. Requires at least one target, and all targets must be of the same type. css|]}t|VqdSr)rn).0rorrr sz0EnvironmentConfig.target_type..rz8There must be one or more targets, all of the same type.) setrfrkrlrm issubclassr rnrQ)r target_typesrgrrrrgs   zEnvironmentConfig.target_typer3r4r5r(r6r7)r6r )r6re)rgrhr6r)rgrhr6rq)r6ru) rrrr rHpropertyrQrfrprtrg __classcell__rrrarr2Fs@     r2cs"eZdZdZd fdd ZZS) TestConfigz*Configuration common to all test commands.r3r4r5r(r6r7cst|||j_|j_|jpg_|jpg_|jpg_|j_|j_|j _ |j _ |j _ |j _ |j _ |j_|j_t|dd_t|dd_t|dd_|jrct|jnt_d_jrpd_d fd d }t|dS) NlintFjunit failure_okTr9r r6r7cs2}|j}|jr|tj|j|jfdSdS)z/Add the metadata file to the payload file list.N)r> metadata_pathr?r;r<r@)r9rAr>rrrmetadata_callbacks z.TestConfig.__init__..metadata_callbackrF)rGrHcoveragecoverage_checkincludeexcluderequirechangedtracked untracked committedstagedunstaged changed_from changed_path base_branchgetattrrrrmetadatar from_filerr r`)rr3r5rrarrrHs0   zTestConfig.__init__r{rrrr rHr}rrrarr~r~c"eZdZdZdfdd ZZS) ShellConfigz$Configuration for the shell command.r3r4r6r7csLt|d|j|_|j|_|j|_tjo|j |_ |j |_ d|_ dS)NshellT) rGrHcmdrawrO check_layoutrTstdinisatty interactiveexportdisplay_stderrrr3rarrrHs zShellConfig.__init__r3r4r6r7rrrrarrrrcr) SanityConfigz%Configuration for the sanity command.r3r4r6r7csPt|d|j|_|j|_|j|_|j|_|j|_|j|_|jp$|j|_ dS)Nsanity) rGrHtest skip_test list_testsallow_disabledenable_optional_errors prime_venvsrrrrarrrHszSanityConfig.__init__rrrrrarrrrcs0eZdZdZd fdd Zd fd d ZZS)IntegrationConfigz*Configuration for the integration command.r3r4r5r(r6r7cst|||j|_|j|_|j|_|j|_|j|_|j|_|j|_|j |_ |j |_ |j |_ |j |_ |j |_ |j|_|j|_|j|_|j|_|j|_|j|_|j|_|jr^d|_d|_dSdS)NT)rGrHstart_at start_at_taskallow_destructive allow_rootrallow_unstableallow_unstable_changedallow_unsupportedretry_on_errorcontinue_on_errordebug_strategychanged_all_targetchanged_all_mode list_targetstags skip_tagsdiffno_temp_workdirno_temp_unicodeexplainr)rr3r5rarrrHs0 zIntegrationConfig.__init__csHtjtjjd|j}tjtjj|}tj|s"t }|S)z;Return the path to the Ansible config for the given config.z%s.cfg) r;r<r=r contentintegration_pathr5rootexistsrGget_ansible_config)ransible_config_relative_pathansible_config_pathrarrr+s   z$IntegrationConfig.get_ansible_configr{)r6r()rrrr rHrr}rrrarr srTIntegrationConfigcr) PosixIntegrationConfigz0Configuration for the posix integration command.r3r4r6r7ct|ddS)N integrationrGrHrrarrrH=zPosixIntegrationConfig.__init__rrrrrarr:rrcr) WindowsIntegrationConfigz2Configuration for the windows integration command.r3r4r6r7cr)Nzwindows-integrationrrrarrrHDrz!WindowsIntegrationConfig.__init__rrrrrarrArrcr) NetworkIntegrationConfigz2Configuration for the network integration command.r3r4r6r7cst|d|j|_dS)Nznetwork-integration)rGrHtestcaserrarrrHKs z!NetworkIntegrationConfig.__init__rrrrrarrHrrcr) UnitsConfigz$Configuration for the units command.r3r4r6r7csXt|d|j|_|j|_t|dd|_|jdkr d|_dS|jdkr*d|_dSdS)Nunitsrequirements_modeonlyTskipF)rGrH collect_only num_workersrrr\rrarrrHTs    zUnitsConfig.__init__rrrrrarrQrr)-r __future__r dataclassesr!r;rTtypingrrutilrrr util_commonrrrdatar r host_configsr r r rrrrTypeVarrEnumr dataclassr'r0r2r~rrrrrrrrrrrrs8   $   ~+*