Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tkn task start -f With Remote Files #583

Merged
merged 1 commit into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cmd/tkn_task_start.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/man/man1/tkn-task-start.1
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
10 changes: 5 additions & 5 deletions pkg/cmd/task/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ package task
import (
"errors"
"fmt"
"io/ioutil"
"strings"
"time"

Expand All @@ -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"
Expand Down Expand Up @@ -140,16 +140,16 @@ 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")

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
}
Expand Down Expand Up @@ -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
}
Expand Down