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

fix task start with file #964

Merged
merged 1 commit into from
May 6, 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
6 changes: 6 additions & 0 deletions pkg/cmd/task/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,13 @@ func startTask(opt startOptions, args []string) error {
if err != nil {
return err
}

tname = task.ObjectMeta.Name

if task.Spec.Params != nil {
params.FilterParamsByType(task.Spec.Params)
}

tr.Spec = v1beta1.TaskRunSpec{
TaskSpec: &task.Spec,
}
Expand Down
34 changes: 34 additions & 0 deletions pkg/cmd/task/start_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3862,6 +3862,23 @@ func TestTaskStart_ExecuteCommand(t *testing.T) {
wantError: false,
goldenFile: true,
},
{
name: "Dry Run with --param -f v1alpha1",
command: []string{"start",
"-f", "./testdata/task-v1alpha1.yaml",
"-n", "ns",
"-s=svc1",
"-i=docker-source=git",
"-o=builtImage=image",
"--dry-run",
"--param=myarg=BomBom",
},
namespace: "",
dynamic: dc1,
input: cs,
wantError: false,
goldenFile: true,
},
}

for _, tp := range testParams {
Expand Down Expand Up @@ -4062,6 +4079,23 @@ func TestTaskStart_ExecuteCommand_v1beta1(t *testing.T) {
wantError: false,
goldenFile: true,
},
{
name: "Dry Run with --param -f v1beta1",
command: []string{"start",
"-f", "./testdata/task-v1beta1.yaml",
"-n", "ns",
"-s=svc1",
"-i=docker-source=git",
"-o=builtImage=image",
"--dry-run",
"--param=myarg=BomBom",
},
namespace: "",
dynamic: dc,
input: cs,
wantError: false,
goldenFile: true,
},
}

for _, tp := range testParams {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
creationTimestamp: null
generateName: test-task-run-
namespace: ns
spec:
inputs:
params:
- name: myarg
value: BomBom
resources:
- name: docker-source
resourceRef:
name: git
outputs:
resources:
- name: builtImage
resourceRef:
name: image
serviceAccountName: svc1
taskSpec:
inputs:
params:
- default: /workspace/docker-source/Dockerfile
description: The path to the dockerfile to build
name: pathToDockerFile
type: string
- default: /workspace/docker-source
description: The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
name: pathToContext
type: string
resources:
- name: docker-source
type: git
outputs:
resources:
- name: builtImage
type: image
steps:
- args:
- --dockerfile=$(inputs.params.pathToDockerFile)
- --destination=$(outputs.resources.builtImage.url)
- --context=$(inputs.params.pathToContext)
command:
- /kaniko/executor
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker/
image: gcr.io/kaniko-project/executor:v0.14.0
name: build-and-push
resources: {}
status:
podName: ""
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ spec:
resources:
- name: builtImage
type: image
params:
- default: /workspace/docker-source/Dockerfile
description: The path to the dockerfile to build
name: pathToDockerFile
type: string
- default: /workspace/docker-source
description: The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
name: pathToContext
type: string
resources:
inputs:
- name: docker-source
type: git
outputs:
- name: builtImage
type: image
steps:
- args:
- --dockerfile=$(inputs.params.pathToDockerFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,6 @@
"spec": {
"serviceAccountName": "svc1",
"taskSpec": {
"resources": {
"inputs": [
{
"name": "docker-source",
"type": "git"
}
],
"outputs": [
{
"name": "builtImage",
"type": "image"
}
]
},
"params": [
{
"name": "pathToDockerFile",
"type": "string",
"description": "The path to the dockerfile to build",
"default": "/workspace/docker-source/Dockerfile"
},
{
"name": "pathToContext",
"type": "string",
"description": "The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)",
"default": "/workspace/docker-source"
}
],
"steps": [
{
"name": "build-and-push",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
creationTimestamp: null
generateName: test-task-run-
namespace: ns
spec:
params:
- name: myarg
value: BomBom
resources:
inputs:
- name: docker-source
resourceRef:
name: git
outputs:
- name: builtImage
resourceRef:
name: image
serviceAccountName: svc1
taskSpec:
params:
- default: /workspace/docker-source/Dockerfile
description: The path to the dockerfile to build
name: pathToDockerFile
type: string
- default: /workspace/docker-source
description: The build context used by Kaniko (https://github.com/GoogleContainerTools/kaniko#kaniko-build-contexts)
name: pathToContext
type: string
resources:
inputs:
- name: docker-source
type: git
outputs:
- name: builtImage
type: image
steps:
- args:
- --dockerfile=$(inputs.params.pathToDockerFile)
- --destination=$(outputs.resources.builtImage.url)
- --context=$(inputs.params.pathToContext)
command:
- /kaniko/executor
env:
- name: DOCKER_CONFIG
value: /tekton/home/.docker/
image: gcr.io/kaniko-project/executor:v0.14.0
name: build-and-push
resources: {}
status:
podName: ""
2 changes: 0 additions & 2 deletions pkg/task/task.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ func SpecConvertDown(spec *v1beta1.TaskSpec) *v1alpha1.TaskSpec {
downTaskSpec.Sidecars = spec.Sidecars
downTaskSpec.Workspaces = spec.Workspaces
downTaskSpec.Results = spec.Results
downTaskSpec.Resources = spec.Resources
downTaskSpec.Params = spec.Params
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v1alpha1 taskspec will have params in Sepc.Inputs.Params

downTaskSpec.Description = spec.Description
if spec.Resources != nil {
if len(spec.Resources.Inputs) > 0 {
Expand Down
2 changes: 0 additions & 2 deletions pkg/taskrun/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ func Create(c *cli.Clients, tr *v1beta1.TaskRun, opts metav1.CreateOptions, ns s
if err != nil {
return nil, err
}
v1alpha1TaskRun.Kind = "TaskRun"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind and APIVersion is already added in the ConvertDown func.

v1alpha1TaskRun.APIVersion = "tekton.dev/v1alpha1"
return createUnstructured(v1alpha1TaskRun, c, opts, ns)
}

Expand Down