
                            S r SSKJr  SSKJr  SSKrSSKrSSKrSSKJr	  SSKJ
r
  SSKJr  SSKJr  \R                  " S	S
9r\R#                  SSSS9  \R#                  SSSSS9  \R#                  SSSS9  \R#                  SSSS9  \R#                  SSSS9  \R#                  SSSS9  \R#                  SSSS9  S r\S :X  a  \" 5         gg)!zThis package calculates the digest of an image.

The format this tool *expects* to deal with is proprietary.
Image digests aren't stable upon gzip implementation/configuration.
This tool is expected to be only self-consistent.
    )absolute_import)print_functionN)docker_image)
oci_compat)logging_setup)zipz'Calculate digest for a container image.)descriptionz	--tarballstorez&An optional legacy base image tarball.)actionhelpz--output-digestTzFilename to store digest in.)requiredr   r   z--configz.The path to the file storing the image config.z
--manifestz0The path to the file storing the image manifest.z--digestappendz,The list of layer digest filenames in order.z--layerz%The list of layer filenames in order.z--oci
store_truezImage has an OCI Manifest.c            
      P   [         R                  " [        5        [        R                  5       n [         R                  " U S9  U R
                  (       dN  U R                  (       d  U R                  (       a,  [        R                  " S5        [        R                  " S5        U R
                  (       d=  U R                  (       d,  [        R                  " S5        [        R                  " S5        U R
                  nU R                  nU R
                  (       aQ  [        R                  " SU R
                  5        [        U R
                  S5       nUR!                  5       nS S S 5        OkU R                  (       aZ  [        R                  " SU R                  5        ["        R$                  " U R                  5       nUR'                  5       nS S S 5        U R                  (       a/  [        U R                  S5       nUR!                  5       nS S S 5        [)        U R                  =(       d    / 5      [)        U R                  =(       d    / 5      :w  a,  [        R                  " S5        [        R                  " S5        [        R                  " S	5        ["        R*                  " U[-        [/        U R                  =(       d    / U R                  =(       d    / 5      5      U R                  US
9 n U R0                  (       a0  [2        R4                  " U5       nUR                  5       nS S S 5        OUR                  5       n[        U R6                  S5       nUR9                  W5        S S S 5        S S S 5        g ! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       GN= f! , (       d  f       N}= f! , (       d  f       N^= f! [:         a7  n	[        R                  " SU	5        [        R                  " S5         S n	A	NS n	A	ff = f! , (       d  f       g = f)N)argsz<Using --layer or --digest requires --config to be specified.   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.z Loading v2.2 image from disk ...)legacy_baseforeign_layers_manifestzw+zError getting digest: %s)r   DefineCommandLineArgsparser
parse_argsInitconfiglayerdigestloggingfatalsysexittarballmanifestinfoopenread
v2_2_imageFromTarballconfig_filelenFromDisklistr   ocir   
OCIFromV22output_digestwrite	Exception)
r   r   r"   readerbasev2_2_imgoci_imgr   digest_filees
             :lib/third_party/containerregistry/tools/image_digester_.pymainr8   D   s   %%f-				$$	$**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	,,12
3t{{ b$**"234,,&	( ,4	""8,>>#& -, """D)[&! *( (! 
 	 
.	- 
"	!  -,
 *)  mm.2	hhqkk!( (s   M;<N<N/P1'ON1)/OO*O;
N

N
N.1
N?	;O
O	OPO
P-P
PPP
P%__main__)__doc__
__future__r   r   argparser   r   containerregistry.client.v2_2r   r&   r   containerregistry.toolsr   	six.movesr   ArgumentParserr   add_argumentr8   __name__     r7   <module>rE      s)   ' %   
 D 4 1 		 	 9
;   &N  P   	'	  )   	9  ;
   	;  =
   	7  9
   h%L  N   L'C  E6r z& rD   