oficina / equipo Public

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

Plain git — no account needed to clone.

Download

Download this file

1package provider
2
3import (
4 "amadan.net/oficina/equipo/internal/runner/provider/gotoolchain"
5 "os"
6)
7
8// GoLease retains toolchain descriptors for a Pi attempt. It grants no account
9// authority; it uses the same tree validation and pins as an account lease.
10type GoLease struct{ lease AccountLease }
11
12func (l *GoLease) Close() {
13 l.lease.goMu.Lock()
14 defer l.lease.goMu.Unlock()
15 l.lease.goClosed = true
16 for _, pin := range l.lease.goPins {
17 pin.file.Close()
18 }
19 l.lease.goPins = nil
20}
21
22func piGoPolicy(in PiPolicyInputs, m *effectiveManifest) error {
23 if in.Action != "implement" || in.GoRoot == "" {
24 return nil
25 }
26 if in.GoLease == nil {
27 return ErrPolicy
28 }
29 mounts := []Mount{{Source: in.GoRoot, Target: "/opt/go", ReadOnly: true}}
30 if in.ModuleCache != "" {
31 if _, err := os.Lstat(in.ModuleCache); !os.IsNotExist(err) {
32 mounts = append(mounts, Mount{Source: in.ModuleCache, Target: "/opt/go-mod", ReadOnly: true})
33 }
34 }
35 for _, mount := range mounts {
36 for _, protected := range []string{in.Home, in.Workspace, in.Tree} {
37 if withinPath(mount.Source, protected) || withinPath(protected, mount.Source) {
38 return ErrPolicy
39 }
40 }
41 f, err := goTree(mount, Binding{provenance: &in.GoLease.lease})
42 if err != nil {
43 return err
44 }
45 m.Files = append(m.Files, f)
46 m.OuterMounts = append(m.OuterMounts, mount)
47 }
48 for k, v := range gotoolchain.Environment("pi") {
49 m.Env[k] = v
50 }
51 m.Env["GIT_CONFIG_GLOBAL"] = "/dev/null"
52 m.Env["GIT_CONFIG_NOSYSTEM"] = "1"
53 return nil
54}
55