forked from harness/gitness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerfile.go
44 lines (34 loc) · 899 Bytes
/
dockerfile.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
33
34
35
36
37
38
39
40
41
42
43
44
package dockerfile
import (
"bytes"
"fmt"
)
type Dockerfile struct {
bytes.Buffer
}
func New(from string) *Dockerfile {
d := Dockerfile{}
d.WriteFrom(from)
return &d
}
func (d *Dockerfile) WriteAdd(from, to string) {
d.WriteString(fmt.Sprintf("ADD %s %s\n", from, to))
}
func (d *Dockerfile) WriteFrom(from string) {
d.WriteString(fmt.Sprintf("FROM %s\n", from))
}
func (d *Dockerfile) WriteRun(cmd string) {
d.WriteString(fmt.Sprintf("RUN %s\n", cmd))
}
func (d *Dockerfile) WriteUser(user string) {
d.WriteString(fmt.Sprintf("USER %s\n", user))
}
func (d *Dockerfile) WriteEnv(key, val string) {
d.WriteString(fmt.Sprintf("ENV %s %s\n", key, val))
}
func (d *Dockerfile) WriteWorkdir(workdir string) {
d.WriteString(fmt.Sprintf("WORKDIR %s\n", workdir))
}
func (d *Dockerfile) WriteEntrypoint(entrypoint string) {
d.WriteString(fmt.Sprintf("ENTRYPOINT %s\n", entrypoint))
}