-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load builtin entrypoint while redirecting steps
Currently, any steps in a Pipeline that rely on the built in entrypoint of a container will not have the expected behaviour while running due to the entrypoint being overridden at runtime. This fixes #175. A major side effect of this work is that the override step will now possibly make HTTP calls every time a step is overridden. There is very rudimentary caching in place, however this could likely be improved if performance becomes an issue.
- Loading branch information
Tanner Bruce
committed
Oct 24, 2018
1 parent
a183a8a
commit bf8be01
Showing
5 changed files
with
111 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
pkg/reconciler/v1alpha1/taskrun/resources/entrypoint_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package resources_test | ||
|
||
import ( | ||
"github.com/knative/build-pipeline/pkg/reconciler/v1alpha1/taskrun/resources" | ||
"k8s.io/api/core/v1" | ||
"testing" | ||
) | ||
const ( | ||
kanikoImage = "gcr.io/kaniko-project/executor" | ||
knativeEntrypoint = "/tools/entrypoint" | ||
entrypointJSONConfigEnvVar = "ENTRYPOINT_OPTIONS" | ||
) | ||
|
||
func TestAddEntrypoint(t *testing.T) { | ||
inputs := []v1.Container{ | ||
{ | ||
Image: kanikoImage, | ||
}, | ||
{ | ||
Image: kanikoImage, | ||
Args: []string{"abcd"}, | ||
}, | ||
{ | ||
Image: kanikoImage, | ||
Command: []string{"abcd"}, | ||
Args: []string{"efgh"}, | ||
}, | ||
} | ||
// The first test case showcases the downloading of the entrypoint for the | ||
// image. the second test shows downloading the image as well as the args | ||
// being passed in. The third command shows a set Command overriding the | ||
// remote one. | ||
envVarStrings := []string{ | ||
`{"args":["/kaniko/executor"],"process_log":"/tools/process-log.txt","marker_file":"/tools/marker-file.txt"}`, | ||
`{"args":["/kaniko/executor","abcd"],"process_log":"/tools/process-log.txt","marker_file":"/tools/marker-file.txt"}`, | ||
`{"args":["abcd","efgh"],"process_log":"/tools/process-log.txt","marker_file":"/tools/marker-file.txt"}`, | ||
|
||
} | ||
err := resources.AddEntrypoint(inputs) | ||
if err != nil { | ||
t.Errorf("failed to get resources: %v", err) | ||
} | ||
for i, input := range inputs { | ||
if len(input.Command) == 0 || input.Command[0] != knativeEntrypoint { | ||
t.Errorf("command incorrectly set: %q", input.Command) | ||
} | ||
if len(input.Args) > 0 { | ||
t.Errorf("containers should have no args") | ||
} | ||
if len(input.Env) == 0 { | ||
t.Error("there should be atleast one envvar") | ||
} | ||
for _, e := range input.Env { | ||
if e.Name == entrypointJSONConfigEnvVar && e.Value != envVarStrings[i] { | ||
t.Errorf("envvar \n%s\n does not match \n%s", e.Value, envVarStrings[i]) | ||
} | ||
} | ||
found := false | ||
for _, vm := range input.VolumeMounts { | ||
if vm.Name == resources.MountName { | ||
found = true | ||
break | ||
} | ||
} | ||
if !found { | ||
t.Error("could not find tools volume mount") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters