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.
33 lines
609 B
Go
33 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)
|
|
}
|