(ctx context2.Context, variables map[string]interface{}, log log.Logger)
| 20 | ) |
| 21 | |
| 22 | func NewContext(ctx context2.Context, variables map[string]interface{}, log log.Logger) Context { |
| 23 | var err error |
| 24 | workingDir, _ := RealWorkDir() |
| 25 | if workingDir == "" { |
| 26 | workingDir, err = os.Getwd() |
| 27 | if err != nil { |
| 28 | panic(errors.Wrap(err, "get current working directory")) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | return &context{ |
| 33 | context: ctx, |
| 34 | workingDir: workingDir, |
| 35 | runID: strings.ToLower(randutil.GenerateRandomString(12)), |
| 36 | environ: env.NewVariableEnvProvider(expand.ListEnviron(os.Environ()...), env.ConvertMap(variables)), |
| 37 | log: log, |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | func RealWorkDir() (string, error) { |
| 42 | if runtime.GOOS == "darwin" { |
nothing calls this directly
no test coverage detected