Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

purge last missing_docs allows + fix docs errors #728

Merged
merged 2 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kube-client/src/client/auth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ pub enum Error {

/// Failed to run auth exec command
#[error("auth exec command '{cmd}' failed with status {status}: {out:?}")]
#[allow(missing_docs)]
AuthExecRun {
/// The failed command
cmd: String,
/// The exit status or exit code of the failed command
status: std::process::ExitStatus,
/// Stdout/Stderr of the failed command
out: std::process::Output,
},

Expand Down
16 changes: 15 additions & 1 deletion kube-client/src/config/file_config.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(missing_docs)]
use std::{
collections::HashMap,
fs,
Expand Down Expand Up @@ -40,8 +39,10 @@ pub struct Kubeconfig {
pub extensions: Option<Vec<NamedExtension>>,

// legacy fields TODO: remove
/// Legacy field from TypeMeta
#[serde(skip_serializing_if = "Option::is_none")]
pub kind: Option<String>,
/// Legacy field from TypeMeta
#[serde(rename = "apiVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub api_version: Option<String>,
Expand All @@ -51,8 +52,10 @@ pub struct Kubeconfig {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct Preferences {
/// Enable colors
#[serde(skip_serializing_if = "Option::is_none")]
pub colors: Option<bool>,
/// Extensions holds additional information. This is useful for extenders so that reads and writes don't clobber unknown fields.
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<NamedExtension>>,
}
Expand All @@ -61,15 +64,19 @@ pub struct Preferences {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct NamedExtension {
/// Name of extension
pub name: String,
/// Additional information for extenders so that reads and writes don't clobber unknown fields
pub extension: serde_json::Value,
}

/// NamedCluster associates name with cluster.
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct NamedCluster {
/// Name of cluster
pub name: String,
/// Information about how to communicate with a kubernetes cluster
pub cluster: Cluster,
}

Expand All @@ -79,6 +86,7 @@ pub struct NamedCluster {
pub struct Cluster {
/// The address of the kubernetes cluster (https://hostname:port).
pub server: String,
/// Skips the validity check for the server's certificate. This will make your HTTPS connections insecure.
#[serde(rename = "insecure-skip-tls-verify")]
#[serde(skip_serializing_if = "Option::is_none")]
pub insecure_skip_tls_verify: Option<bool>,
Expand All @@ -103,7 +111,9 @@ pub struct Cluster {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct NamedAuthInfo {
/// Name of the user
pub name: String,
/// Information that describes identity of the user
#[serde(rename = "user")]
pub auth_info: AuthInfo,
}
Expand Down Expand Up @@ -168,7 +178,9 @@ pub struct AuthInfo {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct AuthProviderConfig {
/// Name of the auth provider
pub name: String,
/// Auth provider configuration
pub config: HashMap<String, String>,
}

Expand Down Expand Up @@ -198,7 +210,9 @@ pub struct ExecConfig {
#[derive(Clone, Debug, Serialize, Deserialize)]
#[cfg_attr(test, derive(PartialEq))]
pub struct NamedContext {
/// Name of the context
pub name: String,
/// Associations for the context
pub context: Context,
}

Expand Down
15 changes: 11 additions & 4 deletions kube-client/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub enum Error {

/// Errors from Native TLS
#[cfg(feature = "native-tls")]
#[cfg_attr(docsrs, doc(feature = "native-tls"))]
#[cfg_attr(docsrs, doc(cfg(feature = "native-tls")))]
#[error("native tls error: {0}")]
NativeTls(#[source] crate::client::NativeTlsError),

Expand All @@ -89,18 +89,25 @@ pub enum Error {
}

#[derive(Error, Debug)]
// Redundant with the error messages and machine names
#[allow(missing_docs)]
/// Possible errors when using API discovery
pub enum DiscoveryError {
/// Invalid GroupVersion
#[error("Invalid GroupVersion: {0}")]
InvalidGroupVersion(String),

/// Missing Kind
#[error("Missing Kind: {0}")]
MissingKind(String),

/// Missing ApiGroup
#[error("Missing Api Group: {0}")]
MissingApiGroup(String),
#[error("Missing MissingResource: {0}")]

/// MissingResource
#[error("Missing Resource: {0}")]
MissingResource(String),

/// Empty ApiGroup
#[error("Empty Api Group: {0}")]
EmptyApiGroup(String),
}
58 changes: 50 additions & 8 deletions kube-core/src/response.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,93 @@
//! Generic api response types
use serde::Deserialize;
// TODO: replace with Status in k8s openapi?

/// A Kubernetes status object
#[allow(missing_docs)]
///
/// Equivalent to Status in k8s-openapi except we have have simplified options
#[derive(Deserialize, Debug)]
pub struct Status {
// TODO: typemeta
// TODO: metadata that can be completely empty (listmeta...)
/// Suggested HTTP return code (0 if unset)
#[serde(default, skip_serializing_if = "num::Zero::is_zero")]
pub code: u16,

/// Status of the operation
///
/// One of: `Success` or `Failure` - [more info](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status)
#[serde(default, skip_serializing_if = "String::is_empty")]
pub status: String,

/// A human-readable description of the status of this operation
#[serde(default, skip_serializing_if = "String::is_empty")]
pub message: String,

/// A machine-readable description of why this operation is in the “Failure” status.
///
/// If this value is empty there is no information available.
/// A Reason clarifies an HTTP status code but does not override it.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub reason: String,

/// Extended data associated with the reason.
///
/// Each reason may define its own extended details.
/// This field is optional and the data returned is not guaranteed to conform to any schema except that defined by the reason type.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub details: Option<StatusDetails>,
#[serde(default, skip_serializing_if = "num::Zero::is_zero")]
pub code: u16,
}

/// Status details object on the [`Status`] object
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
#[allow(missing_docs)]
pub struct StatusDetails {
/// The name attribute of the resource associated with the status StatusReason (when there is a single name which can be described)
#[serde(default, skip_serializing_if = "String::is_empty")]
pub name: String,

/// The group attribute of the resource associated with the status StatusReason
#[serde(default, skip_serializing_if = "String::is_empty")]
pub group: String,

/// The kind attribute of the resource associated with the status StatusReason
///
/// On some operations may differ from the requested resource Kind - [more info](https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds)
#[serde(default, skip_serializing_if = "String::is_empty")]
pub kind: String,

/// UID of the resource (when there is a single resource which can be described)
///
/// [More info](http://kubernetes.io/docs/user-guide/identifiers#uids)
#[serde(default, skip_serializing_if = "String::is_empty")]
pub uid: String,

/// The Causes vector includes more details associated with the failure
///
/// Not all StatusReasons may provide detailed causes.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub causes: Vec<StatusCause>,

/// If specified, the time in seconds before the operation should be retried.
///
/// Some errors may indicate the client must take an alternate action -
/// for those errors this field may indicate how long to wait before taking the alternate action.
#[serde(default, skip_serializing_if = "num::Zero::is_zero")]
pub retry_after_seconds: u32,
}

/// Status cause object on the [`StatusDetails`] object
#[derive(Deserialize, Debug)]
#[allow(missing_docs)]
pub struct StatusCause {
/// A machine-readable description of the cause of the error. If this value is empty there is no information available.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub reason: String,

/// A human-readable description of the cause of the error. This field may be presented as-is to a reader.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub message: String,

/// The field of the resource that has caused this error, as named by its JSON serialization
///
/// May include dot and postfix notation for nested attributes. Arrays are zero-indexed.
/// Fields may appear more than once in an array of causes due to fields having multiple errors.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub field: String,
}
Expand Down
2 changes: 1 addition & 1 deletion kube-runtime/src/wait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub mod delete {
///
/// # Errors
///
/// Returns an [`Error`] if the object was unable to be deleted, or if the wait was interrupted.
/// Returns an [`Error`](enum@super::Error) if the object was unable to be deleted, or if the wait was interrupted.
#[allow(clippy::module_name_repetitions)]
pub async fn delete_and_finalize<K: Clone + Debug + Send + DeserializeOwned + Resource + 'static>(
api: Api<K>,
Expand Down