Skip to content

Commit

Permalink
Replace futures_util::pin_mut! with std::pin::pin!
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnavion committed Jul 26, 2023
1 parent a07798e commit 4d75f75
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 16 deletions.
3 changes: 1 addition & 2 deletions k8s-openapi-tests/src/custom_resource_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ async fn test() {
// Watch CR
{
let (request, response_body) = FooBar::watch("default", Default::default()).expect("couldn't watch FooBars");
let foo_bar_watch_events = client.get_multiple_values(request, response_body);
futures_util::pin_mut!(foo_bar_watch_events);
let foo_bar_watch_events = std::pin::pin!(client.get_multiple_values(request, response_body));
let _ =
foo_bar_watch_events
.filter_map(|foo_bar_watch_event| {
Expand Down
3 changes: 1 addition & 2 deletions k8s-openapi-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ impl Client {
request: http::Request<Vec<u8>>,
response_body: fn(http::StatusCode) -> k8s_openapi::ResponseBody<R>,
) -> (R, http::StatusCode) where R: k8s_openapi::Response {
let stream = self.get_multiple_values(request, response_body);
futures_util::pin_mut!(stream);
let mut stream = std::pin::pin!(self.get_multiple_values(request, response_body));
stream.next().await.expect("unexpected EOF")
}

Expand Down
14 changes: 6 additions & 8 deletions k8s-openapi-tests/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,23 @@ async fn get() {
})
.expect("couldn't get apiserver pod logs");
let mut apiserver_logs = String::new();
let chunks = client.get_multiple_values(request, response_body);
futures_util::pin_mut!(chunks);
let mut found_line = false;
while let Some(chunk) = chunks.next().await {
let mut chunks = std::pin::pin!(client.get_multiple_values(request, response_body));
let found_line = loop {
let Some(chunk) = chunks.next().await else { break false; };
let s = match chunk {
(api::ReadPodLogResponse::Ok(s), _) => s,
(other, status_code) => panic!("{other:?} {status_code}"),
};
apiserver_logs.push_str(&s);

if apiserver_logs.contains("Serving securely on [::]:6443") {
found_line = true;
break;
break true;
}

if apiserver_logs.len() > 65536 {
break;
break false;
}
}
};
assert!(found_line, "did not find expected text in apiserver pod logs: {apiserver_logs}");
}

Expand Down
6 changes: 2 additions & 4 deletions k8s-openapi-tests/src/watch_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ async fn watch_pods() {

let (request, response_body) =
api::Pod::watch("kube-system", Default::default()).expect("couldn't watch pods");
let pod_watch_events = client.get_multiple_values(request, response_body);
futures_util::pin_mut!(pod_watch_events);
let pod_watch_events = std::pin::pin!(client.get_multiple_values(request, response_body));

let apiserver_pod =
pod_watch_events
Expand Down Expand Up @@ -60,8 +59,7 @@ async fn watch_pods_without_initial_events() {
send_initial_events: Some(true),
..Default::default()
}).expect("couldn't watch pods");
let pod_watch_events = client.get_multiple_values(request, response_body);
futures_util::pin_mut!(pod_watch_events);
let pod_watch_events = std::pin::pin!(client.get_multiple_values(request, response_body));

let initial_events_end_annotation =
pod_watch_events
Expand Down

0 comments on commit 4d75f75

Please sign in to comment.