Skip to content

Commit 9ad4b36

Browse files
authored
Merge branch 'main' into support-untagged-enums
2 parents 7d6ee75 + a26e7f3 commit 9ad4b36

17 files changed

+185
-45
lines changed

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
blacklisted-names = []
1+
disallowed-names = []

examples/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ tower-http = { version = "0.3.2", features = ["trace", "decompression-gzip"] }
5050
hyper = { version = "0.14.13", features = ["client", "http1", "stream", "tcp"] }
5151
thiserror = "1.0.29"
5252
backoff = "0.4.0"
53-
clap = { version = "3.1.9", default-features = false, features = ["std", "cargo", "derive"] }
53+
clap = { version = "4.0", default-features = false, features = ["std", "cargo", "derive"] }
5454
edit = "0.1.3"
5555
tokio-stream = { version = "0.1.9", features = ["net"] }
5656

examples/crd_derive.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
99
/// Our spec for Foo
1010
///
1111
/// A struct with our chosen Kind will be created for us, using the following kube attrs
12-
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
12+
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
1313
#[kube(
1414
group = "clux.dev",
1515
version = "v1",

examples/crd_derive_schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use serde::{Deserialize, Serialize};
1919
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting
2020
// - https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#defaulting-and-nullable
2121

22-
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Clone, JsonSchema)]
22+
#[derive(CustomResource, Serialize, Deserialize, Default, Debug, PartialEq, Eq, Clone, JsonSchema)]
2323
#[kube(
2424
group = "clux.dev",
2525
version = "v1",

examples/custom_client_trace.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ async fn main() -> anyhow::Result<()> {
4242
})
4343
.on_response(|response: &Response<Body>, latency: Duration, span: &Span| {
4444
let status = response.status();
45-
span.record("http.status_code", &status.as_u16());
45+
span.record("http.status_code", status.as_u16());
4646
if status.is_client_error() || status.is_server_error() {
47-
span.record("otel.status_code", &"ERROR");
47+
span.record("otel.status_code", "ERROR");
4848
}
4949
tracing::debug!("finished in {}ms", latency.as_millis())
5050
}),

examples/dynamic_jsonpath.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ async fn main() -> anyhow::Result<()> {
2020
);
2121

2222
let pods: Api<Pod> = Api::<Pod>::all(client);
23-
let list_params = ListParams::default().fields(&*field_selector);
23+
let list_params = ListParams::default().fields(&field_selector);
2424
let list = pods.list(&list_params).await?;
2525

2626
// Use the given JSONPATH to filter the ObjectList
2727
let list_json = serde_json::to_value(&list)?;
28-
let res = jsonpath_lib::select(&list_json, &*jsonpath).unwrap();
28+
let res = jsonpath_lib::select(&list_json, &jsonpath).unwrap();
2929
info!("\t\t {:?}", res);
3030
Ok(())
3131
}

examples/kubectl.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,43 @@ use tracing::*;
2121

2222
#[derive(clap::Parser)]
2323
struct App {
24-
#[clap(long, short, arg_enum, default_value_t)]
24+
#[arg(long, short, default_value_t = OutputMode::Pretty)]
2525
output: OutputMode,
26-
#[clap(long, short)]
26+
#[arg(long, short)]
2727
file: Option<std::path::PathBuf>,
28-
#[clap(long, short = 'l')]
28+
#[arg(long, short = 'l')]
2929
selector: Option<String>,
30-
#[clap(long, short)]
30+
#[arg(long, short)]
3131
namespace: Option<String>,
32-
#[clap(long, short = 'A')]
32+
#[arg(long, short = 'A')]
3333
all: bool,
34-
#[clap(arg_enum)]
3534
verb: Verb,
3635
resource: Option<String>,
3736
name: Option<String>,
3837
}
3938

