Skip to content

Commit

Permalink
fix typo on feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
XciD committed Mar 21, 2024
1 parent 10aa932 commit cdde9cb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
22 changes: 12 additions & 10 deletions kube-client/src/client/kubelet_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
client::AsyncBufRead,
Client, Error, Result,
};
use kube_core::{node_proxy::KubeletDebugParams, Request};
use kube_core::{kubelet_debug::KubeletDebugParams, Request};
use std::fmt::Debug;

/// Methods to access debug endpoints directly on `kubelet`
Expand All @@ -16,18 +16,20 @@ use std::fmt::Debug;
/// ## Warning
/// These methods require direct and insecure access to `kubelet` and is only available under the `kubelet_debug` feature.
/// End-to-end usage is explored in the [pod_log_node_proxy](./examples/pod_log_node_proxy.rs) example.
#[cfg(feature = "kubelet_debug")]
#[cfg(feature = "kubelet-debug")]
impl Client {
/// Attach to pod directly from the node
///
/// ## Warning
/// This method uses the insecure `kubelet_debug` interface.
pub async fn node_attach(
&self,
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
ap: &AttachParams,
) -> Result<AttachedProcess> {
let mut req = Request::node_attach(node_proxy_params, container, ap).map_err(Error::BuildRequest)?;
let mut req =
Request::node_attach(kubelet_debug_params, container, ap).map_err(Error::BuildRequest)?;
req.extensions_mut().insert("node_attach");
let stream = self.connect(req).await?;
Ok(AttachedProcess::new(stream, ap))
Expand All @@ -39,7 +41,7 @@ impl Client {
/// This method uses the insecure `kubelet_debug` interface.
pub async fn node_exec<I, T>(
&self,
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
command: I,
ap: &AttachParams,
Expand All @@ -49,7 +51,7 @@ impl Client {
T: Into<String>,
{
let mut req =
Request::node_exec(node_proxy_params, container, command, ap).map_err(Error::BuildRequest)?;
Request::node_exec(kubelet_debug_params, container, command, ap).map_err(Error::BuildRequest)?;
req.extensions_mut().insert("node_exec");
let stream = self.connect(req).await?;
Ok(AttachedProcess::new(stream, ap))

Check warning on line 57 in kube-client/src/client/kubelet_debug.rs

View check run for this annotation

Codecov / codecov/patch

kube-client/src/client/kubelet_debug.rs#L53-L57

Added lines #L53 - L57 were not covered by tests
Expand All @@ -61,10 +63,10 @@ impl Client {
/// This method uses the insecure `kubelet_debug` interface.
pub async fn node_portforward(
&self,
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
ports: &[u16],
) -> Result<Portforwarder> {
let mut req = Request::node_portforward(node_proxy_params, ports).map_err(Error::BuildRequest)?;
let mut req = Request::node_portforward(kubelet_debug_params, ports).map_err(Error::BuildRequest)?;
req.extensions_mut().insert("node_portforward");
let stream = self.connect(req).await?;
Ok(Portforwarder::new(stream, ports))
Expand All @@ -76,11 +78,11 @@ impl Client {
/// This method uses the insecure `kubelet_debug` interface.
pub async fn node_logs(
&self,
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
lp: &LogParams,
) -> Result<impl AsyncBufRead> {
let mut req = Request::node_logs(node_proxy_params, container, lp).map_err(Error::BuildRequest)?;
let mut req = Request::node_logs(kubelet_debug_params, container, lp).map_err(Error::BuildRequest)?;
req.extensions_mut().insert("node_log");
self.request_stream(req).await
}
Expand Down
2 changes: 1 addition & 1 deletion kube-client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub use auth::Error as AuthError;
pub use config_ext::ConfigExt;
pub mod middleware;

#[cfg(feature = "kubelet_debug")] mod kubelet_debug;
#[cfg(feature = "kubelet-debug")] mod kubelet_debug;
#[cfg(any(feature = "rustls-tls", feature = "openssl-tls"))] mod tls;

#[cfg(feature = "openssl-tls")]
Expand Down
19 changes: 11 additions & 8 deletions kube-core/src/kubelet_debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ impl KubeletDebugParams<'_> {
impl Request {
/// Attach to pod directly from the node
pub fn node_attach(
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
ap: &AttachParams,
) -> Result<http::Request<Vec<u8>>, Error> {
ap.validate()?;

let target = format!("/attach/{}/{container}?", node_proxy_params.with_uid());
let target = format!("/attach/{}/{container}?", kubelet_debug_params.with_uid());
let mut qp = form_urlencoded::Serializer::new(target);
ap.append_to_url_serializer_local(&mut qp);

Expand All @@ -50,7 +50,7 @@ impl Request {

/// Execute a command in a pod directly from the node
pub fn node_exec<I, T>(
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
command: I,
ap: &AttachParams,
Expand All @@ -61,7 +61,7 @@ impl Request {
{
ap.validate()?;

Check warning on line 62 in kube-core/src/kubelet_debug.rs

View check run for this annotation

Codecov / codecov/patch

kube-core/src/kubelet_debug.rs#L62

Added line #L62 was not covered by tests

let target = format!("/exec/{}/{container}?", node_proxy_params.with_uid());
let target = format!("/exec/{}/{container}?", kubelet_debug_params.with_uid());
let mut qp = form_urlencoded::Serializer::new(target);
ap.append_to_url_serializer_local(&mut qp);

Check warning on line 66 in kube-core/src/kubelet_debug.rs

View check run for this annotation

Codecov / codecov/patch

kube-core/src/kubelet_debug.rs#L64-L66

Added lines #L64 - L66 were not covered by tests

Expand All @@ -75,7 +75,7 @@ impl Request {

/// Forward ports of a pod directly from the node
pub fn node_portforward(
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
ports: &[u16],
) -> Result<http::Request<Vec<u8>>, Error> {
if ports.is_empty() {
Expand All @@ -99,7 +99,7 @@ impl Request {
}
}

let base_url = format!("/portForward/{}?", node_proxy_params.with_uid());
let base_url = format!("/portForward/{}?", kubelet_debug_params.with_uid());
let mut qp = form_urlencoded::Serializer::new(base_url);
qp.append_pair(
"port",
Expand All @@ -111,12 +111,15 @@ impl Request {

/// Stream logs directly from node
pub fn node_logs(
node_proxy_params: &KubeletDebugParams<'_>,
kubelet_debug_params: &KubeletDebugParams<'_>,
container: &str,
lp: &LogParams,
) -> Result<http::Request<Vec<u8>>, Error> {
// Node logs is the only one that doesn't accept an uid for pod
let target = format!("/containerLogs/{}/{container}?", node_proxy_params.without_uid());
let target = format!(
"/containerLogs/{}/{container}?",
kubelet_debug_params.without_uid()
);

let mut qp = form_urlencoded::Serializer::new(target);

Expand Down

0 comments on commit cdde9cb

Please sign in to comment.