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/functions/__pycache__/upgrade.cpython-312.pyc
�

���7���dZddlmZddlmZddlmZddlZddlmZddlm	Z
ddlmZdd	lmZ
dd
lmZddlmZddlmZddlmZdd
lmZddlmZddlmZddlmZddlmZddlZdZej@dgd��Z!dZ"e!dddde"z��Z#e!dddde"z��Z$e!dddd e"z��Z%e!d!d"d#d$��Z&e!dd%d&d'��Z'e#gge$e&ge#e&ge&ge'e%e&ge$e&ge%e&gge'gd(�
Z(d)�Z)d*�Z*ejVejXejZj\�Gd+�d,ej^���Z0ejVejXejZjb�Gd-�d.e0���Z2y)/�;Upgrade a 1st gen Cloud Function to the Cloud Run function.�)�absolute_import)�division)�unicode_literalsN)�api_enablement)�client)�
exceptions)�util)�base)�types)�flags)�run_util)�service_account_util)�deploy_util)�log)�
console_io)zgoogle.pubsub.topic.publishz/providers/cloud.pubsub/eventTypes/topic.publish�
UpgradeAction)�target_state�
prompt_msg�op_description�success_msgz^You can abort the upgrade process at any time by rerunning this command with the --abort flag.�(SETUP_FUNCTION_UPGRADE_CONFIG_SUCCESSFULaThis creates a Cloud Run function with the same name [{}], code, and configuration as the 1st gen function. The 1st gen function will continue to serve traffic until you redirect traffic to the Cloud Run function in the next step.

To learn more about the differences between 1st gen and Cloud Run functions, visit: https://cloud.google.com/functions/docs/concepts/version-comparisonz�Setting up the upgrade for function. Please wait while we duplicate the 1st gen function configuration and code to a Cloud Run function.aThe Cloud Run function is now ready for testing:
  {}
View the function upgrade testing guide for steps on how to test the function before redirecting traffic to it.

Once you are ready to redirect traffic, rerun this command with the --redirect-traffic flag.

�,REDIRECT_FUNCTION_UPGRADE_TRAFFIC_SUCCESSFULz�This will redirect all traffic from the 1st gen function [{}] to its Cloud Run function copy. Please ensure that you have tested the Cloud Run function before proceeding.z.Redirecting traffic to the Cloud Run function.z�The Cloud Run function is now serving all traffic. If you experience issues, rerun this command with the --rollback-traffic flag. Otherwise, once you are ready to finalize the upgrade, rerun this command with the --commit flag.

z�This will rollback all traffic from the Cloud Run function copy [{}] to the original 1st gen function. The Cloud Run function is still available for testing.z-Rolling back traffic to the 1st gen function.ziThe 1st gen function is now serving all traffic. The Cloud Run function is still available for testing.

�ELIGIBLE_FOR_2ND_GEN_UPGRADEzhThis will abort the upgrade process and delete the Cloud Run function copy of the 1st gen function [{}].z"Aborting the upgrade for function.zDUpgrade aborted and the Cloud Run function was successfully deleted.ztThis will complete the upgrade process for function [{}] and delete the 1st gen copy.

This action cannot be undone.zBCompleting the upgrade and deleting the 1st gen copy for function.a(Upgrade completed and the 1st gen copy was successfully deleted.

Your function will continue to be available at the following endpoints:
{}
Reminder, your function can now be managed through the Cloud Run API. Any event triggers are now Eventarc triggers and can be managed through Eventarc API.)
r�UPGRADE_OPERATION_IN_PROGRESSr�#SETUP_FUNCTION_UPGRADE_CONFIG_ERROR�ABORT_FUNCTION_UPGRADE_ERRORr�'REDIRECT_FUNCTION_UPGRADE_TRAFFIC_ERROR�'ROLLBACK_FUNCTION_UPGRADE_TRAFFIC_ERROR�"COMMIT_FUNCTION_UPGRADE_SUCCESSFUL�COMMIT_FUNCTION_UPGRADE_ERRORc�&�tj|�}|dk(rtjd��||jk(r$tjdj|���|t|vr$tjdj|���y)zKValidates whether the action is a valid action for the given upgrade state.rzVAn upgrade operation is already in progress for this function. Please try again later.z9This function is already in the desired upgrade state: {}zTThis function is not eligible for this operation. Its current upgrade state is '{}'.N)�six�	text_typer	�FunctionsErrorr�format�_VALID_TRANSITION_ACTIONS)�
upgrade_state�action�upgrade_state_strs   � lib/surface/functions/upgrade.py�_ValidateStateTransitionr,�s����m�m�M�2���9�9�
�
#�
#�	#���
�&�-�-�-�
�
#�
#�C�J�J��	
����,�->�?�?�
�
#�
#�	� �&��/���@�c�~�tj|j�dk(r#tjd|j
�d���dt
j�vr#tjd|j
�d���tj|j�dk7r0tjd|j
�d|j�d���|js?|jjtvr#tjd|j
�d	���tjd|j
�d
���)z>Raises an error when the function is not eligible for upgrade.�GEN_2�
Function [z�] is not eligible for Upgrade. To migrate to Cloud Run function, please detach the function using `gcloud functions detach` instead.�:zq] is not eligible for Cloud Run function upgrade. It is in domain-scoped project that Cloud Run does not support.�ACTIVEzB] is not eligible for Cloud Run function upgrade. It is in state [z].zt] is not eligible for Cloud Run function upgrade. Only HTTP functions and Pub/Sub triggered functions are supported.z1] is not eligible for Cloud Run function upgrade.)
r#r$�environmentr	r%�name�api_util�
GetProject�state�url�eventTrigger�	eventType�SUPPORTED_EVENT_TYPES)�functions r+� _RaiseNotEligibleForUpgradeErrorr=�s7���]�]�8�'�'�(�G�3�
�
#�
#�
�X�]�]�O�$&�	&���
	�H���!�!�
