servitor/cmd/lint.go
2019-10-03 23:41:01 +02:00

32 lines
609 B
Go

package cmd
import (
"git.cijber.net/x/servitor/workflow"
"github.com/spf13/cobra"
"gopkg.in/yaml.v2"
"io/ioutil"
)
func init() {
var cmdLint = &cobra.Command{
Use: "lint [workflow file]",
Short: "Lint workflow file",
Long: `Lint and validate a workflow file
exits with exit code 1 on error`,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
buff, err := ioutil.ReadFile(args[0])
if err != nil {
panic(err)
}
wf := workflow.Document{}
err = yaml.Unmarshal(buff, &wf)
if err != nil {
panic(err)
}
},
}
rootCmd.AddCommand(cmdLint)
}