@@ -81,46 +81,40 @@ impl Registry {
8181 }
8282 }
8383
84- pub async fn push (
84+ async fn monolithic_push (
8585 & mut self ,
8686 mut progress : Item ,
8787 image_ref : & Reference ,
8888 image : Image ,
8989 ) -> Result < Option < PushResponse > , PushError > {
90- let registry = image_ref . resolve_registry ( ) ;
91- self . client . store_auth_if_needed ( registry , & self . auth ) . await ;
90+ progress . init ( None , None ) ;
91+ progress . info ( "pushing image" ) ;
9292
93- if let Some ( digest) = self . try_resolve_digest ( & self . auth , image_ref) . await ? {
94- // If the digest matches the image's digest, we can skip pushing
95- if digest == image. digest {
96- progress. info ( "image already exists, skipping push" ) ;
97- return Ok ( None ) ;
98- }
99- }
93+ let image_urls = self
94+ . client
95+ . push (
96+ image_ref,
97+ & image. layers ,
98+ image. config ,
99+ & self . auth ,
100+ image. manifest . into ( ) ,
101+ )
102+ . await ?;
100103
101- if self . use_monolithic_push {
102- progress. init ( None , None ) ;
103- progress. info ( "pushing image" ) ;
104-
105- let image_urls = self
106- . client
107- . push (
108- image_ref,
109- & image. layers ,
110- image. config ,
111- & self . auth ,
112- image. manifest . into ( ) ,
113- )
114- . await ?;
115-
116- progress. done ( "image pushed" ) ;
117-
118- return Ok ( Some ( PushResponse {
119- config_url : image_urls. config_url ,
120- manifest_url : image_urls. manifest_url ,
121- } ) ) ;
122- }
104+ progress. done ( "image pushed" ) ;
105+
106+ Ok ( Some ( PushResponse {
107+ config_url : image_urls. config_url ,
108+ manifest_url : image_urls. manifest_url ,
109+ } ) )
110+ }
123111
112+ async fn layered_push (
113+ & mut self ,
114+ mut progress : Item ,
115+ image_ref : & Reference ,
116+ image : Image ,
117+ ) -> Result < Option < PushResponse > , PushError > {
124118 progress. init ( Some ( image. layers . len ( ) ) , None ) ;
125119 progress. info ( "pushing image" ) ;
126120
@@ -192,4 +186,28 @@ impl Registry {
192186 manifest_url,
193187 } ) )
194188 }
189+
190+ pub async fn push (
191+ & mut self ,
192+ mut progress : Item ,
193+ image_ref : & Reference ,
194+ image : Image ,
195+ ) -> Result < Option < PushResponse > , PushError > {
196+ let registry = image_ref. resolve_registry ( ) ;
197+ self . client . store_auth_if_needed ( registry, & self . auth ) . await ;
198+
199+ if let Some ( digest) = self . try_resolve_digest ( & self . auth , image_ref) . await ? {
200+ // If the digest matches the image's digest, we can skip pushing
201+ if digest == image. digest {
202+ progress. info ( "image already exists, skipping push" ) ;
203+ return Ok ( None ) ;
204+ }
205+ }
206+
207+ if self . use_monolithic_push {
208+ return self . monolithic_push ( progress, image_ref, image) . await ;
209+ }
210+
211+ self . layered_push ( progress, image_ref, image) . await
212+ }
195213}
0 commit comments