Skip to content

Commit

Permalink
Change format parameter in convertListOfSteps to namePrefix
Browse files Browse the repository at this point in the history
Signed-off-by: Tom George <tg82490@gmail.com>
  • Loading branch information
tomgeorge authored and tekton-robot committed Feb 4, 2020
1 parent 69c8876 commit f4e2e44
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/pod/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func convertScripts(shellImage string, steps []v1alpha1.Step, sidecars []v1alpha
//
// It iterates through the list of steps (or sidecars), generates the script file name and heredoc termination string,
// adds an entry to the init container args, sets up the step container to run the script, and sets the volume mounts.
func convertListOfSteps(steps []v1alpha1.Step, initContainer *corev1.Container, placeScripts *bool, format string) []corev1.Container {
func convertListOfSteps(steps []v1alpha1.Step, initContainer *corev1.Container, placeScripts *bool, namePrefix string) []corev1.Container {
containers := []corev1.Container{}
for i, s := range steps {
if s.Script == "" {
Expand All @@ -99,15 +99,15 @@ func convertListOfSteps(steps []v1alpha1.Step, initContainer *corev1.Container,

// Append to the place-scripts script to place the
// script file in a known location in the scripts volume.
tmpFile := filepath.Join(scriptsDir, names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-%d", format, i)))
tmpFile := filepath.Join(scriptsDir, names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-%d", namePrefix, i)))
// heredoc is the "here document" placeholder string
// used to cat script contents into the file. Typically
// this is the string "EOF" but if this value were
// "EOF" it would prevent users from including the
// string "EOF" in their own scripts. Instead we
// randomly generate a string to (hopefully) prevent
// collisions.
heredoc := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-heredoc-randomly-generated", format))
heredoc := names.SimpleNameGenerator.RestrictLengthWithRandomSuffix(fmt.Sprintf("%s-heredoc-randomly-generated", namePrefix))
initContainer.Args[1] += fmt.Sprintf(`tmpfile="%s"
touch ${tmpfile} && chmod +x ${tmpfile}
cat > ${tmpfile} << '%s'
Expand Down

0 comments on commit f4e2e44

Please sign in to comment.