44 lines
864 B
Go
44 lines
864 B
Go
// Copyright 2022 Lauris BH. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package transform
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/goccy/go-yaml"
|
|
)
|
|
|
|
var UnsupportedError = errors.New("unsupported pipeline")
|
|
|
|
type Step struct {
|
|
Name string `yaml:"-"`
|
|
Image string `yaml:"image"`
|
|
Commands []string `yaml:"commands,omitempty"`
|
|
}
|
|
|
|
type Steps []*Step
|
|
|
|
func (s Steps) MarshalYAML() (interface{}, error) {
|
|
v := make(yaml.MapSlice, len(s))
|
|
for i, step := range s {
|
|
v[i] = yaml.MapItem{
|
|
Key: step.Name,
|
|
Value: step,
|
|
}
|
|
}
|
|
return v, nil
|
|
}
|
|
|
|
type Workspace struct {
|
|
Base string `yaml:"base"`
|
|
Path string `yaml:"path"`
|
|
}
|
|
|
|
type Pipeline struct {
|
|
Name string `yaml:"-"`
|
|
Workspace *Workspace `yaml:"workspace,omitempty"`
|
|
Steps Steps `yaml:"pipeline"`
|
|
}
|