You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
942 B
Go

2 years ago
package config
import (
"os"
"gopkg.in/yaml.v3"
)
// Operation is an enum of various operations
type Operation struct {
Layout string `yaml:",omitempty"`
Target string `yaml:",omitempty"`
Plugin string `yaml:",omitempty"`
Options map[string]any `yaml:",omitempty"`
2 years ago
}
type EntryPoint struct {
Source string `yaml:",omitempty"`
Pipeline []Operation `yaml:",omitempty"`
2 years ago
}
type Options struct {
Excludes []string `yaml:",omitempty"`
// Include []string `yaml:",omitempty"`
Output string `yaml:",omitempty"`
2 years ago
}
// Cabretfile has some configuration for the
type Cabretfile struct {
Options Options `yaml:",omitempty"`
EntryPoints []*EntryPoint `yaml:"entryPoints"`
2 years ago
}
func ReadCabretfile(file string) (*Cabretfile, error) {
2 years ago
f, err := os.Open(file)
if err != nil {
return nil, err
}
site := new(Cabretfile)
if err := yaml.NewDecoder(f).Decode(site); err != nil {
2 years ago
return nil, err
}
return site, nil
}