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: //usr/lib/google-cloud-sdk/lib/surface/__pycache__/init.cpython-312.pyc
�

��I\���dZddlmZddlmZddlmZddlZddlmZddlmZ	ddlm
Z
dd	lmZdd
l
mZddl
mZddl
mZdd
l
mZddl
mZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddl!Z!ejDejFejHjJejHjLejHjNejHjP�Gd�dejR���Z*d�Z+y)z&Workflow to set up gcloud environment.�)�absolute_import)�division)�unicode_literalsN)�base)�
exceptions)�
usage_text)�	init_util��config)�execution_utils)�log)�
properties)�yaml)�
named_configs)�
console_io)�store)�network_diagnostics)�resource_projector)�files)�	platformsc��eZdZdZej
Zed��Zd�Z	d�Z
	dd�Zd�Zdd�Z
d	�Zd
�Zd�Zd�Zd
�Zdd�Zy)�Inita:Initialize or reinitialize gcloud.

  {command} launches an interactive Getting Started workflow for the gcloud
  command-line tool.
  It performs the following setup steps:

  - Authorizes gcloud and other SDK tools to access Google Cloud using
    your user account credentials, or from an account of your choosing whose
    credentials are already available.
  - Sets up a new or existing configuration.
  - Sets properties in that configuration, including the current project and
    optionally, the default Google Compute Engine region and zone you'd like to
    use.

  {command} can be used for initial setup of gcloud and to create new or
  reinitialize gcloud configurations. More information about configurations can
  be found by running `gcloud topic configurations`.

  Properties set by {command} are local and persistent, and are not affected by
  remote changes to the project. For example, the default Compute Engine zone in
  your configuration remains stable, even if you or another user changes the
  project-level default zone in the Cloud Platform Console.

  To sync the configuration, re-run `{command}`.

  ## EXAMPLES

  To launch an interactive Getting Started workflow, run:

    $ {command}

  To launch an interactive Getting Started workflow without diagnostics, run:

    $ {command} --skip-diagnostics

  c���|jdddd��|jdddd	�
�|jddd	�
�|jd
d	d��|jdtdd��y)N�obsolete_project_arg�?TzTHIS ARGUMENT NEEDS HELP TEXT.)�nargs�hidden�helpz--console-only�--no-launch-browserz�Prevent the command from launching a browser for authorization. Use this flag if you are on a machine that does not have a browser and you cannot install the gcloud CLI on another machine with a browser.�
store_true)r�action�--no-browserz�Prevent the command from launching a browser for authorization. Use this flag if you are on a machine that does not have a browser but you can install the gcloud CLI on another machine with a browser.z--skip-diagnosticszDo not run diagnostics.)r!rz--universe-domainzLIf set, creates the configuration with the specified [core/universe_domain].)�typerr)�add_argument�str)�parsers �lib/surface/init.py�Argsz	Init.Args[s���
������
-�	�/�
�����
<�
��
�����
<�
��	������
&���
����
��
'���c���|jr tj|jd��tjjd�tjjjj�rtjdd��|j�}|sytjjdj|��|js�tjjd�tjjd�tj�j!�}|sWt#j$d	d
d��s?tjjd
�tjjd�yt'j(�5|j+|�|j-|�ddd�y#1swYyxYw)z7Allows user to select configuration, and initialize it.z�`gcloud init` has changed and no longer takes a PROJECT argument. Please use `gcloud source repos clone` to clone this project's source repositories.zJWelcome! This command will take you through the configuration of gcloud.

zdisable_prompts/--quietz5gcloud init command cannot run with disabled prompts.Nz3Your current configuration has been set to: [{0}]

z@You can skip diagnostics next time by using the following flag:
z"  gcloud init --skip-diagnostics

zNetwork errors detected.z!Would you like to continue anywayF)�message�
prompt_string�defaultz7You can re-run diagnostics with the following command:
z!  gcloud info --run-diagnostics

)r�c_exc�InvalidArgumentExceptionr
�status�writer�VALUES�core�disable_prompts�GetBool�_PickConfiguration�format�skip_diagnosticsr�NetworkDiagnostic�	RunChecksr�PromptContinuer�WithLegacyQuota�_PickProperties�
_Summarize)�self�args�configuration_name�network_passeds    r'�RunzInit.Run�s���� � ��*�*�
�
#�
#�,�
-�-��J�J���8�9������-�-�5�5�7��*�*�
#�
A�
C�C��0�0�2�����J�J���L��f�/�0�2�� � �	�j�j���+�,�	�j�j���=�>�*�<�<�>�H�H�J�n�
��(�(�.�=����*�*�
�
�(�)�

�*�*�
�
�@�
A�
�
�	�	�	�
���4� �
�o�o�(�)�
 �	�	�s�.#G�G#c��|jrBtjtjjj|j�|jxs;|jtjjjj
k(}|j
|j|j||j��sy|j|j��sy|j�|j�y)N��preselected)�universe_domainr�PersistPropertyr2r3r-�_PickAccount�console_only�
no_browser�account�_PickProject�project�_PickDefaultRegionAndZone�_CreateBotoConfig)r?r@�is_default_universes   r'r=zInit._PickProperties�s������� � �
�
�
�
 �
 �
0�
0�$�2F�2F�H�
� � � �	O����
� 1� 1� 6� 6� F� F� N� N�N��������4�?�?�,?��L�L��"�
��������6���"�"�$����r)Nc��d}tj�}|r�|rE|}||vr�tjj	dj|dj
|���yg}|r|jd�|jd�tj||zdd��}	|	�y|	t|�kr||	}n`|r|	t|�k(rd	}nMy|r/tjj	d
j|��ytjd��}
|
syd	}|r*|rd
g}n|rdg}ng}|jddgddg|zd��s9ytjtjj j"�tjj	djtjj j"j%���y	)aChecks if current credentials are valid, if not runs auth login.

    Args:
      console_only: bool, True if the auth flow shouldn't use the browser
      no_browser: bool, True if the auth flow shouldn't use the browser and
        should ask another gcloud installation to help with the browser flow.
      is_default_universe: bool, True if selected universe is the default
      preselected: str, disable prompts and use this value if not None

    Returns:
      bool, True if valid credentials are setup.
    Fz7
[{0}] is not one of your credentialed accounts [{1}].
�,z!Sign in with a new Google AccountzSkip this stepz�Choose the account you want to use for this configuration.
To use a federated user account, exit this command and sign in to the gcloud CLI with your login configuration file, then run this command again.

Select an account:N)r+r,Tz&
[{0}] is not a credentialed account.
z7You must sign in to continue. Would you like to sign in�r,rr"�auth�loginz--forcez--brief)�disable_user_outputzYou are signed in as: [{0}].

)�c_store�AvailableAccountsr
r0r1r7�join�appendr�PromptChoice�lenr;�_RunCmdrrHr2r3rL�Get)r?rJrKrQrF�new_credentials�accountsrL�additional_options�idx�answer�browser_argss            r'rIzInit._PickAccount�s����O��(�(�*�H��	����(�"�

�*�*�
�
�&�&,�f�W�c�h�h�x�6H�&I�K�� ���
�
#�
#�$G�
H��!�!�"2�3��%�%��)�)�)�� ���;����X����S�M�'�
 �S�C��M�%9� �/��	�	�j�j���
4�
;�
;�K�
H����(�(�G��f�
���o��
�-�.���&�'����
�\�\�6�7�+�$�i�0�<�?�.3��5��� � ��!2�!2�!7�!7�!?�!?��I��J�J���7��f�Z�.�.�3�3�;�;�?�?�A�B�D�r)c��tjj�}tjj�}|r|j|vrEtjj|j�|j
�|jSt|�dk(rN|jtjd�}|r,|j�s|j
�|jSg}tjjdj|j��tjj�tjjt!j"t$j&j)���tj*j�tjjd�tjj�|j-dj|j��|j-d�t/t1j2|��D��cgc]\}}|j4s|��}}}|j7d�|D��t9j:|d�	�}|�y|d
k(r|j=�|jS|dk(r|j?�S||dz
}	tjjA|	�|	Scc}}w)ztAllows user to re-initialize, create or pick new configuration.

    Returns:
      Configuration name or None.
    �Nz4Settings from your current configuration [{0}] are:
�
z9Re-initialize this configuration [{0}] with new settings zCreate a new configurationc3�>K�|]}dj|����y�w)z9Switch to and re-initialize existing configuration: [{0}]N)r7)�.0�names  r'�	<genexpr>z*Init._PickConfiguration.<locals>.<genexpr>Ks'����/�-�t�3�39�6�$�<�@�-�s�zPick configuration to use:)r+r�)!r�ConfigurationStore�
AllConfigs�ActiveConfigrk�CreateConfig�Activater]�get�DEFAULT_CONFIG_NAME�
GetPropertiesr
r0r1r7�flushr�dumprr2�	AllValues�outr[�sorted�six�	iteritems�	is_active�extendrr\�_CleanCurrentConfiguration�_CreateConfiguration�ActivateConfig)
r?�configs�
active_config�default_config�choicesrk�c�config_choicesrc�config_names
          r'r6zInit._PickConfigurationsM���.�.�9�9�;�G�!�4�4�A�A�C�M��m�(�(��7��&�&�3�3�M�4F�4F�G�����
�
�
��
�7�|�q���{�{�=�#D�#D�d�K�n�	�� <� <� >����!��"�"�"��G��J�J���L��f�]�/�/�0�2��J�J�����J�J���T�Y�Y�z�0�0�:�:�<�=�>��G�G�M�M�O��J�J���T���J�J�����N�N�C�J�J����	 �!��N�N�/�0�*0����w�1G�*H�*�*H�w�t�Q��[�[��*H�N�*��N�N�/�-�/�/��
!�
!�'�3O�
P�C�
�{�
�
�a�x�
�%�%�'�
�
�
��
�a�x�
�
&�
&�
(�(� ��q��)�K��$�$�3�3�K�@����*s�K7c��tj|��}|�ftjtjj
j|�tjjdj|��|S)z�Allows user to select a project.

    Args:
      preselected: str, use this value if not None

    Returns:
      str, project_id or None if was not selected.
    rEz.Your current project has been set to: [{0}].

)r	�PickProjectrrHr2r3rNr
r0r1r7)r?rF�
project_ids   r'rMzInit._PickProjectZsa���&�&�;�?�J���� � ��!2�!2�!7�!7�!?�!?��L�	�j�j���I���z�*�,��r)c�.��	�jgd�dg��}d}d}|�Ztj|�}|jdi�}|jdg�D]}|dd	k(r|d
}�|ddk(s�|d
}� |stjd�
�}|sy�fd�}|r�jgd�|g�}|d|gd��}|r|s|d}|r�jgd�|g�}|d|gd��y#t$r"tjj	d�YywxYw)zFPulls metadata properties for region and zone and sets them in gcloud.)�computezproject-info�describez--quiet)�paramsa�Not setting default zone/region (this feature makes it easier to use
[gcloud compute] by setting an appropriate default value for the
--zone and --region flag).
See https://cloud.google.com/compute/docs/gcloud-compute section on how to set
default compute region and zone manually. If you would like [gcloud init] to be
able to do this for you the next time you run it, make sure the
Compute Engine API is enabled for your project on the
https://console.developers.google.com/apis page.

N�commonInstanceMetadata�items�keyzgoogle-compute-default-zone�valuezgoogle-compute-default-regionz;Do you want to configure a default Compute Region and Zone?rTc���|s��j|�}|�yt|�}dj|�}tjdj|�g|D�cgc]}|d��	c}z|ddtj���}|�|dk(ry||dz
}tjtjjj|�|d�tjjd	j||d��|Scc}w)
zDSet named compute property to default_value or get via list command.Nz�Which Google Compute Engine {0} would you like to use as project default?
If you do not specify a {0} via a command line flag while working with Compute Engine resources, the default is assumed.zDo not set default {0}rkT)r+r,�allow_freeform�freeform_suggesterrrgz�Your project default Compute Engine {0} has been set to [{1}].
You can change it by running [gcloud config set compute/{0} NAME].

)r^�listr7rr\r�TextChoiceSuggesterrrHr2r��Propertyr
r0r1)rk�
default_value�list_command�valuesr+r�rcr?s       �r'�SetPropertyz3Init._PickDefaultRegionAndZone.<locals>.SetProperty�s���
����l�+���>�
��f���
E�GM�f��G�		��%�%�
%�
,�
,�T�
2�3�*0�1�&��u�V�}�&�1�
2��4��)�=�=�?�	A���;�#��(�
��s�1�u�
�
�� � ��!2�!2�!:�!:�!C�!C�D�!I�!.�v�!6�8�	�j�j���C���t�]�6�%:�;�=����2s�D
)r��zonesr��zone)r�r�r��region)r��regionsr�)r�r�r�)
r^�	Exceptionr
r0r1r�MakeSerializablersrr;)	r?�project_info�default_zone�default_region�metadata�itemrdr�r�s	`        r'rOzInit._PickDefaultRegionAndZonejsM�����\�\�"I�*3��"�6�l� �L��N���'�8�8��F�l��!�!�":�B�?�h��,�,�w��+�$���;�7�7��g��,�
�%�[�;�
;���=�.�	,���(�(�,�.�f����>��\�\�"B�#/�.�2�l��v�|�-I�J�D��N��H�~�n���|�|�$F�%3�$4�6�n���.�*H�I��W��	�j�j���
�
���s�C)�)(D�Dc��tjjd�tjj
jj�r_tjjdjtjj
jj���ntjjd�tjj
jj�}|r.tjjdj|��tjjjj�}|r.tjjdj|��tjjjj�}|r.tjjdj|��tjjd�tjjdj|�	��tjjd
�tjjd�tjjd�tjjd
�tjjd�y)Nz5The Google Cloud CLI is configured and ready to use!
z>* Commands that require authentication will use {0} by defaultzL* Commands that require authentication will fail until you are authenticatedz2* Commands will reference project `{0}` by defaultz:* Compute Engine commands will use region `{0}` by defaultz9* Compute Engine commands will use zone `{0}` by default
zDRun `gcloud help config` to learn how to change individual settings
z�This gcloud configuration is called [{config}]. You can create additional configurations if you work with multiple accounts and/or projects.r
z1Run `gcloud topic configurations` to learn more.
zSome things to try next:
z�* Run `gcloud --help` to see the Cloud Platform services you can interact with. And run `gcloud help COMMAND` to get help on any gcloud command.zl* Run `gcloud topic --help` to learn about advanced features of the CLI like arg files and output formattingzF* Run `gcloud cheat-sheet` to see a roster of go-to `gcloud` commands.)
r
r0�Printrr2r3rLr_r7rNr�r�r�)r?rArNr�r�s     r'r>zInit._Summarize�s����J�J���M�N������%�%�)�)�+�	�j�j���
J��6�*�#�#�(�(�0�0�4�4�6�7�9�
�j�j��������$�$�,�,�0�0�2�G��	�j�j���
>��6�'�?���
�
�
&�
&�
-�
-�
1�
1�
3�F�
�	�j�j���
F��6�&�>�����$�$�)�)�-�-�/�D��	�j�j���
F��6�$�<���J�J���O�Q��J�J���	��F�"4�F�5�7��J�J���I�J��J�J���1�2��J�J���	���J�J���	3�4��J�J���	�r)c��tjd�}|j�}tjj|�tjj
|�tjj�|S)Nz�Enter configuration name. Names start with a lower case letter and contain only lower case letters a-z, digits 0-9, and hyphens '-':  )	r�PromptResponse�striprrnrqr��ActivePropertiesFile�
Invalidate)r?rAs  r'r�zInit._CreateConfiguration�sm��#�2�2�	P�Q��,�1�1�3���$�$�1�1�2D�E��$�$�3�3�4F�G��&�&�1�1�3��r)c�J�t�}|stjd�ytjt
jjdd��}t
jj|�r&tjdj|���yddd|g}tjj�tjjk(rtj|g|���}ntj |g|���}tj"|d	tj$jtj$j�
�}|dk(r0tj&j)dj|���ytj&j)d
�y)Nz;Unable to find [gsutil]. Not configuring default .boto file�~z.botozINot configuring default .boto file. File already exists at [{boto_path}].)�	boto_pathrz-nz-oT)�no_exit�out_func�err_funcrz�Created a default .boto configuration file at [{boto_path}]. See this file and
[https://cloud.google.com/storage/docs/gsutil/commands/config] for more
information about configuring Google Cloud Storage.
zxError creating a default .boto configuration file. Please run [gsutil config -n] if you would like to create this file.
)�_FindGsutilr
�debugr�
ExpandHomeDir�os�pathrZ�existsr7r�OperatingSystem�Current�WINDOWSr�ArgsForCMDTool�ArgsForExecutableTool�Exec�file_only_loggerr0r1)r?�gsutil_pathr��command_args�gsutil_args�return_codes      r'rPzInit._CreateBotoConfig�sZ���-�K��	�i�i�����#�#�B�G�G�L�L��g�$>�?�I�	�w�w�~�~�i� �	�i�i�+�+1�6�I�6�+F�H���d�D�)�4�L�� � �(�(�*�i�.G�.G�.O�.O�O�#�2�2�;�B�4@�B�k�$�9�9�+�I�;G�I�k�"�&�&�{�D�03�0D�0D�0J�0J�03�0D�0D�0J�0J�L�K��a��	�j�j�����F�Y�F��	!�
�j�j���-�.r)c��tjtjjjd�tjtjjj
d�tjtjjjd�tjtjjjd�tjj�y�N)rrHr2r3rLrNr�r�r�rr�r�)r?s r'rzInit._CleanCurrentConfigurations������z�0�0�5�5�=�=�t�D����z�0�0�5�5�=�=�t�D����z�0�0�8�8�?�?��F����z�0�0�8�8�=�=�t�D��&�&�1�1�3r)c�\�|jj|�stjd|�y|�g}||z}tjddj	|��	|r|jd�tjjjj��|r|jd�tjjjj�r|jd�tj|j|��S#t $rP}tjddj	||z��t#j$||z|j&��d}~wt($r*tjddj	||z���wxYw)	NzCommand %s does not exist.zExecuting: [gcloud %s]� z--no-user-output-enabledz--verbosity=nonez
--log-httpz[%s] has failed
zFailed to run [%s]
)�_cli_power_users_only�IsValidCommandr
�inforZr[rr2r3�	verbosityr_�log_httpr5rr��ExecuteCommandDoNotUse�
SystemExitr.�FailedSubCommand�code�
BaseException)r?�cmdr�rWr@�excs      r'r^zInit._RunCmd%sU���%�%�4�4�S�9�	�h�h�+�S�1�
�
�~��f���<�D��H�H�
%�s�x�x��~�6��
����.�/�
�
�
�
 �
 �
*�
*�
.�
.�
0�
8�
����&�'�	�	�	�	�	�	(�	(�	0�	0�	2����L�!�
�
0�
0�
�
%�
%�d�
+�-�-���;�	�h�h�"�C�H�H�S�6�\�$:�;��"�"�3��<����:�:����	�h�h�%�s�x�x��f��'=�>���s�"B>D!�!	F+�*AE5�56F+r�)NT)�__name__�
__module__�__qualname__�__doc__r�SDK_TOOLS_CATEGORY�category�staticmethodr(rCr=rIr6rMrOr>r�rPrr^�r)r'rr,sm��#�J�
$�
$�(��(��(�T**�X�( $�W�r:�x� QJ�f/�b�$.�L4�r)rc��tj�j}|sytjj�tjjk(rd}nd}tjj||�S)zHFinds the bundled gsutil wrapper.

  Returns:
    The path to gsutil.
  Nz
gsutil.cmd�gsutil)
r�Paths�sdk_bin_pathrr�r�r�r�r�rZ)r�r�s  r'r�r�Fs]������,�,�,�	�
����&�&�(�I�,E�,E�,M�,M�M�
�F�
�F�	�����l�F�	+�+r)),r��
__future__rrrr��googlecloudsdk.callioperrr.r�googlecloudsdk.command_libr	�googlecloudsdk.corerrr
rr�"googlecloudsdk.core.configurationsr�googlecloudsdk.core.consoler�googlecloudsdk.core.credentialsrrX�googlecloudsdk.core.diagnosticsr�googlecloudsdk.core.resourcer�googlecloudsdk.core.utilrrr{�UniverseCompatible�
ReleaseTracks�ReleaseTrack�ALPHA�BETA�PREVIEW�GA�Commandrr�r�r)r'�<module>r�s��� -�&��'�	�(�7�.�0�&�/�#�*�$�<�2�<�?�;�*�.�
����������������������������	�P�4�<�<�P�
��P�f,r)