HEX
Server: Apache/2.4.68 (Debian)
System: Linux as-cs-widget-demo-us-central1 6.1.0-44-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.164-1 (2026-03-09) x86_64
User: root (0)
PHP: 8.2.32
Disabled: NONE
Upload Files
File: //lib/google-cloud-sdk/lib/surface/code/__pycache__/dev.cpython-312.pyc
�

���.��T�dZddlmZddlmZddlmZddlmZddlZddlZddlm	Z	ddl
mZdd	l
mZdd
l
m
Z
ddl
mZddl
mZdd
l
mZddl
mZddl
mZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z!ddl"Z"ddl#Z#Gd�dejH�Z%d�Z&d�Z'd�Z(ejRd��Z*e	jVe	jXjZe	jXj\�Gd �d!e	j^��Z0d"�Z1d#�Z2d$�Z3y)%z4Command for running a local development environment.�)�absolute_import)�division)�print_function)�unicode_literalsN)�base)�cross_platform_temp_file)�flags)�
kubernetes)�local)�local_files)�run_subprocess)�skaffold)�yaml_helper)�artifact_registry)�cloud)�cloud_files)�cloudrun)�config)�
exceptions)�
properties)�yaml)�update_manager)�filesc��eZdZdZy)�RuntimeMissingDependencyErrorz A runtime dependency is missing.N)�__name__�
__module__�__qualname__�__doc__���lib/surface/code/dev.pyrr/s��(r!rc�l�tjjjj	�dk(S)z/Return true if the verbosity is equal to debug.�debug)r�VALUES�core�	verbosity�Getr r!r"�_IsDebugr)3s(��	�	�	�	�	�	)�	)�	-�	-�	/�7�	:�:r!c�F�tj|ddt���S)N�	skaffold_�.yaml��prefix�suffix�delete�r�
NamedTempFiler))�skaffold_configs r"�_SkaffoldTempFiler48s%��	!�	/�	/��
�
���^�	
�r!c�F�tj|ddt���S)N�deploy_r,r-r1)�kubernetes_configs r"�_DeployTempFiler8@s%��	!�	/�	/��
�
���^�	
�r!c#�K�|s|��ytj|j�}tj|d�}d|d<ttj|��5}|��ddd�y#1swYyxYw�w)a?Set build.local.push value in skaffold file.

  Args:
    skaffold_file: Skaffold file handle.
    shared_docker: Boolean that is true if docker instance is shared between the
      kubernetes cluster and local docker builder.

  Yields:
    Path of skaffold file with build.local.push value set to the proper value.
  )�buildrF�pushN)r�	load_path�namer�GetOrCreater4�dump)�
skaffold_file�
shared_docker�
skaffold_yaml�local_block�patched_skaffold_files     r"�
_SetImagePushrEHsi����
����N�N�=�#5�#5�6�M��)�)�-�9K�L�K��K���	�4�9�9�]�3�	4�8M�!�!�
5�	4�	4�s�A A<�"A0�'	A<�0A9�5A<c��eZdZdZddd�Zed��Zd�Zd�Zd�Z	d	�Z
d
�Zed��Z
eejd���Zy
)�Devz;Run a Cloud Run service in a local development environment.a!          Run a Cloud Run service in a local development environment.

          This command takes Cloud Run source, builds it, and runs it on the
          local machine. This command also watches the relevant source files and
          updates the container when they change.
          a�          If building images using a Dockerfile:

            $ {command} --dockerfile=<path_to_dockerfile>

          If the Dockerfile is named `Dockerfile` and is located in the current
          directory, the `--dockerfile` flag may be omitted:

            $ {command}

          To access Google Cloud Platform services with the current user's
          credentials, login to obtain the application default credentials and
          invoke this command with the `--application-default-credential` flag.

            $ gcloud auth application-default login
            $ {command} --dockerfile=<path_to_dockerfile>             --application-default-credential
          )�DESCRIPTION�EXAMPLESc��tj�}|j|j��|j	|�|jd��}|j