40-
#[derive(clap::ArgEnum, Clone, PartialEq, Eq)]
39+
#[derive(Clone, PartialEq, Eq, clap::ValueEnum)]
4140
enum OutputMode {
4241
Pretty,
4342
Yaml,
4443
}
45-
impl Default for OutputMode {
46-
fn default() -> Self {
47-
Self::Pretty
44+
45+
impl OutputMode {
46+
fn as_str(&self) -> &'static str {
47+
match self {
48+
Self::Pretty => "pretty",
49+
Self::Yaml => "yaml",
50+
}
51+
}
52+
}
53+
54+
impl std::fmt::Display for OutputMode {
55+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
56+
f.pad(self.as_str())
4857
}
4958
}
50-
#[derive(clap::ArgEnum, Clone, PartialEq, Eq, Debug)]
59+
60+
#[derive(Clone, PartialEq, Eq, Debug, clap::ValueEnum)]
5161
enum Verb {
5262
Get,
5363
Delete,
@@ -64,7 +74,7 @@ fn resolve_api_resource(discovery: &Discovery, name: &str) -> Option<(ApiResourc
6474
.groups()
6575
.flat_map(|group| {
6676
group
67-
.recommended_resources()
77+
.resources_by_stability()
6878
.into_iter()
6979
.map(move |res| (group, res))
7080
})

examples/pod_cp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async fn main() -> anyhow::Result<()> {
5858
// Write the data to pod
5959
{
6060
let mut header = tar::Header::new_gnu();
61-
header.set_path(&file_name).unwrap();
61+
header.set_path(file_name).unwrap();
6262
header.set_size(data.len() as u64);
6363
header.set_cksum();
6464

kube-client/src/api/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,6 @@ mod test {
254254
let _: Api<corev1::Node> = Api::all(client.clone());
255255
let _: Api<corev1::Pod> = Api::default_namespaced(client.clone());
256256
let _: Api<corev1::PersistentVolume> = Api::all(client.clone());
257-
let _: Api<corev1::ConfigMap> = Api::namespaced(client.clone(), "default");
257+
let _: Api<corev1::ConfigMap> = Api::namespaced(client, "default");
258258
}
259259
}

kube-client/src/client/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ impl TryFrom<Config> for ClientBuilder<BoxService<Request<hyper::Body>, Response
143143
})
144144
.on_response(|res: &Response<hyper::Body>, _latency: Duration, span: &Span| {
145145
let status = res.status();
146-
span.record("http.status_code", &status.as_u16());
146+
span.record("http.status_code", status.as_u16());
147147
if status.is_client_error() || status.is_server_error() {
148-
span.record("otel.status_code", &"ERROR");
148+
span.record("otel.status_code", "ERROR");
149149
}
150150
})
151151
// Explicitly disable `on_body_chunk`. The default does nothing.
@@ -159,10 +159,10 @@ impl TryFrom<Config> for ClientBuilder<BoxService<Request<hyper::Body>, Response
159159
// - Polling `Body` errored
160160
// - the response was classified as failure (5xx)
161161
// - End of stream was classified as failure
162-
span.record("otel.status_code", &"ERROR");
162+
span.record("otel.status_code", "ERROR");
163163
match ec {
164164
ServerErrorsFailureClass::StatusCode(status) => {
165-
span.record("http.status_code", &status.as_u16());
165+
span.record("http.status_code", status.as_u16());
166166
tracing::error!("failed with status {}", status)
167167
}
168168
ServerErrorsFailureClass::Error(err) => {

kube-client/src/client/tls.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ pub mod rustls_tls {
8383
use hyper_rustls::ConfigBuilderExt;
8484
use rustls::{
8585
self,
86-
client::{ServerCertVerified, ServerCertVerifier},
86+
client::{HandshakeSignatureValid, ServerCertVerified, ServerCertVerifier},
87+
internal::msgs::handshake::DigitallySignedStruct,
8788
Certificate, ClientConfig, PrivateKey,
8889
};
8990
use thiserror::Error;
@@ -194,8 +195,27 @@ pub mod rustls_tls {
194195
_ocsp_response: &[u8],
195196
_now: std::time::SystemTime,
196197
) -> Result<ServerCertVerified, rustls::Error> {
198+
tracing::warn!("Server cert bypassed");
197199
Ok(ServerCertVerified::assertion())
198200
}
201+
202+
fn verify_tls13_signature(
203+
&self,
204+
_message: &[u8],
205+
_cert: &Certificate,
206+
_dss: &DigitallySignedStruct,
207+
) -> Result<HandshakeSignatureValid, rustls::Error> {
208+
Ok(HandshakeSignatureValid::assertion())
209+
}
210+
211+
fn verify_tls12_signature(
212+
&self,
213+
_message: &[u8],
214+
_cert: &Certificate,
215+
_dss: &DigitallySignedStruct,
216+
) -> Result<HandshakeSignatureValid, rustls::Error> {
217+
Ok(HandshakeSignatureValid::assertion())
218+
}
199219
}
200220
}
201221

kube-client/src/config/file_config.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub struct Kubeconfig {
5151

5252
/// Preferences stores extensions for cli.
5353
#[derive(Clone, Debug, Serialize, Deserialize)]
54-
#[cfg_attr(test, derive(PartialEq))]
54+
#[cfg_attr(test, derive(PartialEq, Eq))]
5555
pub struct Preferences {
5656
/// Enable colors
5757
#[serde(skip_serializing_if = "Option::is_none")]
@@ -63,7 +63,7 @@ pub struct Preferences {
6363

6464
/// NamedExtention associates name with extension.
6565
#[derive(Clone, Debug, Serialize, Deserialize)]
66-
#[cfg_attr(test, derive(PartialEq))]
66+
#[cfg_attr(test, derive(PartialEq, Eq))]
6767
pub struct NamedExtension {
6868
/// Name of extension
6969
pub name: String,
@@ -73,7 +73,7 @@ pub struct NamedExtension {
7373

7474
/// NamedCluster associates name with cluster.
7575
#[derive(Clone, Debug, Serialize, Deserialize)]
76-
#[cfg_attr(test, derive(PartialEq))]
76+
#[cfg_attr(test, derive(PartialEq, Eq))]
7777
pub struct NamedCluster {
7878
/// Name of cluster
7979
pub name: String,
@@ -83,7 +83,7 @@ pub struct NamedCluster {
8383

8484
/// Cluster stores information to connect Kubernetes cluster.
8585
#[derive(Clone, Debug, Serialize, Deserialize)]
86-
#[cfg_attr(test, derive(PartialEq))]
86+
#[cfg_attr(test, derive(PartialEq, Eq))]
8787
pub struct Cluster {
8888
/// The address of the kubernetes cluster (https://hostname:port).
8989
pub server: String,
@@ -209,13 +209,13 @@ pub struct AuthInfo {
209209
#[cfg(test)]
210210
impl PartialEq for AuthInfo {
211211
fn eq(&self, other: &Self) -> bool {
212-
serde_json::to_value(&self).unwrap() == serde_json::to_value(&other).unwrap()
212+
serde_json::to_value(self).unwrap() == serde_json::to_value(other).unwrap()
213213
}
214214
}
215215

216216
/// AuthProviderConfig stores auth for specified cloud provider.
217217
#[derive(Clone, Debug, Serialize, Deserialize)]
218-
#[cfg_attr(test, derive(PartialEq))]
218+
#[cfg_attr(test, derive(PartialEq, Eq))]
219219
pub struct AuthProviderConfig {
220220
/// Name of the auth provider
221221
pub name: String,
@@ -225,7 +225,7 @@ pub struct AuthProviderConfig {
225225

226226
/// ExecConfig stores credential-plugin configuration.
227227
#[derive(Clone, Debug, Serialize, Deserialize)]
228-
#[cfg_attr(test, derive(PartialEq))]
228+
#[cfg_attr(test, derive(PartialEq, Eq))]
229229
pub struct ExecConfig {
230230
/// Preferred input version of the ExecInfo.
231231
///
@@ -247,7 +247,7 @@ pub struct ExecConfig {
247247

248248
/// NamedContext associates name with context.
249249
#[derive(Clone, Debug, Serialize, Deserialize)]
250-
#[cfg_attr(test, derive(PartialEq))]
250+
#[cfg_attr(test, derive(PartialEq, Eq))]
251251
pub struct NamedContext {
252252
/// Name of the context
253253
pub name: String,
@@ -257,7 +257,7 @@ pub struct NamedContext {
257257

258258
/// Context stores tuple of cluster and user information.
259259
#[derive(Clone, Debug, Serialize, Deserialize)]
260-
#[cfg_attr(test, derive(PartialEq))]
260+
#[cfg_attr(test, derive(PartialEq, Eq))]
261261
pub struct Context {
262262
/// Name of the cluster for this context
263263
pub cluster: String,

0 commit comments

Comments
 (0)