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
| Name | Type | Description |
|---|---|---|
id | Uuid | Unique identifier for the deployment object. |
created_at | DateTime < Utc > | Timestamp when the deployment object was created. |
updated_at | DateTime < Utc > | Timestamp when the deployment object was last updated. |
deleted_at | Option < DateTime < Utc > > | Timestamp for soft deletion, if applicable. |
sequence_id | i64 | Auto-incrementing sequence number for ordering. |
stack_id | Uuid | ID of the stack this deployment object belongs to. |
yaml_content | String | YAML content of the deployment. |
yaml_checksum | String | SHA-256 checksum of the YAML content. |
submitted_at | DateTime < Utc > | Timestamp when the deployment was submitted. |
is_deletion_marker | bool | Indicates 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
| Name | Type | Description |
|---|---|---|
stack_id | Uuid | ID of the stack this deployment object belongs to. |
yaml_content | String | YAML content of the deployment. |
yaml_checksum | String | SHA-256 checksum of the YAML content. |
is_deletion_marker | bool | Indicates 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:
| Name | Type | Description |
|---|---|---|
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())
}
}