
                            d Z ddlmZ ddlmZ ddlZddl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 dd
lm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  ej0                  d      Zej5                  dddd       ej5                  ddd       ej5                  ddd       ej5                  dddd       ej5                  dd d!       ej5                  d"d d#       ej5                  d$d dd%       ej5                  d&d'd(       ej5                  d)dd*       d+Zd, Zd- Zed.k(  r" ej>                         5   e        ddd       yy# 1 sw Y   yxY w)/zThis package pushes images to a Docker Registry.

The format this tool *expects* to deal with is (unlike docker_pusher)
proprietary, however, unlike {fast,docker}_puller the signature of this tool is
compatible with docker_pusher.
    )absolute_import)print_functionN)docker_creds)docker_name)docker_image)docker_session)
oci_compat)logging_setup)patched)retry)transport_pool)zipz,Push images to a Docker Registry, faaaaaast.)descriptionz--namestorez%The name of the docker image to push.T)actionhelprequiredz	--tarballz&An optional legacy base image tarball.)r   r   z--configz.The path to the file storing the image config.z
--manifestFz0The path to the file storing the image manifest.)r   r   r   z--digestappendz,The list of layer digest filenames in order.z--layerz%The list of layer filenames in order.z--stamp-info-filezbA list of files from which to read substitutions to make in the provided --name, e.g. {BUILD_USER}z--oci
store_truez$Push the image with an OCI Manifest.z--client-config-dirzrThe path to the directory where the client configuration files are located. Overiddes the value from DOCKER_CONFIG   c           
      x   i }|xs g D ]_  }t        |      5 }|D ]C  }|j                  d      }|j                  dd      \  }}||v rt        d|d|d       |||<   E 	 ddd       a  | j                  d
i |}|rt        dj	                  | |	             t        j                  |      S # 1 sw Y   xY w)z/Perform substitutions in the provided tag name.
    z"WARNING: Duplicate value for key "z
": using ""Nz{name} was resolved to {fname})namefname )openstripsplitprintformatr   Tag)	r   filesformat_argsinfofileinfolinekeyvalueformatted_names	            7lib/third_party/containerregistry/tools/fast_pusher_.pyr$   r$   [   s    ++2+h	h4$zz$ZZQ'
U+
!$e- / C  
  4;;--.
	+22 3 ) + 
	(( 
s   A	B00B9	c            
      .
   t        j                  t               t        j                         } t        j                  |        t        | j                  | j                        }| j                  sB| j                  s| j                  r*t        j                  d       t        j                  d       | j                  s6| j                  s*t        j                  d       t        j                  d       | j                  }| j                   }| j                  rPt        j"                  d| j                         t%        | j                  d      5 }|j'                         }d d d        nd| j                  rXt        j"                  d| j                         t)        j*                  | j                        5 }|j-                         }d d d        | j                   r/t%        | j                   d      5 }|j'                         }d d d        t/        | j                  xs g       t/        | j                  xs g       k7  r*t        j                  d       t        j                  d       | j0                  )t2        j4                  j7                  | j0                         t9        j:                         }|j=                  t>        j@                        }tC        j@                  |jD                  tF        	      }t        j"                  d
       t)        jH                  |tK        tM        | j                  xs g | j                  xs g             | j                  |      5 }	 t2        j4                  jO                  |      }		 tS        jT                  |	|tF              5 }t        j"                  d       | jV                  r@tY        jZ                  |      5 }|j]                  |       |j                         }d d d        n!|j]                  |       |j                         }t_        dja                  |             d d d        d d d        y # 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   dxY w# tP        $ r7}
t        j                  d||
       t        j                  d       Y d }
~
0d }
~
ww xY w# 1 sw Y   xY w# 1 sw Y   xY w# tP        $ r6}
t        j                  d||
       t        j                  d       Y d }
~
d }
~
ww xY w# 1 sw Y   y xY w)N)argsz<Using --layer or --digest requires --config to be specified.r   z/Either --config or --tarball must be specified.zReading config from %rrzReading config from tarball %rz0--digest and --layer must have matching lengths.)sizez Loading v2.2 image from disk ...)legacy_baseforeign_layers_manifestz&Error resolving credentials for %s: %s)threadszStarting upload ...z*{name} was published with digest: {digest})r   digestzError publishing %s: %s)1r
   DefineCommandLineArgsparser
parse_argsInitr$   r   stamp_info_fileconfiglayerr5   loggingfatalsysexittarballmanifestr(   r   read
v2_2_imageFromTarballconfig_filelenclient_config_dirr   DefaultKeychainsetCustomConfigDirr   FactoryWithSourceTransportCallablehttplib2Httpr   Build_THREADSFromDisklistr   Resolve	Exceptionr   Pushocir	   
OCIFromV22uploadr"   r#   )r/   r   r;   rB   readerbaseretry_factory	transportv2_2_imgcredsesessionoci_imgr5   s                 r-   mainrb   q   s   %%f-				$$
 
TYY,,	-$	$**MMFHHHQK	T\\MMCDHHQK ;;&]](	[[LL)4;;7	dkk3	6{{}f 
 	||LL14<<@				-!f 
. 
]]	dmmS	!Vh 
" 		s4::#344MMDEHHQK 
'  33D4J4JK--/-;;HMMJ-!!-"5"5HE)	,,12
3t{{ b$**"234,,&	( ,4**2248e
y(47>*+88$$X.'NN7#^^%F /. ..
"??$&;BBf C & 	(4( (3 
 	 
.	- 
"	!6  mm<dAF	hhqkk /.	4 4  mm-tQ7	hhqkk;( (s   Q3Q.Q!TQ.:S	7R="R10AR=6S	QQ!Q+.	R.7,R)#T)R..T1R:6R==S	S			T,T>TTTT__main__) __doc__
__future__r   r   argparser=   r?   containerregistry.clientr   r   containerregistry.client.v2_2r   rD   r   r	   containerregistry.toolsr
   r   containerregistry.transportr   r   rM   	six.movesr   ArgumentParserr7   add_argumentrP   r$   rb   __name__Httplib2r       r-   <module>rq      s   ' %   
 1 0 D 8 4 1 + - 6   
!	 	 >
@   W#J  
   &N  P   	9  ;
   	;	  =   	7  9
   h%L  N   >	  @   L'M  O   
6  7 ),Qh zwF  s   EE