Skip to content

Commit

Permalink
Derive additional traits
Browse files Browse the repository at this point in the history
  • Loading branch information
nightkr committed Sep 7, 2023
1 parent 5989481 commit df72972
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ All notable changes to this project will be documented in this file.

- `PodListeners` CRD ([#644]).

### Changed

- Derive `Eq` and `Copy` where applicable for listener CRDs ([#644]).

[#644]: https://github.com/stackabletech/operator-rs/pull/644

## [0.46.0] - 2023-08-08
Expand Down
24 changes: 14 additions & 10 deletions src/commons/listener.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use k8s_openapi::api::core::v1::{
use crate::builder::ListenerOperatorVolumeSourceBuilder;

/// Defines a policy for how [`Listener`]s should be exposed.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[kube(
group = "listeners.stackable.tech",
version = "v1alpha1",
Expand All @@ -55,7 +55,7 @@ pub struct ListenerClassSpec {
}

/// The method used to access the services.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq)]
pub enum ServiceType {
/// Reserve a port on each node.
NodePort,
Expand All @@ -71,7 +71,9 @@ pub enum ServiceType {
/// 1. It uses a cluster-level policy object ([`ListenerClass`]) to define how exactly the exposure works
/// 2. It has a consistent API for reading back the exposed address(es) of the service
/// 3. The [`Pod`] must mount a [`Volume`] referring to the `Listener`, which also allows us to control stickiness
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
#[derive(
CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq, Eq,
)]
#[kube(
group = "listeners.stackable.tech",
version = "v1alpha1",
Expand Down Expand Up @@ -99,7 +101,7 @@ impl ListenerSpec {
}
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ListenerPort {
/// The name of the port.
Expand All @@ -113,7 +115,7 @@ pub struct ListenerPort {
}

/// Informs users about how to reach the [`Listener`].
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ListenerStatus {
/// The backing Kubernetes [`Service`].
Expand All @@ -128,7 +130,7 @@ pub struct ListenerStatus {
}

/// One address that a [`Listener`] is accessible from.
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct ListenerIngress {
/// The hostname or IP address to the [`Listener`].
Expand All @@ -139,7 +141,7 @@ pub struct ListenerIngress {
pub ports: BTreeMap<String, i32>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "PascalCase")]
pub enum AddressType {
Hostname,
Expand All @@ -152,7 +154,9 @@ pub enum AddressType {
/// This is not expected to be created or modified by users. It will be created by
/// the Stackable Listener Operator when mounting the listener volume, and is always
/// named `pod-{pod.metadata.uid}`.
#[derive(CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default)]
#[derive(
CustomResource, Serialize, Deserialize, Clone, Debug, JsonSchema, Default, PartialEq, Eq,
)]
#[kube(
group = "listeners.stackable.tech",
version = "v1alpha1",
Expand All @@ -167,7 +171,7 @@ pub struct PodListenersSpec {
pub listeners: BTreeMap<String, PodListener>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct PodListener {
/// `Node` if this address only allows access to [`Pod`]s hosted on a specific Kubernetes [`Node`], otherwise `Cluster`.
Expand All @@ -180,7 +184,7 @@ pub struct PodListener {
pub ingress_addresses: Option<Vec<ListenerIngress>>,
}

#[derive(Serialize, Deserialize, Clone, Debug, JsonSchema)]
#[derive(Serialize, Deserialize, Clone, Copy, Debug, JsonSchema, PartialEq, Eq)]
#[serde(rename_all = "PascalCase")]
pub enum PodListenerScope {
Node,
Expand Down

0 comments on commit df72972

Please sign in to comment.