devops-models 0.1.0

Typed serde models for DevOps configuration formats: Kubernetes, Docker Compose, GitLab CI, GitHub Actions, Prometheus, Alertmanager, Helm, Ansible, and OpenAPI.
Documentation

devops-models

Crates.io docs.rs License: MIT OR Apache-2.0

Typed serde models for common DevOps configuration formats.

Zero browser dependencies — works in any Rust target: native CLIs, CI/CD plugins, cloud functions, and WASM.

Supported formats

Format Types
Kubernetes Deployment, Service, ConfigMap, Secret, Ingress, HPA, CronJob, Job, PVC, NetworkPolicy, StatefulSet, DaemonSet, Role, ClusterRole, RoleBinding, ClusterRoleBinding, ServiceAccount
CI/CD GitLab CI pipelines, GitHub Actions workflows
Containers Docker Compose
Monitoring Prometheus, Alertmanager
Configuration Helm values, Ansible playbooks
API OpenAPI 3.x
LLM ChatMessage, ChatRequest/Response, LlmProvider, LlmConfig

Quick start

[dependencies]
devops-models = "0.1"

Parse a Kubernetes Deployment

use devops_models::models::k8s::K8sDeployment;

let yaml = r#"
apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
  namespace: production
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: my-app:v1.2.3
          resources:
            limits:
              memory: "256Mi"
              cpu: "500m"
"#;

let deployment: K8sDeployment = serde_yaml::from_str(yaml).unwrap();
println!("Replicas: {:?}", deployment.spec.replicas);

Validate with the ConfigValidator trait

All models implement ConfigValidator, which provides structure + semantic validation:

use devops_models::models::validation::ConfigValidator;
use devops_models::models::k8s_workloads::K8sCronJob;

let cronjob: K8sCronJob = serde_yaml::from_str(yaml).unwrap();
let result = cronjob.validate();

if !result.valid {
    for err in &result.errors {
        eprintln!("Error: {}", err);
    }
}
for warn in &result.warnings {
    println!("Warning: {}", warn);
}

Parse a Docker Compose file

use devops_models::models::docker_compose::DockerCompose;

let compose: DockerCompose = serde_yaml::from_str(yaml).unwrap();

LLM configuration

use devops_models::llm::provider::{LlmConfig, LlmProvider};

let config = LlmConfig {
    provider: LlmProvider::Anthropic,
    api_key: "sk-ant-...".to_string(),
    model: "claude-sonnet-4-20250514".to_string(),
    base_url: None,
};

println!("Endpoint: {}", config.endpoint());

Error handling

use devops_models::{DevopsError, Result};

fn parse_k8s(yaml: &str) -> Result<()> {
    serde_yaml::from_str::<serde_json::Value>(yaml)
        .map_err(|e| DevopsError::YamlParse(e.to_string()))?;
    Ok(())
}

Feature flags

This crate has no optional feature flags — all types are always available and have no platform-specific dependencies.

Relationship to other crates

License

Licensed under either of MIT or Apache-2.0, at your option.