Skip to content

Commit

Permalink
Merge branch 'master' into portforward-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nightkr committed Sep 7, 2022
2 parents b6521a2 + 05f62c0 commit 3be17bf
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion kube-client/src/client/upgrade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ pub fn verify_response(res: &Response<Body>, key: &str) -> Result<(), UpgradeCon
/// This must be nonce consisting of a randomly selected 16-byte value in base64.
pub fn sec_websocket_key() -> String {
let r: [u8; 16] = rand::random();
base64::encode(&r)
base64::encode(r)
}
4 changes: 2 additions & 2 deletions kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ fn load_from_base64_or_file<P: AsRef<Path>>(
}

fn load_from_base64(value: &str) -> Result<Vec<u8>, LoadDataError> {
base64::decode(&value).map_err(LoadDataError::DecodeBase64)
base64::decode(value).map_err(LoadDataError::DecodeBase64)
}

fn load_from_file<P: AsRef<Path>>(file: &P) -> Result<Vec<u8>, LoadDataError> {
fs::read(&file).map_err(|source| LoadDataError::ReadFile(source, file.as_ref().into()))
fs::read(file).map_err(|source| LoadDataError::ReadFile(source, file.as_ref().into()))
}

// Ensure there is a trailing newline in the blob
Expand Down
4 changes: 2 additions & 2 deletions kube-client/src/config/incluster_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ pub fn token_file() -> String {

/// Returns certification from specified path in cluster.
pub fn load_cert() -> Result<Vec<Vec<u8>>, Error> {
let certs = std::fs::read(&SERVICE_CERTFILE).map_err(Error::ReadCertificateBundle)?;
let certs = std::fs::read(SERVICE_CERTFILE).map_err(Error::ReadCertificateBundle)?;
super::certs(&certs).map_err(Error::ParseCertificates)
}

/// Returns the default namespace from specified path in cluster.
pub fn load_default_ns() -> Result<String, Error> {
std::fs::read_to_string(&SERVICE_DEFAULT_NS).map_err(Error::ReadDefaultNamespace)
std::fs::read_to_string(SERVICE_DEFAULT_NS).map_err(Error::ReadDefaultNamespace)
}
10 changes: 5 additions & 5 deletions kube-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ mod test {

let pp = PostParams::default();
match pods.create(&pp, &p).await {
Ok(o) => assert_eq!(p.name(), o.name()),
Ok(o) => assert_eq!(p.name_unchecked(), o.name_unchecked()),
Err(crate::Error::Api(ae)) => assert_eq!(ae.code, 409), // if we failed to clean-up
Err(e) => return Err(e.into()), // any other case if a failure
}
Expand Down Expand Up @@ -276,7 +276,7 @@ mod test {
// Delete it
let dp = DeleteParams::default();
pods.delete("busybox-kube1", &dp).await?.map_left(|pdel| {
assert_eq!(pdel.name(), "busybox-kube1");
assert_eq!(pdel.name_unchecked(), "busybox-kube1");
});

Ok(())
Expand Down Expand Up @@ -311,7 +311,7 @@ mod test {
}))?;

match pods.create(&Default::default(), &p).await {
Ok(o) => assert_eq!(p.name(), o.name()),
Ok(o) => assert_eq!(p.name_unchecked(), o.name_unchecked()),
Err(crate::Error::Api(ae)) => assert_eq!(ae.code, 409), // if we failed to clean-up
Err(e) => return Err(e.into()), // any other case if a failure
}
Expand Down Expand Up @@ -388,7 +388,7 @@ mod test {
// Delete it
let dp = DeleteParams::default();
pods.delete("busybox-kube2", &dp).await?.map_left(|pdel| {
assert_eq!(pdel.name(), "busybox-kube2");
assert_eq!(pdel.name_unchecked(), "busybox-kube2");
});

Ok(())
Expand Down Expand Up @@ -425,7 +425,7 @@ mod test {
}))?;

match pods.create(&Default::default(), &p).await {
Ok(o) => assert_eq!(p.name(), o.name()),
Ok(o) => assert_eq!(p.name_unchecked(), o.name_unchecked()),
Err(crate::Error::Api(ae)) => assert_eq!(ae.code, 409), // if we failed to clean-up
Err(e) => return Err(e.into()), // any other case if a failure
}
Expand Down
2 changes: 1 addition & 1 deletion kube-core/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ mod test {
assert_eq!(mypod.types.as_ref().unwrap().api_version, "v1");

assert_eq!(mypod.namespace().unwrap(), "dev");
assert_eq!(mypod.name(), "blog");
assert_eq!(mypod.name_unchecked(), "blog");
assert!(mypod.status().is_none());
assert_eq!(mypod.spec().containers[0], ContainerSimple {
image: "blog".into()
Expand Down
2 changes: 1 addition & 1 deletion kube-core/src/params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ where
}
#[cfg(test)]
mod test {
use super::{DeleteParams, PatchParams, ValidationDirective};
use super::{DeleteParams, PatchParams};
#[test]
fn delete_param_serialize() {
let mut dp = DeleteParams::default();
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/src/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ mod future_hash_map;
mod runner;

#[derive(Debug, Error)]
pub enum Error<ReconcilerErr: std::error::Error + 'static, QueueErr: std::error::Error + 'static> {
pub enum Error<ReconcilerErr: 'static, QueueErr: 'static> {
#[error("tried to reconcile object {0} that was not found in local store")]
ObjectNotFound(ObjectRef<DynamicObject>),
#[error("reconciler for object {1} failed")]
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/src/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ where
}
}

match scheduler.poll_pop_queue_message(cx, &can_take_message) {
match scheduler.poll_pop_queue_message(cx, can_take_message) {
Poll::Ready(expired) => Poll::Ready(Some(expired)),
Poll::Pending => Poll::Pending,
}
Expand Down
4 changes: 4 additions & 0 deletions kube-runtime/src/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,15 @@ where
{
type Item = Case;

#[allow(clippy::mut_mutex_lock)]
fn poll_next(
self: std::pin::Pin<&mut Self>,
cx: &mut std::task::Context<'_>,
) -> std::task::Poll<Option<Self::Item>> {
let this = self.project();
// this code triggers false positive in Clippy
// https://github.com/rust-lang/rust-clippy/issues/9415
// TODO: remove #[allow] once fix reaches nightly.
let inner = this.inner.lock().unwrap();
let mut inner = Pin::new(inner);
let inner_peek = inner.as_mut().peek();
Expand Down
5 changes: 4 additions & 1 deletion kube/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ mod test {
}))?;

let pp = PostParams::default();
assert_eq!(data.name(), pods.create(&pp, &data).await?.name());
assert_eq!(
data.name_unchecked(),
pods.create(&pp, &data).await?.name_unchecked()
);

// Watch it phase for a few seconds
let is_running = await_condition(pods.clone(), "busybox-kube4", conditions::is_pod_running());
Expand Down

0 comments on commit 3be17bf

Please sign in to comment.