�
#�
#�
�X�]�]�O�$�	���
	�]�]�8�>�>�"�h�.�
�
#�
#�
�X�]�]�O�$%�%-�^�^�$4�B�	8���
�,�,�
�
�
�
)�
)�1F�
F�
�
#�
#�
�X�]�]�O�$�	���
	�!�!��8�=�=�/�"��	�r-c�0�eZdZdZddd�Zed��Zd�Zy)�UpgradeBetarz
{description}a�          To start the upgrade process for a 1st gen function `foo` and create a Cloud Run function copy, run:

            $ {command} foo --setup-config

          Once you are ready to redirect traffic to the Cloud Run function copy, run:

            $ {command} foo --redirect-traffic

          If you find you need to do more local testing you can rollback traffic to the 1st gen copy:

            $ {command} foo --rollback-traffic

          Once you're ready to finish upgrading and delete the 1st gen copy, run:

            $ {command} foo --commit

          You can abort the upgrade process at any time by running:

            $ {command} foo --abort
          )�DESCRIPTION�EXAMPLESc�Z�tj|d�tj|�y)Nz
to upgrade)r
�AddFunctionResourceArg�AddUpgradeFlags)�parsers r+�ArgszUpgradeBeta.Args	s ��	� � ���6�	���&�!r-c�F	�tj|j��}|jjj�}|j
�}|j|�}|s$tjdj|���|jst|�|jj}tj|�dk(r:tjd|j�d|j j"�d���d}d}|j$rt&}|j(}n�|j*rt,}|j.}nu|j0rt2}|j4}nV|j6rt8}|j:}n7|j<rt>}|j@}ntCjDgd�d��tG||�|jHj|�}	tKjL|	d�	�sy|t>k(r�tOjPd
�tOjPd�|jR}
|
s"|jTrtCjVdd
��|
r3tYjZ|
j\�rt_j`�|
r>tYjb|
j\�rt_jd|
jf�|||jT�}n||�}|jh}tkjl|jn|jp||�trjtjw�|t>k(r�|j|�}|jRr5tyjz|tkj|�|jTd��trjtjw|j~j|jj�j���y|t2k(rpt�j�|�}
dj�d�|
j�D��}trjtjw|j~j|��ytrjtjw|j~�y)NzFunction [{}] does not exist.�)INELIGIBLE_FOR_UPGRADE_UNTIL_REDEPLOYMENTr0z?] is not eligible for Cloud Run function upgrade. The runtime [z�] is not supported. Please update to a supported runtime instead and try again. Use `gcloud functions runtimes list` to get a list of available runtimes.)z--abortz--commitz--redirect-trafficz--rollback-trafficz--setup-configz*One of the upgrade step must be specified.T)�defaultzcloudbuild.googleapis.comzartifactregistry.googleapis.comz--trigger-service-accountzLTrigger service account can only be specified for event-triggered functions.F)�is_gen2�c3�(K�|]
}d|�d����y�w)z* �
N�)�.0r8s  r+�	<genexpr>z"UpgradeBeta.Run.<locals>.<genexpr>{s����B�\�c�r�#��b�\�\�s�)F�	client_v2�FunctionsClient�ReleaseTrack�CONCEPTSr4�Parse�RelativeName�GetFunctionr	r%r&�upgradeInfor=�upgradeStater#r$�buildConfig�runtime�redirect_traffic�_REDIRECT_TRAFFIC_ACTION�RedirectFunctionUpgradeTraffic�rollback_traffic�_ROLLBACK_TRAFFIC_ACTION�RollbackFunctionUpgradeTraffic�commit�_COMMIT_ACTION�CommitFunctionUpgrade�abort�
_ABORT_ACTION�AbortFunctionUpgrade�setup_config�_SETUP_CONFIG_ACTION�SetupFunctionUpgradeConfig�calliope_exceptions�OneOfArgumentsRequiredExceptionr,rr�PromptContinuer�PromptToEnableApiIfDisabledr9�trigger_service_account�InvalidArgumentException�
trigger_types�IsPubsubTyper:r�'ensure_pubsub_sa_has_token_creator_role�IsAuditLogType�#ensure_data_access_logs_are_enabled�eventFiltersrr5�WaitForOperationr�messagesr�status�Printr�$ValidateAndBindTriggerServiceAccountr6r�
serviceConfig�urir�
GetService�join�urls)�self�argsr�function_ref�
function_namer<r(r)�	action_fn�message�trigger�	operation�description�service�urls_stringss               r+�RunzUpgradeBeta.Runs���
�
&�
&�t�'8�'8�':�
;�F��=�=�%�%�+�+�-�L� �-�-�/�M��!�!�-�0�H���%�%�
)�
0�
0��
?�
�����&�x�0��(�(�5�5�M�	�
�
�m�$�6�	7�
�%�%��x�}�}�o�&$�$,�$8�$8�$@�$@�#A�B!�!�
���F��I����'�f��7�7�i�	
�	�	�'�f��7�7�i�	
����f��.�.�i�	
����f��-�-�i�	
�	�	�#�f��3�3�i��?�?��7�	
�	��]�F�3����&�&�}�5�G��$�$�W�d�;��
�%�%��0�0�1L�M��0�0�
+���%�%�g�
��5�5�!�:�:�'�
*�
�	
�

�]�/�/��0A�0A�B��;�;�=�	�]�1�1�'�2C�2C�D��7�7��8L�8L�M��M�4�+G�+G�H�i��M�*�i��'�'�K�����
�
�v���	�;���J�J����
�%�%��#�#�M�2�h�	�	�	�	�A�A�����!��(�(��		
�
�j�j���
�
�
�
#�
#�H�$8�$8�$F�$F�$J�$J�
K��
�>�	!��#�#�H�-�g��W�W�B�W�\�\�B�B�l�	�j�j���v�)�)�0�0��>�?�	�j�j���v�)�)�*r-N)�__name__�
__module__�__qualname__�__doc__�
detailed_help�staticmethodrFr�rNr-r+r?r?�s3��D�%���-�2�"��"�p+r-r?c��eZdZdZy)�UpgradeAlpharN)r�r�r�r�rNr-r+r�r��s��Dr-r�)3r��
__future__rrr�collections� googlecloudsdk.api_lib.functionsr�#googlecloudsdk.api_lib.functions.v2rrQr	r
r5�googlecloudsdk.callioperrk�#googlecloudsdk.command_lib.eventarcrrq�$googlecloudsdk.command_lib.functionsr
rr�'googlecloudsdk.command_lib.functions.v2r�googlecloudsdk.corer�googlecloudsdk.core.consolerr#r;�
namedtupler�_ABORT_GUIDANCE_MSGrir]r`rfrcr'r,r=�DefaultUniverseOnly�
ReleaseTracksrS�BETA�Commandr?�ALPHAr�rNr-r+�<module>r�s'��B�&��'��;�C�:�@�(�E�F�6�9�E�?�#�2�
���
'��&�&����
���
%�;�	O�	�
�����2)�?�	+�D�
�����$)�;�	"�C�
�
���� �/�	.�8�N�
�
���	>�	M�	=���(&:�$:�%'� ��1�
	��,�&3�O�� ��5�	!��0�
	!��0�+-�&4�%5�5��<�2�D�������D�%�%�*�*�+�Q+�$�,�,�Q+�,��Q+�h�������D�%�%�+�+�,�D�;�D�-��Dr-