dd��|j
dd��|j
dd	d
d��|j�tjjk(r'|j
d
dd��|j
dd��|j
dtd	d��y)NF)�requiredz--kube-contextzKubernetes context.)�helpz--minikube-profilezMinikube profile.z--stop-clusterT�
store_truezKIf running on minikube, stop the minkube profile at the end of the session.)�default�actionrLz--minikube-vm-driver�dockerz+If running on minikube, use this vm driver.)rNrLz--namespacez8Kubernetes namespace for development kubernetes objects.z--skaffold-events-portz^Local port on which the skaffold events api is exposed. If not set, a random port is selected.)�type�hiddenrL)
r	�CommonFlags�AddAlphaAndBetaFlags�ReleaseTrack�ConfigureParser�add_mutually_exclusive_group�add_argumentr�ALPHA�int)�cls�parser�common�groups    r"�ArgszDev.Args�s
��
�
�
�
 �F�
���� 0� 0� 2�3�
���6�"��/�/��/�?�E�	���'�.C��D�	���+�2E��F�
�������	������T�.�.�4�4�4����
 ��<��>�

���
�I��K�
��� �
��*�	�+r!c���t|�t�rt|�|jd�r|jr|j|�y|j
|�y)Nr)�_EnsureComponentsInstalledr)�_PrintDependencyVersions�IsKnownAndSpecifiedr�	_RunCloud�	_RunLocal)�self�argss  r"�RunzDev.Run�sC���t�$��z��t�$�����(�T�Z�Z�
�n�n�T��
�n�n�T�r!c���tj||j��}tj|�}tj|j��}t|dd�}t�t|�5}tj|j|j��}|jxstj�}t!|�5}	|j#|�5}
|j%||
j&�5t)|	|
j*�5}|j-||
||�5}t/j0|j2|�5|j5�ddd�ddd�ddd�ddd�ddd�ddd�ddd�y#1swY�:xYw#1swY�>xYw#1swY�BxYw#1swY�FxYw#1swY�JxYw#1swY�NxYw#1swYyxYw)N�	namespace)r�AssembleSettingsrUr�LocalRuntimeFiles�six�ensure_text�KubernetesConfig�getattr�_EnsureDockerRunningr8�SkaffoldConfigr=�skaffold_events_port�
portpicker�pick_unused_portr4�_GetKubernetesEngine�_WithKubeNamespace�context_namerErA�_SkaffoldProcessr�PrintUrlThreadContext�service_name�wait)
rfrg�settings�local_file_generatorr7rj�kubernetes_filer3�skaffold_event_portr@�kube_contextrD�running_processs
             r"rez
Dev._RunLocal�s����%�%�d�D�,=�,=�,?�@�H�&�8�8��B�����(<�(M�(M�(O�P����k�4�0�I���	�*�	+�����
�
-�
-�o�.B�.B�
C�E�o��
#�
#�
D�z�'B�'B�'D���_�-���$�$�T�*�l��"�"�9�l�.G�.G�H���%�3�3�5�8M�� � �!6��i�!4�6�9H��)�)�(�*?�*?�*=�?�����?�6�5�I�+�.�
,�	+�?�?��6�6��5�5��I�H��+�*��.�-��
,�	+�s��?AG)�G�-G�
G	�!F9�6!F-
�F!�(F-
�0F9�8G	�G�G�G)�!F*�&F-
�-F6�2F9�9G�>G	�G
�
G�G�G�G&	�"G)�)G2c	�`�tj|�}tj|�tj|||j��t
j|�}tj|j��}|jrtj|j�t|�5}tj|j|j ��}|j"xst%j&�}t)|�5}|j+||�5}	t-j.|j0|�5|	j3�ddd�ddd�ddd�ddd�y#1swY�"xYw#1swY�&xYw#1swY�*xYw#1swYyxYw�N)rrk�ValidateSettingsr�PromptToOverwriteCloudrUr�CloudRuntimeFilesrmrnro�ar_repor�CreateIfNeededr8rrr=rsrtrur4�_CloudSkaffoldProcessrrzr{r|)
rfrgr}�cloud_file_generatorr7rr3r�r@r�s
          r"rdz
Dev._RunCloud�sR���%�%�d�+�H�	���8�$��#�#�D�(�D�4E�4E�4G�H�&�8�8��B�����(<�(M�(M�(O�P������&�&�x�'7�'7�8�	�*�	+�����
�
-�
-�o�.B�.B�
C�E�o��
#�
#�
D�z�'B�'B�'D���_�-���%�%�m�&9�;�>M��)�)�(�*?�*?�*=�?�����?�;�.�
,�	+�?�?��;�;��.�-��
,�	+�sU�>AF$�F�-!F�F	�F�'F�/F$�F	
�F�F�F�F!	�F$�$F-c��tj|j|j||jt�|�Sr�)r�Skaffoldr=rx�env_varsr))rfrDr�rjr�s     r"ryzDev._SkaffoldProcess�s9�����2�7�7�)�6�6�	�)�2�2�H�J�0�2�2r!c�V�tj|jt�|��S)N)r$�events_port)rr�r=r))rfrDr�s   r"r�zDev._CloudSkaffoldProcess�s&������"�"��j�'�)�)r!c�V���fd�}�fd�}�jd�r|�S|�S)z�Get the appropriate kubernetes implementation from the args.

    Args:
      args: The namespace containing the args.

    Returns:
      The context manager for the appropriate kubernetes implementation.
    c�B��tj�j�Sr�)r
