Skip to content

Commit 94bd227

Browse files
committed
Use main request method for semver checking
Previously I refactored the code to have `impl_request_raw` to check the semver so we could do the child process checking at the same time. But now that that's a default part of the main request flow, clean things up here make the semver call not special.
1 parent 056ced4 commit 94bd227

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/imageproxy.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -117,23 +117,14 @@ impl ImageProxy {
117117
let mut c = tokio::process::Command::from(c);
118118
c.kill_on_drop(true);
119119
let child = c.spawn().context("Failed to spawn skopeo")?;
120-
let mut childwait = Box::pin(child.wait_with_output());
120+
let childwait = Box::pin(child.wait_with_output());
121121

122122
let sockfd = Arc::new(Mutex::new(mysock));
123123

124+
let mut r = Self { sockfd, childwait };
125+
124126
// Verify semantic version
125-
let protoreq =
126-
Self::impl_request_raw::<String>(Arc::clone(&sockfd), Request::new_bare("Initialize"));
127-
let protover = tokio::select! {
128-
r = protoreq => {
129-
r?.0
130-
}
131-
r = &mut childwait => {
132-
let r = r?;
133-
let stderr = String::from_utf8_lossy(&r.stderr);
134-
return Err(anyhow!("skopeo exited unexpectedly (no support for `experimental-image-proxy`?): {}\n{}", r.status, stderr));
135-
}
136-
};
127+
let protover = r.impl_request::<String, _, ()>("Initialize", []).await?.0;
137128
let protover = semver::Version::parse(protover.as_str())?;
138129
let supported = &*SUPPORTED_PROTO_VERSION;
139130
if !supported.matches(&protover) {
@@ -144,7 +135,6 @@ impl ImageProxy {
144135
));
145136
}
146137

147-
let r = Self { sockfd, childwait };
148138
Ok(r)
149139
}
150140

0 commit comments

Comments
 (0)