@@ -2,13 +2,18 @@ use std::io::Write;
22
33use anyhow:: Result ;
44use clap:: Parser ;
5+ use containers_image_proxy:: ImageProxyConfig ;
56use oci_spec:: image:: { Digest , ImageManifest } ;
67use tokio:: io:: AsyncReadExt ;
78
89#[ derive( clap:: Parser , Debug ) ]
910struct GetMetadataOpts {
1011 /// The skopeo-style transport:image reference
1112 reference : String ,
13+
14+ /// Disable TLS verification
15+ #[ clap( long) ]
16+ insecure : bool ,
1217}
1318
1419#[ derive( clap:: Parser , Debug ) ]
@@ -38,8 +43,19 @@ struct Metadata {
3843 manifest : ImageManifest ,
3944}
4045
46+ impl GetMetadataOpts {
47+ fn proxy_opts ( & self ) -> containers_image_proxy:: ImageProxyConfig {
48+ let mut r = ImageProxyConfig :: default ( ) ;
49+ if self . insecure {
50+ r. insecure_skip_tls_verification = Some ( true )
51+ }
52+ r
53+ }
54+ }
55+
4156async fn get_metadata ( o : GetMetadataOpts ) -> Result < ( ) > {
42- let proxy = containers_image_proxy:: ImageProxy :: new ( ) . await ?;
57+ let config = o. proxy_opts ( ) ;
58+ let proxy = containers_image_proxy:: ImageProxy :: new_with_config ( config) . await ?;
4359 let img = proxy. open_image ( & o. reference ) . await ?;
4460 let ( digest, manifest) = proxy. fetch_manifest ( & img) . await ?;
4561 let metadata = Metadata { digest, manifest } ;
@@ -71,7 +87,8 @@ async fn get_blob(o: GetBlobOpts) -> Result<()> {
7187}
7288
7389async fn fetch_container_to_devnull ( o : GetMetadataOpts ) -> Result < ( ) > {
74- let proxy = containers_image_proxy:: ImageProxy :: new ( ) . await ?;
90+ let config = o. proxy_opts ( ) ;
91+ let proxy = containers_image_proxy:: ImageProxy :: new_with_config ( config) . await ?;
7592 let img = & proxy. open_image ( & o. reference ) . await ?;
7693 let manifest = proxy. fetch_manifest ( img) . await ?. 1 ;
7794 for layer in manifest. layers ( ) {
0 commit comments