-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.go
46 lines (36 loc) · 1.04 KB
/
build.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
45
46
package permissions
import (
"os"
"path/filepath"
"time"
"github.com/paketo-buildpacks/packit/v2"
"github.com/paketo-buildpacks/packit/v2/scribe"
)
const (
tmpDirName = "tmp"
pidsDirName = "pids"
cacheDirName = "cache"
)
func Build(logger scribe.Emitter) packit.BuildFunc {
return func(context packit.BuildContext) (packit.BuildResult, error) {
logger.Title("%s %s", context.BuildpackInfo.Name, context.BuildpackInfo.Version)
before := time.Now()
dirs := []string{
filepath.Join(context.WorkingDir, tmpDirName),
filepath.Join(context.WorkingDir, tmpDirName, pidsDirName),
filepath.Join(context.WorkingDir, tmpDirName, cacheDirName),
}
logger.Process("changing permission for directories:")
for _, dir := range dirs {
logger.Process(dir)
if err := os.MkdirAll(dir, 0770); err != nil {
return packit.BuildResult{}, err
}
if err := os.Chmod(dir, 0770); err != nil {
return packit.BuildResult{}, err
}
}
logger.Action("Completed in %s", time.Since(before))
return packit.BuildResult{}, nil
}
}