package provider import ( "amadan.net/oficina/equipo/internal/runner/provider/gotoolchain" "os" ) // GoLease retains toolchain descriptors for a Pi attempt. It grants no account // authority; it uses the same tree validation and pins as an account lease. type GoLease struct{ lease AccountLease } func (l *GoLease) Close() { l.lease.goMu.Lock() defer l.lease.goMu.Unlock() l.lease.goClosed = true for _, pin := range l.lease.goPins { pin.file.Close() } l.lease.goPins = nil } func piGoPolicy(in PiPolicyInputs, m *effectiveManifest) error { if in.Action != "implement" || in.GoRoot == "" { return nil } if in.GoLease == nil { return ErrPolicy } mounts := []Mount{{Source: in.GoRoot, Target: "/opt/go", ReadOnly: true}} if in.ModuleCache != "" { if _, err := os.Lstat(in.ModuleCache); !os.IsNotExist(err) { mounts = append(mounts, Mount{Source: in.ModuleCache, Target: "/opt/go-mod", ReadOnly: true}) } } for _, mount := range mounts { for _, protected := range []string{in.Home, in.Workspace, in.Tree} { if withinPath(mount.Source, protected) || withinPath(protected, mount.Source) { return ErrPolicy } } f, err := goTree(mount, Binding{provenance: &in.GoLease.lease}) if err != nil { return err } m.Files = append(m.Files, f) m.OuterMounts = append(m.OuterMounts, mount) } for k, v := range gotoolchain.Environment("pi") { m.Env[k] = v } m.Env["GIT_CONFIG_GLOBAL"] = "/dev/null" m.Env["GIT_CONFIG_NOSYSTEM"] = "1" return nil }