oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1package main
2
3import (
4 "amadan.net/oficina/equipo/internal/runner/provider"
5 runnersetup "amadan.net/oficina/equipo/internal/runner/setup"
6 "path/filepath"
7)
8
9func accountEnvironment(getenv func(string) string) (func(string) string, error) {
10 if getenv("EQUIPO_ORIGIN") != "" {
11 return getenv, nil
12 }
13 home := getenv("HOME")
14 if !filepath.IsAbs(home) {
15 return nil, provider.ErrContract
16 }
17 root := getenv("EQUIPO_RUNNER_ROOT")
18 if root == "" {
19 root = filepath.Join(home, ".local/share/equipo-runner")
20 }
21 values, e := runnersetup.ReadServiceEnvironment(root)
22 if e != nil {
23 return nil, e
24 }
25 return func(k string) string {
26 if v := getenv(k); v != "" {
27 return v
28 }
29 return values[k]
30 }, nil
31}
32