package runbook

import "gopkg.in/yaml.v3"

type Spec struct {
	Version int    `yaml:"version"`
	Name    string `yaml:"name"`
	Steps   []Step `yaml:"steps"`
}

type Step struct {
	ID     string         `yaml:"id"`
	Action string         `yaml:"action"`
	OnFail string         `yaml:"on_fail"`
	With   map[string]any `yaml:"with"`
}

func Parse(data []byte) (*Spec, error) {
	var s Spec
	if err := yaml.Unmarshal(data, &s); err != nil {
		return nil, err
	}
	return &s, nil
}
