Skip to content

Instantly share code, notes, and snippets.

@ImJasonH ImJasonH/main.go
Created Dec 17, 2019

Embed
What would you like to do?
Example of parsing a YAML file into a Tekton Task
import (
"flag"
"io/ioutil"
"log"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1alpha1"
"github.com/tektoncd/pipeline/pkg/client/clientset/versioned/scheme"
)
var (
filename = flag.String("f", "", "Name of file to parse")
)
func main() {
flag.Parse()
b, err := ioutil.ReadFile(*filename)
if err != nil {
log.Fatal(err)
}
var task v1alpha1.Task
scheme.Codecs.UniversalDeserializer().Decode(b, nil, &task); err != nil {
log.Fatal(err)
}
log.Printf("Task: %+v", task)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.