pub fn validate_k8s_manifest(content: &str) -> ValidationResultExpand description
Validate a Kubernetes manifest (all supported resource kinds) via serde.
Detects the resource kind from the YAML and dispatches to the appropriate
typed struct validator. For known kinds this provides structural validation
(required fields, type checks) plus semantic warnings (replicas=1,
missing resource limits, :latest image tags, etc.).
Unknown kind values are accepted as valid with a warning.
ยงExample
use devops_validate::validator::validate_k8s_manifest;
let yaml = r#"
apiVersion: apps/v1
kind: Deployment
metadata:
name: test
spec:
replicas: 1
selector:
matchLabels:
app: test
template:
metadata:
labels:
app: test
spec:
containers:
- name: app
image: test:latest
"#;
let result = validate_k8s_manifest(yaml);
assert!(result.valid);
assert!(!result.warnings.is_empty()); // warns on replicas=1 and :latest