From f2a4bb8fbcb764dfd420c7a6b2b385df001d6c1d Mon Sep 17 00:00:00 2001 From: Dan Lorenc Date: Mon, 5 Aug 2019 09:15:09 -0500 Subject: [PATCH] Automatically create named directories for each output resource in a TaskRun. TaskRuns are expected to place files related to an Output in a directory named for each Output. Right now, we expect Task authors to create this directory before placing files there. This is onerous and error-prone, so we should automatically create them. There are a few approaches to doing this: - a mkdir init container - a volume - a mkdir pod container I chose to use the final one, a mkdir pod container for consistency with Input resources. This is prepended to the Task steps. --- examples/pipelineruns/output-pipelinerun.yaml | 6 + pkg/apis/pipeline/v1alpha1/artifact_pvc.go | 2 +- .../taskrun/resources/output_resource.go | 4 + .../taskrun/resources/output_resource_test.go | 341 +++++++++++------- .../v1alpha1/taskrun/taskrun_test.go | 53 ++- 5 files changed, 269 insertions(+), 137 deletions(-) diff --git a/examples/pipelineruns/output-pipelinerun.yaml b/examples/pipelineruns/output-pipelinerun.yaml index a608db598b2..202ee72bef3 100644 --- a/examples/pipelineruns/output-pipelinerun.yaml +++ b/examples/pipelineruns/output-pipelinerun.yaml @@ -25,6 +25,8 @@ spec: resources: - name: workspace type: git + - name: shouldexist + type: git steps: - name: read-docs-old image: ubuntu @@ -34,6 +36,10 @@ spec: image: ubuntu command: ['bash'] args: ['-c', 'echo some stuff > /workspace/damnworkspace/stuff'] + - name: check-output-exists + image: ubuntu + command: ['bash'] + args: ['-c', "stat /workspace/output/shouldexist && touch /workspace/output/shouldexist/foo"] --- # Reads a file from a predefined path in the workspace git PipelineResource apiVersion: tekton.dev/v1alpha1 diff --git a/pkg/apis/pipeline/v1alpha1/artifact_pvc.go b/pkg/apis/pipeline/v1alpha1/artifact_pvc.go index 37d3f878fc7..8ebc1fff09e 100644 --- a/pkg/apis/pipeline/v1alpha1/artifact_pvc.go +++ b/pkg/apis/pipeline/v1alpha1/artifact_pvc.go @@ -90,7 +90,7 @@ func GetPvcMount(name string) corev1.VolumeMount { // CreateDirContainer returns a container step to create a dir func CreateDirContainer(name, destinationPath string) corev1.Container { return corev1.Container{ - Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("create-dir-%s", name)), + Name: names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("create-dir-%s", strings.ToLower(name))), Image: *BashNoopImage, Command: []string{"/ko-app/bash"}, Args: []string{"-args", strings.Join([]string{"mkdir", "-p", destinationPath}, " ")}, diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource.go b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource.go index 44467a70ccb..fbdf8d05577 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource.go @@ -129,6 +129,10 @@ func AddOutputResources( resourceVolumes = append(resourceVolumes, as.GetSecretsVolumes()...) } + // Add containers to mkdir each output directory. This should run before the build steps themselves. + mkdirStep := []corev1.Container{v1alpha1.CreateDirContainer(boundResource.Name, sourcePath)} + taskSpec.Steps = append(mkdirStep, taskSpec.Steps...) + taskSpec.Steps = append(taskSpec.Steps, resourceContainers...) taskSpec.Volumes = append(taskSpec.Volumes, resourceVolumes...) diff --git a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go index 455aea8c92a..4a78af49e9a 100644 --- a/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/resources/output_resource_test.go @@ -158,25 +158,31 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "source-mkdir-source-git-9l9zj", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "mkdir -p pipeline-task-name"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: "pipelinerun-pvc", - MountPath: "/pvc", - }}, - }, { - Name: "source-copy-source-git-mz4c7", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "cp -r /workspace/source-workspace/. pipeline-task-name"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: "pipelinerun-pvc", - MountPath: "/pvc", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mssqb", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/source-workspace"}, + }, { + Name: "source-mkdir-source-git-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p pipeline-task-name"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "pipelinerun-pvc", + MountPath: "/pvc", + }}, + }, { + Name: "source-copy-source-git-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "cp -r /workspace/source-workspace/. pipeline-task-name"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "pipelinerun-pvc", + MountPath: "/pvc", + }}, }}, - }}, }, { name: "git resource in output only", desc: "git resource declared as output with pipelinerun owner reference", @@ -215,25 +221,32 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "source-mkdir-source-git-9l9zj", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "mkdir -p pipeline-task-name"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: "pipelinerun-pvc", - MountPath: "/pvc", - }}, - }, { - Name: "source-copy-source-git-mz4c7", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "cp -r /workspace/output/source-workspace/. pipeline-task-name"}, - VolumeMounts: []corev1.VolumeMount{{ - Name: "pipelinerun-pvc", - MountPath: "/pvc", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mssqb", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + { + Name: "source-mkdir-source-git-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p pipeline-task-name"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "pipelinerun-pvc", + MountPath: "/pvc", + }}, + }, { + Name: "source-copy-source-git-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "cp -r /workspace/output/source-workspace/. pipeline-task-name"}, + VolumeMounts: []corev1.VolumeMount{{ + Name: "pipelinerun-pvc", + MountPath: "/pvc", + }}, }}, - }}, }, { name: "image resource in output with pipelinerun with owner", desc: "image resource declared as output with pipelinerun owner reference should not generate any steps", @@ -272,7 +285,14 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: nil, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + }, wantVolumes: nil, }, { name: "git resource in output", @@ -307,6 +327,14 @@ func TestValidOutputResources(t *testing.T) { }, }, }, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + }, }, { name: "storage resource as both input and output", desc: "storage resource defined in both input and output with parents pipelinerun reference", @@ -360,31 +388,38 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "upload-source-gcs-9l9zj", - Image: "override-with-gsutil-image:latest", - VolumeMounts: []corev1.VolumeMount{{ - Name: "volume-source-gcs-sname", - MountPath: "/var/secret/sname", - }}, - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "rsync -d -r /workspace/faraway-disk gs://some-bucket"}, - Env: []corev1.EnvVar{{ - Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-78c5n", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/faraway-disk"}, + }, + { + Name: "upload-source-gcs-9l9zj", + Image: "override-with-gsutil-image:latest", + VolumeMounts: []corev1.VolumeMount{{ + Name: "volume-source-gcs-sname", + MountPath: "/var/secret/sname", + }}, + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "rsync -d -r /workspace/faraway-disk gs://some-bucket"}, + Env: []corev1.EnvVar{{ + Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + }}, + }, { + Name: "source-mkdir-source-gcs-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p pipeline-task-path"}, + VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-parent-pvc", MountPath: "/pvc"}}, + }, { + Name: "source-copy-source-gcs-mssqb", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "cp -r /workspace/faraway-disk/. pipeline-task-path"}, + VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-parent-pvc", MountPath: "/pvc"}}, }}, - }, { - Name: "source-mkdir-source-gcs-mz4c7", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "mkdir -p pipeline-task-path"}, - VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-parent-pvc", MountPath: "/pvc"}}, - }, { - Name: "source-copy-source-gcs-mssqb", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "cp -r /workspace/faraway-disk/. pipeline-task-path"}, - VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-parent-pvc", MountPath: "/pvc"}}, - }}, wantVolumes: []corev1.Volume{{ Name: "volume-source-gcs-sname", VolumeSource: corev1.VolumeSource{ @@ -429,30 +464,37 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "upload-source-gcs-9l9zj", - Image: "override-with-gsutil-image:latest", - VolumeMounts: []corev1.VolumeMount{{ - Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", - }}, - Env: []corev1.EnvVar{{ - Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-78c5n", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + { + Name: "upload-source-gcs-9l9zj", + Image: "override-with-gsutil-image:latest", + VolumeMounts: []corev1.VolumeMount{{ + Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", + }}, + Env: []corev1.EnvVar{{ + Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + }}, + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, + }, { + Name: "source-mkdir-source-gcs-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p pipeline-task-path"}, + VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-pvc", MountPath: "/pvc"}}, + }, { + Name: "source-copy-source-gcs-mssqb", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "cp -r /workspace/output/source-workspace/. pipeline-task-path"}, + VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-pvc", MountPath: "/pvc"}}, }}, - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, - }, { - Name: "source-mkdir-source-gcs-mz4c7", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "mkdir -p pipeline-task-path"}, - VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-pvc", MountPath: "/pvc"}}, - }, { - Name: "source-copy-source-gcs-mssqb", - Image: "override-with-bash-noop:latest", - Command: []string{"/ko-app/bash"}, - Args: []string{"-args", "cp -r /workspace/output/source-workspace/. pipeline-task-path"}, - VolumeMounts: []corev1.VolumeMount{{Name: "pipelinerun-pvc", MountPath: "/pvc"}}, - }}, wantVolumes: []corev1.Volume{{ Name: "volume-source-gcs-sname", VolumeSource: corev1.VolumeSource{ @@ -493,18 +535,25 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "upload-source-gcs-9l9zj", - Image: "override-with-gsutil-image:latest", - VolumeMounts: []corev1.VolumeMount{{ - Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", - }}, - Env: []corev1.EnvVar{{ - Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + { + Name: "upload-source-gcs-9l9zj", + Image: "override-with-gsutil-image:latest", + VolumeMounts: []corev1.VolumeMount{{ + Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", + }}, + Env: []corev1.EnvVar{{ + Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + }}, + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, }}, - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, - }}, wantVolumes: []corev1.Volume{{ Name: "volume-source-gcs-sname", VolumeSource: corev1.VolumeSource{ @@ -544,18 +593,25 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "upload-source-gcs-9l9zj", - Image: "override-with-gsutil-image:latest", - VolumeMounts: []corev1.VolumeMount{{ - Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", - }}, - Env: []corev1.EnvVar{{ - Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + { + Name: "upload-source-gcs-9l9zj", + Image: "override-with-gsutil-image:latest", + VolumeMounts: []corev1.VolumeMount{{ + Name: "volume-source-gcs-sname", MountPath: "/var/secret/sname", + }}, + Env: []corev1.EnvVar{{ + Name: "GOOGLE_APPLICATION_CREDENTIALS", Value: "/var/secret/sname/key.json", + }}, + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, }}, - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "rsync -d -r /workspace/output/source-workspace gs://some-bucket"}, - }}, wantVolumes: []corev1.Volume{{ Name: "volume-source-gcs-sname", VolumeSource: corev1.VolumeSource{ @@ -599,7 +655,14 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: nil, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + }, }, { name: "Resource with TargetPath as output", desc: "Resource with TargetPath defined only in output", @@ -638,7 +701,14 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: nil, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace"}, + }, + }, }, { desc: "image output resource with no steps", taskRun: &v1alpha1.TaskRun{ @@ -671,7 +741,14 @@ func TestValidOutputResources(t *testing.T) { }, }, }, - wantSteps: nil, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + }, }} { t.Run(c.name, func(t *testing.T) { names.TestingSeed() @@ -767,12 +844,19 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "artifact-copy-to-source-git-9l9zj", - Image: "override-with-gsutil-image:latest", - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "cp -P -r /workspace/source-workspace gs://fake-bucket/pipeline-task-name"}, - }}, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/source-workspace"}, + }, + { + Name: "artifact-copy-to-source-git-9l9zj", + Image: "override-with-gsutil-image:latest", + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "cp -P -r /workspace/source-workspace gs://fake-bucket/pipeline-task-name"}, + }}, }, { name: "git resource in output only with bucket storage", desc: "git resource declared as output with pipelinerun owner reference", @@ -811,12 +895,19 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, - wantSteps: []corev1.Container{{ - Name: "artifact-copy-to-source-git-9l9zj", - Image: "override-with-gsutil-image:latest", - Command: []string{"/ko-app/gsutil"}, - Args: []string{"-args", "cp -P -r /workspace/output/source-workspace gs://fake-bucket/pipeline-task-name"}, - }}, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-mz4c7", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + { + Name: "artifact-copy-to-source-git-9l9zj", + Image: "override-with-gsutil-image:latest", + Command: []string{"/ko-app/gsutil"}, + Args: []string{"-args", "cp -P -r /workspace/output/source-workspace gs://fake-bucket/pipeline-task-name"}, + }}, }, { name: "git resource in output", desc: "git resource declared in output without pipelinerun owner reference", @@ -850,6 +941,14 @@ func TestValidOutputResourcesWithBucketStorage(t *testing.T) { }, }, }, + wantSteps: []corev1.Container{ + { + Name: "create-dir-source-workspace-9l9zj", + Image: "override-with-bash-noop:latest", + Command: []string{"/ko-app/bash"}, + Args: []string{"-args", "mkdir -p /workspace/output/source-workspace"}, + }, + }, }} { t.Run(c.name, func(t *testing.T) { outputResourceSetup(t) diff --git a/pkg/reconciler/v1alpha1/taskrun/taskrun_test.go b/pkg/reconciler/v1alpha1/taskrun/taskrun_test.go index 68b22341d61..313169d7355 100644 --- a/pkg/reconciler/v1alpha1/taskrun/taskrun_test.go +++ b/pkg/reconciler/v1alpha1/taskrun/taskrun_test.go @@ -196,6 +196,29 @@ var ( return tb.PodInitContainer("step-credential-initializer-"+suffix, "override-with-creds:latest", actualOps...) } + getMkdirResourceContainer = func(name, dir, suffix string, ops ...tb.ContainerOp) tb.PodSpecOp { + actualOps := []tb.ContainerOp{ + tb.Command("/builder/tools/entrypoint"), + tb.Args("-wait_file", "/builder/downward/ready", "-post_file", "/builder/tools/0", "-wait_file_content", "-entrypoint", "/ko-app/bash", "--", + "-args", "mkdir -p "+dir), + tb.WorkingDir(workspaceDir), + tb.EnvVar("HOME", "/builder/home"), + tb.VolumeMount("tools", "/builder/tools"), + tb.VolumeMount("downward", "/builder/downward"), + tb.VolumeMount("workspace", workspaceDir), + tb.VolumeMount("home", "/builder/home"), + tb.Resources(tb.Requests( + tb.CPU("0"), + tb.Memory("0"), + tb.EphemeralStorage("0"), + )), + } + + actualOps = append(actualOps, ops...) + + return tb.PodContainer(fmt.Sprintf("step-create-dir-%s-%s", name, suffix), "override-with-bash-noop:latest", actualOps...) + } + getPlaceToolsInitContainer = func(ops ...tb.ContainerOp) tb.PodSpecOp { actualOps := []tb.ContainerOp{ tb.Command("/bin/sh"), @@ -470,16 +493,16 @@ func TestReconcile(t *testing.T) { }, }, toolsVolume, downward, workspaceVolume, homeVolume), tb.PodRestartPolicy(corev1.RestartPolicyNever), - getCredentialsInitContainer("mssqb"), + getCredentialsInitContainer("78c5n"), getPlaceToolsInitContainer(), + getMkdirResourceContainer("myimage", "/workspace/output/myimage", "mssqb"), tb.PodContainer("step-git-source-git-resource-mz4c7", "override-with-git:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/downward/ready", "-post_file", "/builder/tools/0", "-wait_file_content", "-entrypoint", "/ko-app/git-init", "--", + tb.Args("-wait_file", "/builder/tools/0", "-post_file", "/builder/tools/1", "-entrypoint", "/ko-app/git-init", "--", "-url", "https://foo.git", "-revision", "master", "-path", "/workspace/workspace"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), tb.VolumeMount("tools", "/builder/tools"), - tb.VolumeMount("downward", "/builder/downward"), tb.VolumeMount("workspace", workspaceDir), tb.VolumeMount("home", "/builder/home"), tb.Resources(tb.Requests( @@ -490,7 +513,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-mycontainer", "myimage", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/0", "-post_file", "/builder/tools/1", "-entrypoint", "/mycmd", "--", + tb.Args("-wait_file", "/builder/tools/1", "-post_file", "/builder/tools/2", "-entrypoint", "/mycmd", "--", "--my-arg=foo", "--my-arg-with-default=bar", "--my-arg-with-default2=thedefault", "--my-additional-arg=gcr.io/kristoff/sven"), tb.WorkingDir(workspaceDir), @@ -506,7 +529,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-myothercontainer", "myotherimage", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/1", "-post_file", "/builder/tools/2", "-entrypoint", "/mycmd", "--", + tb.Args("-wait_file", "/builder/tools/2", "-post_file", "/builder/tools/3", "-entrypoint", "/mycmd", "--", "--my-other-arg=https://foo.git"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), @@ -521,7 +544,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-image-digest-exporter-9l9zj", "override-with-imagedigest-exporter-image:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/2", "-post_file", "/builder/tools/3", "-entrypoint", "/ko-app/imagedigestexporter", "--", + tb.Args("-wait_file", "/builder/tools/3", "-post_file", "/builder/tools/4", "-entrypoint", "/ko-app/imagedigestexporter", "--", "-images", "[{\"name\":\"image-resource\",\"type\":\"image\",\"url\":\"gcr.io/kristoff/sven\",\"digest\":\"\",\"OutputImageDir\":\"\"}]", "-terminationMessagePath", "/builder/home/image-outputs/termination-log"), tb.WorkingDir(workspaceDir), @@ -559,16 +582,16 @@ func TestReconcile(t *testing.T) { }, }, toolsVolume, downward, workspaceVolume, homeVolume), tb.PodRestartPolicy(corev1.RestartPolicyNever), - getCredentialsInitContainer("vr6ds"), + getCredentialsInitContainer("l22wn"), getPlaceToolsInitContainer(), + getMkdirResourceContainer("git-resource", "/workspace/git-resource", "vr6ds"), tb.PodContainer("step-create-dir-another-git-resource-78c5n", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/downward/ready", "-post_file", "/builder/tools/0", "-wait_file_content", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/0", "-post_file", "/builder/tools/1", "-entrypoint", "/ko-app/bash", "--", "-args", "mkdir -p /workspace/another-git-resource"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), tb.VolumeMount("tools", "/builder/tools"), - tb.VolumeMount("downward", "/builder/downward"), tb.VolumeMount("workspace", workspaceDir), tb.VolumeMount("home", "/builder/home"), tb.Resources(tb.Requests( @@ -579,7 +602,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-source-copy-another-git-resource-mssqb", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/0", "-post_file", "/builder/tools/1", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/1", "-post_file", "/builder/tools/2", "-entrypoint", "/ko-app/bash", "--", "-args", "cp -r source-folder/. /workspace/another-git-resource"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), @@ -595,7 +618,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-create-dir-git-resource-mz4c7", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/1", "-post_file", "/builder/tools/2", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/2", "-post_file", "/builder/tools/3", "-entrypoint", "/ko-app/bash", "--", "-args", "mkdir -p /workspace/git-resource"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), @@ -610,7 +633,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-source-copy-git-resource-9l9zj", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/2", "-post_file", "/builder/tools/3", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/3", "-post_file", "/builder/tools/4", "-entrypoint", "/ko-app/bash", "--", "-args", "cp -r source-folder/. /workspace/git-resource"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), @@ -626,7 +649,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-simple-step", "foo", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/3", "-post_file", "/builder/tools/4", "-entrypoint", "/mycmd", "--"), + tb.Args("-wait_file", "/builder/tools/4", "-post_file", "/builder/tools/5", "-entrypoint", "/mycmd", "--"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), tb.VolumeMount("tools", "/builder/tools"), @@ -640,7 +663,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-source-mkdir-git-resource-6nl7g", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/4", "-post_file", "/builder/tools/5", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/5", "-post_file", "/builder/tools/6", "-entrypoint", "/ko-app/bash", "--", "-args", "mkdir -p output-folder"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"), @@ -656,7 +679,7 @@ func TestReconcile(t *testing.T) { ), tb.PodContainer("step-source-copy-git-resource-j2tds", "override-with-bash-noop:latest", tb.Command(entrypointLocation), - tb.Args("-wait_file", "/builder/tools/5", "-post_file", "/builder/tools/6", "-entrypoint", "/ko-app/bash", "--", + tb.Args("-wait_file", "/builder/tools/6", "-post_file", "/builder/tools/7", "-entrypoint", "/ko-app/bash", "--", "-args", "cp -r /workspace/git-resource/. output-folder"), tb.WorkingDir(workspaceDir), tb.EnvVar("HOME", "/builder/home"),