diff --git a/docs/cmd/tkn_task_start.md b/docs/cmd/tkn_task_start.md index 15a1cf62f..835744c80 100644 --- a/docs/cmd/tkn_task_start.md +++ b/docs/cmd/tkn_task_start.md @@ -30,7 +30,7 @@ like cat,foo,bar ### Options ``` - -f, --filename string filename containing a task definition + -f, --filename string local or remote file name containing a task definition -h, --help help for start -i, --inputresource strings pass the input resource name and ref as name=ref -l, --labels strings pass labels as label=value. diff --git a/docs/man/man1/tkn-task-start.1 b/docs/man/man1/tkn-task-start.1 index 5eb2bafa9..6db5456a1 100644 --- a/docs/man/man1/tkn-task-start.1 +++ b/docs/man/man1/tkn-task-start.1 @@ -21,7 +21,7 @@ Start tasks .SH OPTIONS .PP \fB\-f\fP, \fB\-\-filename\fP="" - filename containing a task definition + local or remote file name containing a task definition .PP \fB\-h\fP, \fB\-\-help\fP[=false] diff --git a/go.sum b/go.sum index 0c070fec7..3f564aba7 100644 --- a/go.sum +++ b/go.sum @@ -412,6 +412,7 @@ k8s.io/api v0.0.0-20191004102255-dacd7df5a50b h1:38Nx0U83WjBqn1hUWxlgKc7mvH7WhyH k8s.io/api v0.0.0-20191004102255-dacd7df5a50b/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/apimachinery v0.0.0-20191004074956-01f8b7d1121a h1:lDydUqHrbL/1l5ZQrqD1RIlabhmX8aiZEtxVUb+30iU= k8s.io/apimachinery v0.0.0-20191004074956-01f8b7d1121a/go.mod h1:ccL7Eh7zubPUSh9A3USN90/OzHNSVN6zxzde07TDCL0= +k8s.io/apimachinery v0.17.0 h1:xRBnuie9rXcPxUkDizUsGvPf1cnlZCFu210op7J7LJo= k8s.io/cli-runtime v0.0.0-20191004110054-fe9b9282443f h1:vJOrMsZe+RD884n+WQ5So2oOp7SajI0Op3oOBg64ZsY= k8s.io/cli-runtime v0.0.0-20191004110054-fe9b9282443f/go.mod h1:qWnH3/b8sp/l7EvlDh7ulDU3UWA4P4N1NFbEEP791tM= k8s.io/client-go v0.0.0-20191004102537-eb5b9a8cfde7 h1:WyPHgjjXvF4zVVwKGZKKiJGBUW45AuN44uSOuH8euuE= diff --git a/pkg/cmd/task/start.go b/pkg/cmd/task/start.go index 6587ffcd3..781c02d22 100644 --- a/pkg/cmd/task/start.go +++ b/pkg/cmd/task/start.go @@ -17,7 +17,6 @@ package task import ( "errors" "fmt" - "io/ioutil" "strings" "time" @@ -26,6 +25,7 @@ import ( "github.com/tektoncd/cli/pkg/cli" "github.com/tektoncd/cli/pkg/cmd/taskrun" "github.com/tektoncd/cli/pkg/flags" + "github.com/tektoncd/cli/pkg/helper/file" "github.com/tektoncd/cli/pkg/helper/labels" "github.com/tektoncd/cli/pkg/helper/options" "github.com/tektoncd/cli/pkg/helper/params" @@ -140,7 +140,7 @@ like cat,foo,bar c.Flags().BoolVarP(&opt.Last, "last", "L", false, "re-run the task using last taskrun values") c.Flags().StringSliceVarP(&opt.Labels, "labels", "l", []string{}, "pass labels as label=value.") c.Flags().BoolVarP(&opt.ShowLog, "showlog", "", false, "show logs right after starting the task") - c.Flags().StringVarP(&opt.Filename, "filename", "f", "", "filename containing a task definition") + c.Flags().StringVarP(&opt.Filename, "filename", "f", "", "local or remote file name containing a task definition") c.Flags().Int64VarP(&opt.TimeOut, "timeout", "t", 3600, "timeout for taskrun in seconds") _ = c.MarkZshCompPositionalArgumentCustom(1, "__tkn_get_task") @@ -148,8 +148,8 @@ like cat,foo,bar return c } -func parseTask(p string) (*v1alpha1.Task, error) { - b, err := ioutil.ReadFile(p) +func parseTask(taskLocation string, p cli.Params) (*v1alpha1.Task, error) { + b, err := file.LoadFileContent(p, taskLocation, file.IsYamlFile(), fmt.Errorf("inavlid file format for %s: .yaml or .yml file extension and format required", taskLocation)) if err != nil { return nil, err } @@ -177,7 +177,7 @@ func startTask(opt startOptions, args []string) error { Timeout: &metav1.Duration{Duration: timeoutSeconds}, } } else { - task, err := parseTask(opt.Filename) + task, err := parseTask(opt.Filename, opt.cliparams) if err != nil { return err }