Skip to content

Commit

Permalink
run fmt task
Browse files Browse the repository at this point in the history
  • Loading branch information
casualjim committed Aug 13, 2023
1 parent 651b526 commit 989c286
Showing 1 changed file with 39 additions and 64 deletions.
103 changes: 39 additions & 64 deletions kube-runtime/src/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,20 +474,16 @@ where
Ok(list) => {
objects.extend(list.items);
if let Some(continue_token) = list.metadata.continue_.filter(|s| !s.is_empty()) {
(
None,
State::Empty {
continue_token: Some(continue_token),
objects,
},
)
(None, State::Empty {
continue_token: Some(continue_token),
objects,
})
} else if let Some(resource_version) =
list.metadata.resource_version.filter(|s| !s.is_empty())

Check warning on line 482 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L482

Added line #L482 was not covered by tests
{
(
Some(Ok(Event::Restarted(objects))),
State::InitListed { resource_version },
)
(Some(Ok(Event::Restarted(objects))), State::InitListed {
resource_version,

Check warning on line 485 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L485

Added line #L485 was not covered by tests
})
} else {
(Some(Err(Error::NoResourceVersion)), State::default())

Check warning on line 488 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L488

Added line #L488 was not covered by tests
}
Expand Down Expand Up @@ -530,21 +526,15 @@ where
Some(Ok(WatchEvent::Bookmark(bm))) => {
let marks_initial_end = bm.metadata.annotations.contains_key("k8s.io/initial-events-end");
if marks_initial_end {
(
Some(Ok(Event::Restarted(objects))),
State::Watching {
resource_version: bm.metadata.resource_version,
stream,
},
)
(Some(Ok(Event::Restarted(objects))), State::Watching {
resource_version: bm.metadata.resource_version,
stream,

Check warning on line 531 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L526-L531

Added lines #L526 - L531 were not covered by tests
})
} else {
(
None,
State::Watching {
resource_version: bm.metadata.resource_version,
stream,
},
)
(None, State::Watching {
resource_version: bm.metadata.resource_version,
stream,

Check warning on line 536 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L534-L536

Added lines #L534 - L536 were not covered by tests
})
}
}
Some(Ok(WatchEvent::Error(err))) => {

Check warning on line 540 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L540

Added line #L540 was not covered by tests
Expand All @@ -567,23 +557,20 @@ where
} else {
debug!("watcher error: {err:?}");

Check warning on line 558 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L558

Added line #L558 was not covered by tests
}
(
Some(Err(err).map_err(Error::WatchFailed)),
State::IntialWatch { objects, stream },
)
(Some(Err(err).map_err(Error::WatchFailed)), State::IntialWatch {
objects,
stream,

Check warning on line 562 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L560-L562

Added lines #L560 - L562 were not covered by tests
})
}
None => (None, State::default()),

Check warning on line 565 in kube-runtime/src/watcher.rs

View check run for this annotation

Codecov / codecov/patch

kube-runtime/src/watcher.rs#L565

Added line #L565 was not covered by tests
}
}
State::InitListed { resource_version } => {
match api.watch(&wc.to_watch_params(), &resource_version).await {
Ok(stream) => (
None,
State::Watching {
resource_version,
stream,
},
),
Ok(stream) => (None, State::Watching {
resource_version,
stream,
}),
Err(err) => {
if std::matches!(err, ClientErr::Api(ErrorResponse { code: 403, .. })) {
warn!("watch initlist error with 403: {err:?}");
Expand All @@ -606,36 +593,27 @@ where
if resource_version.is_empty() {
(Some(Err(Error::NoResourceVersion)), State::default())
} else {
(
Some(Ok(Event::Applied(obj))),
State::Watching {
resource_version,
stream,
},
)
(Some(Ok(Event::Applied(obj))), State::Watching {
resource_version,
stream,
})
}
}
Some(Ok(WatchEvent::Deleted(obj))) => {
let resource_version = obj.resource_version().unwrap_or_default();
if resource_version.is_empty() {
(Some(Err(Error::NoResourceVersion)), State::default())
} else {
(
Some(Ok(Event::Deleted(obj))),
State::Watching {
resource_version,
stream,
},
)
(Some(Ok(Event::Deleted(obj))), State::Watching {
resource_version,
stream,
})
}
}
Some(Ok(WatchEvent::Bookmark(bm))) => (
None,
State::Watching {
resource_version: bm.metadata.resource_version,
stream,
},
),
Some(Ok(WatchEvent::Bookmark(bm))) => (None, State::Watching {
resource_version: bm.metadata.resource_version,
stream,
}),
Some(Ok(WatchEvent::Error(err))) => {
// HTTP GONE, means we have desynced and need to start over and re-list :(
let new_state = if err.code == 410 {
Expand All @@ -659,13 +637,10 @@ where
} else {
debug!("watcher error: {err:?}");
}
(
Some(Err(err).map_err(Error::WatchFailed)),
State::Watching {
resource_version,
stream,
},
)
(Some(Err(err).map_err(Error::WatchFailed)), State::Watching {
resource_version,
stream,
})
}
None => (None, State::InitListed { resource_version }),
},
Expand Down

0 comments on commit 989c286

Please sign in to comment.