forked from openshift/geard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplates.go
32 lines (28 loc) · 1.16 KB
/
templates.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package sti
import "text/template"
// Script used to initialize permissions on bind-mounts when a non-root user is specified by an image
var saveArtifactsInitTemplate = template.Must(template.New("sa-init.sh").Parse(`#!/bin/sh
chown -R {{.User}} /tmp/artifacts && chmod -R 775 /tmp/artifacts
chmod -R 755 /tmp/scripts
chmod -R 755 /tmp/defaultScripts
chmod -R 755 /tmp/src
exec su {{.User}} - -s /bin/sh -c {{.SaveArtifactsPath}}
`))
// Script used to initialize permissions on bind-mounts for a docker-run build (prepare call)
var buildTemplate = template.Must(template.New("build-init.sh").Parse(`#!/bin/sh
{{if eq .Usage false }}chown -R {{.User}} /tmp/src && chmod -R 775 /tmp/src{{end}}
chmod -R 755 /tmp/scripts
chmod -R 755 /tmp/defaultScripts
{{if .Incremental}}chown -R {{.User}} /tmp/artifacts && chmod -R 775 /tmp/artifacts{{end}}
mkdir -p /opt/sti/bin
{{if .RunPath}}
if [ -f {{.RunPath}} ]; then
cp {{.RunPath}} /opt/sti/bin
fi
{{end}}
if [ -f {{.AssemblePath}} ]; then
exec su {{.User}} - -s /bin/sh -c "{{.AssemblePath}} {{if .Usage}}-h{{end}}"
else
echo "No assemble script supplied in ScriptsUrl argument, application source, or default url in the image."
fi
`))