Skip to content

Commit 9fa37c0

Browse files
committed
Support using --debug with skopeo
To aid debugging ostreedev/ostree-rs-ext#657 This will be especially handy with containers/skopeo#2439 Signed-off-by: Colin Walters <[email protected]>
1 parent 4ac396a commit 9fa37c0

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/imageproxy.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,11 @@ pub struct ImageProxyConfig {
175175
/// If set, disable TLS verification. Equivalent to `skopeo --tls-verify=false`.
176176
pub insecure_skip_tls_verification: Option<bool>,
177177

178+
/// If enabled, propagate debug-logging level from the proxy via stderr to the
179+
/// current process' stderr. Note than when enabled, this also means that standard
180+
/// error will no longer be captured.
181+
pub debug: bool,
182+
178183
/// Provide a configured [`std::process::Command`] instance.
179184
///
180185
/// This allows configuring aspects of the resulting child `skopeo` process.
@@ -202,6 +207,7 @@ impl TryFrom<ImageProxyConfig> for Command {
202207
type Error = Error;
203208

204209
fn try_from(config: ImageProxyConfig) -> Result<Self> {
210+
let debug = config.debug || std::env::var_os("CONTAINERS_IMAGE_PROXY_DEBUG").is_some();
205211
let mut allocated_fds = RESERVED_FD_RANGE.clone();
206212
let mut alloc_fd = || {
207213
allocated_fds.next().ok_or_else(|| {
@@ -223,6 +229,9 @@ impl TryFrom<ImageProxyConfig> for Command {
223229
c
224230
});
225231
c.arg("experimental-image-proxy");
232+
if debug {
233+
c.arg("--debug");
234+
}
226235
let auth_option_count = [
227236
config.authfile.is_some(),
228237
config.auth_data.is_some(),
@@ -276,7 +285,10 @@ impl TryFrom<ImageProxyConfig> for Command {
276285
if config.insecure_skip_tls_verification.unwrap_or_default() {
277286
c.arg("--tls-verify=false");
278287
}
279-
c.stdout(Stdio::null()).stderr(Stdio::piped());
288+
c.stdout(Stdio::null());
289+
if !debug {
290+
c.stderr(Stdio::piped());
291+
}
280292
Ok(c)
281293
}
282294
}

0 commit comments

Comments
 (0)