-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.go
42 lines (35 loc) · 870 Bytes
/
setup.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
package astra
import (
"os"
)
// Setup sets up the service by creating the temp dir and caching.
// Setup should be called before anything else in the service.
func (s *Service) Setup() error {
s.Log.Info().Msg("Setting up")
s.Log.Info().Msg("Creating temp dir")
err := s.setupAstraDir()
if err != nil {
s.Log.Error().Err(err).Msg("Error creating temp dir")
return err
}
s.Log.Info().Msg("Creating temp dir complete")
if s.WorkDir == "" {
s.Log.Info().Msg("Noting current dir")
cwd, err := os.Getwd()
if err != nil {
s.Log.Error().Err(err).Msg("Error noting current dir")
return err
}
s.WorkDir = cwd
s.Log.Info().Msg("Noting current dir complete")
}
if s.CacheEnabled {
err := s.Cache()
if err != nil {
s.Log.Error().Err(err).Msg("Error caching")
return err
}
}
s.Log.Info().Msg("Setting up complete")
return nil
}