brokkr-models::models::rendered_deployment_objects
Rust
Rendered Deployment Object Module
This module defines structures and methods for tracking the provenance of deployment objects created from templates.
Data Model
Rendered deployment objects track the relationship between a deployment object and the template instance that created it. This provides provenance information for auditing, debugging, and reconstruction purposes.
id: UUID, primary keydeployment_object_id: UUID, foreign key referencing thedeployment_objectstabletemplate_id: UUID, foreign key referencing thestack_templatestabletemplate_version: INTEGER, version of the template used (snapshot)template_parameters: TEXT, JSON string of parameters used for renderingcreated_at: TIMESTAMP, when the rendering occurred
Usage
When a template is instantiated with parameters, the system:
- Validates parameters against the template’s JSON Schema
- Renders the Tera template with the parameters
- Creates a deployment object with the rendered YAML
- Creates a rendered_deployment_object record to track the provenance
This allows reconstruction of how any deployment object was created and enables re-rendering with different parameters if needed.
Constraints
deployment_object_idmust be a valid, non-nil UUID.template_idmust be a valid, non-nil UUID.template_versionmust be at least 1.template_parametersmust be a valid JSON string.
Structs
Section titled “Structs”struct RenderedDeploymentObject
Section titled “struct RenderedDeploymentObject”pub
Derives: Queryable, Selectable, Identifiable, AsChangeset, Debug, Clone, Serialize, Deserialize, Eq, PartialEq, Hash, ToSchema
Represents a rendered deployment object provenance record in the database.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
id |
Uuid |
Unique identifier for this provenance record. |
deployment_object_id |
Uuid |
ID of the deployment object that was created. |
template_id |
Uuid |
ID of the template used to create the deployment object. |
template_version |
i32 |
Version of the template at the time of rendering (snapshot). |
template_parameters |
String |
JSON string of parameters used for rendering. |
created_at |
DateTime<Utc> |
Timestamp when the rendering occurred. |
struct NewRenderedDeploymentObject
Section titled “struct NewRenderedDeploymentObject”pub
Derives: Insertable, Debug, Clone, Serialize, Deserialize, ToSchema
Represents a new rendered deployment object provenance record to be inserted.
Fields
Section titled “Fields”| Name | Type | Description |
|---|---|---|
deployment_object_id |
Uuid |
ID of the deployment object that was created. |
template_id |
Uuid |
ID of the template used to create the deployment object. |
template_version |
i32 |
Version of the template at the time of rendering (snapshot). |
template_parameters |
String |
JSON string of parameters used for rendering. |
Methods
Section titled “Methods”pub
fn new( deployment_object_id: Uuid, template_id: Uuid, template_version: i32, template_parameters: String,) -> Result<Self, String>Creates a new NewRenderedDeploymentObject instance.
Parameters:
| Name | Type | Description |
|---|---|---|
deployment_object_id |
Uuid |
UUID of the deployment object created from this rendering. |
template_id |
Uuid |
UUID of the template used for rendering. |
template_version |
i32 |
Version number of the template used. |
template_parameters |
String |
JSON string of the parameters used for rendering. |
Returns:
Returns Ok(NewRenderedDeploymentObject) if all parameters are valid,
otherwise returns an Err with a description of the validation failure.
Source
pub fn new( deployment_object_id: Uuid, template_id: Uuid, template_version: i32, template_parameters: String, ) -> Result<Self, String> { // Validate deployment_object_id if deployment_object_id.is_nil() { return Err("Invalid deployment object ID".to_string()); }
// Validate template_id if template_id.is_nil() { return Err("Invalid template ID".to_string()); }
// Validate template_version if template_version < 1 { return Err("Template version must be at least 1".to_string()); }
// Validate template_parameters is valid JSON if serde_json::from_str::<serde_json::Value>(&template_parameters).is_err() { return Err("Template parameters must be valid JSON".to_string()); }
Ok(NewRenderedDeploymentObject { deployment_object_id, template_id, template_version, template_parameters, }) }