�ExternalClusterContextr�)rgs�r"�Externalz*Dev._GetKubernetesEngine.<locals>.External�s���
�
.�
.�t�/@�/@�
A�Ar!c	�����jd�r
�j}ntj}tj|�j
t
�dd�t��S)N�minikube_profile�minikube_vm_driverrP)�IsSpecifiedr�r
�DEFAULT_CLUSTER_NAME�Minikube�stop_clusterrpr))�cluster_namergs �r"r�z*Dev._GetKubernetesEngine.<locals>.Minikube�sW���	
�	�	�,�	-��,�,��!�6�6��
�
 �
 ��t�/@�/@�!(��/C�X�!N�!)��-�-r!r�)r�)rgr�r�s`  r"rvzDev._GetKubernetesEngine�s.���B�-�����'�
�Z��
�Z�r!c#�xK�|r$tj||�5d��ddd�yd��y#1swYyxYw�w)z�Create and destory a kubernetes namespace if one is specified.

    Args:
      namespace_name: Namespace name.
      context_name: Kubernetes context name.

    Yields:
      None
    N)r
�
KubeNamespace)�namespace_namerxs  r"rwzDev._WithKubeNamespace	s5������#�#�N�L�A�
�B�A��B�A�s�:�.�:�7�:N)rrrr�
detailed_help�classmethodr_rhrerdryr��staticmethodrv�
contextlib�contextmanagerrwr r!r"rGrGbsz��D����-�<�#+��#+�J��0�(2�)�����8�
������r!rGc���tjd�}|std��	tj|dgdt���y#tj$rtd��wxYw)zMake sure docker is running.rPzWCannot locate docker on $PATH. Install docker from https://docs.docker.com/get-docker/.�info�)�timeout_sec�show_outputzIUnable to reach docker daemon. Make sure docker is running and reachable.N)�
file_utils�FindExecutableOnPathrr
rhr)�
subprocess�CalledProcessError)rPs r"rqrqsn���*�*�8�4�&�	�
'�	/�0�0�������'�R�X�Z�P��	�	&�	&��
'�	����s�"A�A&c�4�tj�jsydg}|jd�r#|j	d�|j	d�n#|jd�rn|j	d�tjj|�y)z4Make sure the components needed later are installed.Nrrzcloud-run-proxyz
log-streamingr��minikube)	r�Paths�sdk_rootrc�appendr�r�
UpdateManager�EnsureInstalledAndRestart)rg�
componentss  r"rara.s{��	����	 �	 ���|�*�	���g�&����'�(����o�&�����'�
����
�#����8�8��Dr!c���dtj�i}|jd�rntj�|d<t|j
��D]\}}t|�d|�d���y)z.Print the version strings of the dependencies.rr�r�z: �
N)r�
GetVersionr�r
�GetMinikubeVersion�sorted�items�print)rg�dependency_versionsr=�versions    r"rbrbBse��#�X�%8�%8�%:�;��	���n�%��&0�&C�&C�&E��
�#��1�7�7�9�:�m�d�G�	��g�
&�'�;r!)4r�
__future__rrrrr�r��googlecloudsdk.callioper�googlecloudsdk.command_lib.coderr	r
rrr
rr�%googlecloudsdk.command_lib.code.cloudrrrr�googlecloudsdk.corerrrr�googlecloudsdk.core.updaterr�googlecloudsdk.core.utilrr�rtrm�Errorrr)r4r8r�rE�
ReleaseTracksrU�BETArY�CommandrGrqrarbr r!r"�<module>r�s���;�&��%�'���(�D�1�6�1�7�:�4�7�C�7�=�:�&�*�*�$�6�8��
�)�J�$4�$4�)�;�
�����"��"�2����D�%�%�*�*�D�,=�,=�,C�,C�D�v�$�,�,�v�E�v�r�$E�(
(r!