
    W                         d Z ddlmZ ddlmZ ddlmZ ddlZddlmZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ  G d d      Zy)zExtracts environment vars required for binary operations.

Binary operations like terraform tools requires extracting env vars. This file
exposes function that can be reused for extracting common env vars.
    )absolute_import)division)unicode_literalsN)
exceptions)log)
properties)GetFreshAccessToken)encodingc                       e Zd ZdZd Zd Zy)EnvironmentVariableszExtracts env vars.
  c                 $    | j                          y )N)_ExtractEnvironmentVariables)selfs    4lib/googlecloudsdk/command_lib/terraform/env_vars.py__init__zEnvironmentVariables.__init__'   s    %%'    c                    t        t        j                  j                  j                  j                               dd| _        g d}g d}t        j                  j                         D ]  \  }}||v s|| j                  |<    t        j                  j                  j                  j                         | _
        | j                  r/t        j                  dj                  | j                               y	|D ]h  }t        j                  t        j                  |      | _
        | j                  s9t        j                  dj                  | j                  |              n | j                  st!        j"                  d      y	)
zmExtractEnvironmentVariables can be used to extract environment variables required for binary operations.
    )accounttrue)GOOGLE_OAUTH_ACCESS_TOKENUSE_STRUCTURED_LOGGING)
HTTP_PROXY
http_proxyHTTPS_PROXYhttps_proxyNO_PROXYno_proxy)GOOGLE_PROJECTGOOGLE_CLOUD_PROJECTGCLOUD_PROJECTz%Setting project to {} from propertiesz!Setting project to {} from env {}zVFailed to retrieve the project id. Please specify the project id using --project flag.N)r	   r   VALUEScorer   Getenv_varsosenvironitemsprojectr   debugformatr
   GetEncodedValuer   Error)r   proxy_env_namesproject_env_namesenv_keyenv_vals        r   r   z1EnvironmentVariables._ExtractEnvironmentVariables*   s1   
  
(9(9(>(>(F(F(J(J(LM	DMO JJ,,.	O	#!(g /
 $$))11557DL||	ii7>>t||LM&'//

GD<<
))188wO  ' \\%
 	
 r   N)__name__
__module____qualname____doc__r   r    r   r   r   r   #   s    (+
r   r   )r4   
__future__r   r   r   os.pathr%   googlecloudsdk.corer   r   r   %googlecloudsdk.core.credentials.storer	   googlecloudsdk.core.utilr
   r   r5   r   r   <module>r;      s1     '  '  * # * E -2
 2
r   