Skip to content

Commit

Permalink
SqsSessionStatus change (enum variants in subschema have to be of the…
Browse files Browse the repository at this point in the history
… same type)
  • Loading branch information
t4lz committed Apr 22, 2024
1 parent d636531 commit 70135b4
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mirrord/operator/src/crd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ pub struct QueueDetails {
// | ---- queue id
// ---- ConfigMap name

// TODO: Don't save whole PodSpec, because its schema is so long you can't create the CRD with
// `kubectl apply` due to a length limit.
/// The original PodSpec of the queue consumer.
pub original_spec: PodSpec,
}
Expand Down Expand Up @@ -490,24 +492,24 @@ pub struct MirrordQueueSplitterSpec {
#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)]
#[serde(rename = "SQSSessionDetails", rename_all = "camelCase")]
pub struct SqsSessionDetails {
// TODO: Don't save whole PodSpec, because its schema is so long you can't create the CRD with
// `kubectl apply` due to a length limit.
pub spec: PodSpec,
pub queue_names: HashMap<QueueId, QueueNameUpdate>,
}

#[derive(Clone, Debug, Default, Deserialize, Serialize, JsonSchema)]
#[serde(rename = "SQSSessionStatus", rename_all = "camelCase")]
pub enum SqsSessionStatus {
#[default]
Requested,
Started(SqsSessionDetails),
pub struct SqsSessionStatus {
pub details: Option<SqsSessionDetails>,
}

/// The [`kube::runtime::wait::Condition`] trait is auto-implemented for this function.
/// To be used in [`kube::runtime::wait::await_condition`].
pub fn is_session_ready(session: Option<&MirrordSqsSession>) -> bool {
session
.and_then(|session| session.status.as_ref())
.map(|status| matches!(status, SqsSessionStatus::Started(..)))
.map(|status| status.details.is_some())
.unwrap_or_default()
}

Expand Down

0 comments on commit 70135b4

Please sign in to comment.