Skip to content

Commit

Permalink
update the entrypoint copy step to be more generic
Browse files Browse the repository at this point in the history
- based on the version of ko used, the binary could be in /ko-app or
in /ko-app/entrypoint
  • Loading branch information
nader-ziada committed Mar 4, 2019
1 parent e6274a8 commit 57cd24d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
9 changes: 5 additions & 4 deletions pkg/reconciler/v1alpha1/taskrun/entrypoint/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,11 @@ func AddToEntrypointCache(c *Cache, sha string, ep []string) {
func AddCopyStep(b *v1alpha1.BuildSpec) {

cp := corev1.Container{
Name: InitContainerName,
Image: *entrypointImage,
Command: []string{"/bin/cp"},
Args: []string{"/ko-app/entrypoint", BinaryLocation},
Name: InitContainerName,
Image: *entrypointImage,
Command: []string{"/bin/sh"},
// based on the ko version, the binary could be in one of two different locations
Args: []string{"-c", fmt.Sprintf("if [[ -d /ko-app ]]; then cp /ko-app/entrypoint %s; else cp /ko-app %s; fi;", BinaryLocation, BinaryLocation)},
VolumeMounts: []corev1.VolumeMount{toolsMount},
}
b.Steps = append([]corev1.Container{cp}, b.Steps...)
Expand Down
4 changes: 2 additions & 2 deletions pkg/reconciler/v1alpha1/taskrun/taskrun_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ var (
}

placeToolsInitContainer = tb.PodInitContainer("build-step-place-tools", "override-with-entrypoint:latest",
tb.Command("/bin/cp"),
tb.Args("/ko-app/entrypoint", entrypointLocation),
tb.Command("/bin/sh"),
tb.Args("-c", fmt.Sprintf("if [[ -d /ko-app ]]; then cp /ko-app/entrypoint %s; else cp /ko-app %s; fi;", entrypointLocation, entrypointLocation)),
tb.WorkingDir(workspaceDir),
tb.EnvVar("HOME", "/builder/home"),
tb.VolumeMount("tools", "/tools"),
Expand Down

0 comments on commit 57cd24d

Please sign in to comment.