vik 0.1.1

Vik is an issue-driven coding workflow automation tool.
//! `workspace:` section of the Workflow Definition.

use std::path::PathBuf;

use serde::{Deserialize, Serialize};

use super::WorkflowSchema;
use super::diagnose::*;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct WorkspaceSchema {
  /// Workspace home before per-workflow namespacing. Missing or null
  /// uses `VIK_HOME` when set, otherwise the OS home directory.
  /// Relative values are resolved against the workflow file directory
  /// (not cwd) at supervisor build time.
  #[serde(default)]
  pub root: Option<PathBuf>,

  #[serde(flatten)]
  unknown_fields: serde_yaml::Mapping,
}

impl Diagnose for WorkspaceSchema {
  fn diagnose(&self, _: &WorkflowSchema) -> Diagnostics {
    let mut diagnostics = Diagnostics::new();

    if let Some(root) = &self.root {
      diagnostics.error_if_empty_path("root", root);
    }
    diagnostics.warn_unknown_fields(&self.unknown_fields);

    diagnostics
  }
}