Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

brokkr-models::models::deployment_objects Rust

Structs

brokkr-models::models::deployment_objects::DeploymentObject

pub

Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema, ``

Represents a deployment object in the database.

Fields

NameTypeDescription
idUuidUnique identifier for the deployment object.
created_atDateTime < Utc >Timestamp when the deployment object was created.
updated_atDateTime < Utc >Timestamp when the deployment object was last updated.
deleted_atOption < DateTime < Utc > >Timestamp for soft deletion, if applicable.
sequence_idi64Auto-incrementing sequence number for ordering.
stack_idUuidID of the stack this deployment object belongs to.
yaml_contentStringYAML content of the deployment.
yaml_checksumStringSHA-256 checksum of the YAML content.
submitted_atDateTime < Utc >Timestamp when the deployment was submitted.
is_deletion_markerboolIndicates if this object marks a deletion.

brokkr-models::models::deployment_objects::NewDeploymentObject

pub

Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema

Represents a new deployment object to be inserted into the database.

Fields

NameTypeDescription
stack_idUuidID of the stack this deployment object belongs to.
yaml_contentStringYAML content of the deployment.
yaml_checksumStringSHA-256 checksum of the YAML content.
is_deletion_markerboolIndicates if this object marks a deletion.

Methods

new pub
#![allow(unused)]
fn main() {
fn new (stack_id : Uuid , yaml_content : String , is_deletion_marker : bool ,) -> Result < Self , String >
}

Creates a new NewDeploymentObject instance.

Parameters:

NameTypeDescription
stack_id-UUID of the stack this deployment object belongs to.
yaml_content-YAML content of the deployment. Must be a non-empty string.
is_deletion_marker-Boolean indicating if this object marks a deletion.
generator_id-UUID of the generator associated with this deployment object.

Returns:

Returns Ok(NewDeploymentObject) if all parameters are valid, otherwise returns an Err with a description of the validation failure.

Source
#![allow(unused)]
fn main() {
    pub fn new(
        stack_id: Uuid,
        yaml_content: String,
        is_deletion_marker: bool,
    ) -> Result<Self, String> {
        // Validate stack_id
        if stack_id.is_nil() {
            return Err("Invalid stack ID".to_string());
        }

        // Validate yaml_content
        if yaml_content.trim().is_empty() {
            return Err("YAML content cannot be empty".to_string());
        }

        // Generate SHA-256 checksum
        let yaml_checksum = generate_checksum(&yaml_content);

        Ok(NewDeploymentObject {
            stack_id,
            yaml_content,
            yaml_checksum,
            is_deletion_marker,
        })
    }
}

Functions

brokkr-models::models::deployment_objects::generate_checksum

private

#![allow(unused)]
fn main() {
fn generate_checksum (content : & str) -> String
}

Helper function to generate SHA-256 checksum for YAML content.

Source
#![allow(unused)]
fn main() {
fn generate_checksum(content: &str) -> String {
    use sha2::{Digest, Sha256};
    let mut hasher = Sha256::new();
    hasher.update(content.as_bytes());
    format!("{:x}", hasher.finalize())
}
}