-
-
Notifications
You must be signed in to change notification settings - Fork 16
feat!: Add working conversion webhook with cert rotation #1066
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
base: main
Are you sure you want to change the base?
Changes from 36 commits
0ef29ab
ed58563
3be083e
fd4d94b
b3c17b3
bdbcee0
b4c22b0
31b128b
b84cf05
0390680
2e1d085
3f8e744
6f0040c
941ee6b
0c52f5f
2ec9b73
a8a2381
9089385
4671a41
a3b3cc1
f8683e4
457dbf3
a39ee47
6210262
dcb22bd
f1fee5d
caddffb
7450d85
ac29c0e
51321f0
082a59d
c032633
8dedf5a
9da5588
758202f
29b0c6c
8b83131
e9e182e
fe1749d
3894d3b
0936315
99f1dfe
daac003
0e1a160
8dc1235
f87c468
d8765d8
0c490c2
4e4cc70
0dd99ed
5e41bf1
320e821
221bc36
37818fd
c925bd0
8c13fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,7 +116,7 @@ use product_config::ProductConfigManager; | |
use snafu::{ResultExt, Snafu}; | ||
use stackable_telemetry::tracing::TelemetryOptions; | ||
|
||
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts}; | ||
use crate::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions}; | ||
|
||
pub const AUTHOR: &str = "Stackable GmbH - [email protected]"; | ||
|
||
|
@@ -163,10 +163,10 @@ pub enum Command<Run: Args = ProductOperatorRun> { | |
/// Can be embedded into an extended argument set: | ||
/// | ||
/// ```rust | ||
/// # use stackable_operator::cli::{Command, ProductOperatorRun, ProductConfigPath}; | ||
/// # use stackable_operator::cli::{Command, OperatorEnvironmentOptions, ProductOperatorRun, ProductConfigPath}; | ||
/// # use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOptions}; | ||
/// # use stackable_telemetry::tracing::TelemetryOptions; | ||
/// use clap::Parser; | ||
/// use stackable_operator::{namespace::WatchNamespace, utils::cluster_info::KubernetesClusterInfoOpts}; | ||
/// use stackable_telemetry::tracing::TelemetryOptions; | ||
/// | ||
/// #[derive(clap::Parser, Debug, PartialEq, Eq)] | ||
/// struct Run { | ||
|
@@ -176,17 +176,36 @@ pub enum Command<Run: Args = ProductOperatorRun> { | |
/// common: ProductOperatorRun, | ||
/// } | ||
/// | ||
/// let opts = Command::<Run>::parse_from(["foobar-operator", "run", "--name", "foo", "--product-config", "bar", "--watch-namespace", "foobar", "--kubernetes-node-name", "baz"]); | ||
/// let opts = Command::<Run>::parse_from([ | ||
/// "foobar-operator", | ||
/// "run", | ||
/// "--name", | ||
/// "foo", | ||
/// "--product-config", | ||
/// "bar", | ||
/// "--watch-namespace", | ||
/// "foobar", | ||
/// "--operator-namespace", | ||
/// "stackable-operators", | ||
/// "--operator-service-name", | ||
/// "foo-operator", | ||
/// "--kubernetes-node-name", | ||
/// "baz", | ||
/// ]); | ||
/// assert_eq!(opts, Command::Run(Run { | ||
/// name: "foo".to_string(), | ||
/// common: ProductOperatorRun { | ||
/// product_config: ProductConfigPath::from("bar".as_ref()), | ||
/// watch_namespace: WatchNamespace::One("foobar".to_string()), | ||
/// telemetry_arguments: TelemetryOptions::default(), | ||
/// cluster_info_opts: KubernetesClusterInfoOpts { | ||
/// telemetry: TelemetryOptions::default(), | ||
/// cluster_info: KubernetesClusterInfoOptions { | ||
/// kubernetes_cluster_domain: None, | ||
/// kubernetes_node_name: "baz".to_string(), | ||
/// }, | ||
/// operator_environment: OperatorEnvironmentOptions { | ||
/// operator_namespace: "stackable-operators".to_string(), | ||
/// operator_service_name: "foo-operator".to_string(), | ||
/// }, | ||
/// }, | ||
/// })); | ||
/// ``` | ||
|
@@ -220,10 +239,13 @@ pub struct ProductOperatorRun { | |
pub watch_namespace: WatchNamespace, | ||
|
||
#[command(flatten)] | ||
pub telemetry_arguments: TelemetryOptions, | ||
pub operator_environment: OperatorEnvironmentOptions, | ||
|
||
#[command(flatten)] | ||
pub telemetry: TelemetryOptions, | ||
|
||
#[command(flatten)] | ||
pub cluster_info_opts: KubernetesClusterInfoOpts, | ||
pub cluster_info: KubernetesClusterInfoOptions, | ||
} | ||
|
||
/// A path to a [`ProductConfigManager`] spec file | ||
|
@@ -281,9 +303,25 @@ impl ProductConfigPath { | |
} | ||
} | ||
|
||
#[derive(clap::Parser, Debug, PartialEq, Eq)] | ||
pub struct OperatorEnvironmentOptions { | ||
/// The namespace the operator is running in, usually `stackable-operators`. | ||
Techassi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/// | ||
/// Note that when running the operator on Kubernetes we recommend to use the | ||
/// [downward API](https://kubernetes.io/docs/concepts/workloads/pods/downward-api/) | ||
/// to let Kubernetes project the namespace as the `OPERATOR_NAMESPACE` env variable. | ||
#[arg(long, env)] | ||
pub operator_namespace: String, | ||
|
||
/// The name of the service the operator is reachable at, usually | ||
/// something like `<product>-operator`. | ||
#[arg(long, env)] | ||
pub operator_service_name: String, | ||
} | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use std::{env, fs::File}; | ||
use std::fs::File; | ||
|
||
use clap::Parser; | ||
use rstest::*; | ||
|
@@ -294,7 +332,6 @@ mod tests { | |
const USER_PROVIDED_PATH: &str = "user_provided_path_properties.yaml"; | ||
const DEPLOY_FILE_PATH: &str = "deploy_config_spec_properties.yaml"; | ||
const DEFAULT_FILE_PATH: &str = "default_file_path_properties.yaml"; | ||
const WATCH_NAMESPACE: &str = "WATCH_NAMESPACE"; | ||
|
||
#[test] | ||
fn verify_cli() { | ||
|
@@ -381,16 +418,17 @@ mod tests { | |
|
||
#[test] | ||
fn product_operator_run_watch_namespace() { | ||
// clean env var to not interfere if already set | ||
unsafe { env::remove_var(WATCH_NAMESPACE) }; | ||
|
||
// cli with namespace | ||
let opts = ProductOperatorRun::parse_from([ | ||
"run", | ||
"--product-config", | ||
"bar", | ||
"--watch-namespace", | ||
"foo", | ||
"--operator-namespace", | ||
"stackable-operators", | ||
"--operator-service-name", | ||
"foo-operator", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. note: I still feel like all these CLI unit tests are pretty much useless and should be removed to speed up the testing runs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think they have a noticeable effect on the test runtime. Compare to the really slow doc tests, those take 1000x longer (not joking ^^) |
||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
|
@@ -399,11 +437,15 @@ mod tests { | |
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::One("foo".to_string()), | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
cluster_info: KubernetesClusterInfoOptions { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
telemetry: Default::default(), | ||
operator_environment: OperatorEnvironmentOptions { | ||
operator_namespace: "stackable-operators".to_string(), | ||
operator_service_name: "foo-operator".to_string(), | ||
} | ||
} | ||
); | ||
|
||
|
@@ -412,6 +454,10 @@ mod tests { | |
"run", | ||
"--product-config", | ||
"bar", | ||
"--operator-namespace", | ||
"stackable-operators", | ||
"--operator-service-name", | ||
"foo-operator", | ||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
|
@@ -420,33 +466,15 @@ mod tests { | |
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::All, | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
} | ||
); | ||
|
||
// env with namespace | ||
unsafe { env::set_var(WATCH_NAMESPACE, "foo") }; | ||
let opts = ProductOperatorRun::parse_from([ | ||
"run", | ||
"--product-config", | ||
"bar", | ||
"--kubernetes-node-name", | ||
"baz", | ||
]); | ||
assert_eq!( | ||
opts, | ||
ProductOperatorRun { | ||
product_config: ProductConfigPath::from("bar".as_ref()), | ||
watch_namespace: WatchNamespace::One("foo".to_string()), | ||
cluster_info_opts: KubernetesClusterInfoOpts { | ||
cluster_info: KubernetesClusterInfoOptions { | ||
kubernetes_cluster_domain: None, | ||
kubernetes_node_name: "baz".to_string() | ||
}, | ||
telemetry_arguments: Default::default(), | ||
telemetry: Default::default(), | ||
operator_environment: OperatorEnvironmentOptions { | ||
operator_namespace: "stackable-operators".to_string(), | ||
operator_service_name: "foo-operator".to_string(), | ||
} | ||
} | ||
); | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.