Skip to content

Commit ef0d166

Browse files
committed
More docs
1 parent 8b518a0 commit ef0d166

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

crates/stackable-webhook/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,28 @@ pub enum WebhookServerError {
3838
EncodeCertificateAuthorityAsPem { source: x509_cert::der::Error },
3939
}
4040

41+
/// An HTTPS server that serves a bunch of webhooks.
42+
///
43+
/// It handles TLS certificate rotation.
44+
///
45+
/// ### Example usage
46+
///
47+
/// ```
48+
/// use stackable_webhook::WebhookServer;
49+
/// use stackable_webhook::WebhookServerOptions;
50+
/// use stackable_webhook::servers::Webhook;
51+
///
52+
/// # async fn docs() {
53+
/// let mut webhooks: Vec<Box<dyn Webhook>> = vec![];
54+
///
55+
/// let webhook_options = WebhookServerOptions {
56+
/// socket_addr: WebhookServer::DEFAULT_SOCKET_ADDRESS,
57+
/// operator_namespace: "my-namespace".to_owned(),
58+
/// operator_service_name: "my-operator".to_owned(),
59+
/// };
60+
/// let webhook_server = WebhookServer::new(webhook_options, webhooks).await.unwrap();
61+
/// # }
62+
/// ```
4163
pub struct WebhookServer {
4264
options: WebhookServerOptions,
4365
webhooks: Vec<Box<dyn Webhook>>,

crates/stackable-webhook/src/servers/mutating_webhook.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ pub enum MutatingWebhookError {
4545
/// ```
4646
/// use std::sync::Arc;
4747
///
48-
/// use k8s_openapi::api::admissionregistration::v1::MutatingWebhook;
4948
/// use k8s_openapi::api::admissionregistration::v1::MutatingWebhookConfiguration;
5049
/// use k8s_openapi::api::apps::v1::StatefulSet;
5150
///
@@ -54,7 +53,7 @@ pub enum MutatingWebhookError {
5453
/// use stackable_operator::kube::core::admission::{AdmissionRequest, AdmissionResponse};
5554
/// use stackable_operator::kvp::Label;
5655
/// use stackable_webhook::WebhookServer;
57-
/// use stackable_webhook::servers::MutatingWebhookServer;
56+
/// use stackable_webhook::servers::MutatingWebhook;
5857
///
5958
/// # async fn docs() {
6059
/// // The Kubernetes client
@@ -64,7 +63,7 @@ pub enum MutatingWebhookError {
6463
/// // Read in from user input, e.g. CLI arguments
6564
/// let disable_restarter_mutating_webhook = false;
6665
///
67-
/// let mutating_webhook = Box::new(MutatingWebhookServer::new(
66+
/// let mutating_webhook = Box::new(MutatingWebhook::new(
6867
/// get_mutating_webhook_configuration(),
6968
/// my_handler,
7069
/// ctx,
@@ -82,7 +81,7 @@ pub enum MutatingWebhookError {
8281
/// let webhook_name = "pod-labeler.stackable.tech";
8382
///
8483
/// MutatingWebhookConfiguration {
85-
/// webhooks: Some(vec![MutatingWebhook {
84+
/// webhooks: Some(vec![k8s_openapi::api::admissionregistration::v1::MutatingWebhook {
8685
/// // This is checked by the stackable_webhook code
8786
/// admission_review_versions: vec!["v1".to_owned()],
8887
/// ..Default::default()

0 commit comments

Comments
 (0)