mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-26 18:30:30 +00:00
25 lines
538 B
Go
25 lines
538 B
Go
|
package runner
|
||
|
|
||
|
import (
|
||
|
"encoding/json"
|
||
|
"io/ioutil"
|
||
|
)
|
||
|
|
||
|
// Parse parses a raw file containing a JSON encoded format of an intermediate
|
||
|
// representation of the pipeline.
|
||
|
func Parse(data []byte) (*Spec, error) {
|
||
|
v := &Spec{}
|
||
|
err := json.Unmarshal(data, v)
|
||
|
return v, err
|
||
|
}
|
||
|
|
||
|
// ParseFile parses a file containing a JSON encoded format of an intermediate
|
||
|
// representation of the pipeline.
|
||
|
func ParseFile(filename string) (*Spec, error) {
|
||
|
out, err := ioutil.ReadFile(filename)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return Parse(out)
|
||
|
}
|