Documentation
¶
Overview ¶
Package env reads and writes agent-vm's env files, ~/.agent-vm/env and a project's .agent-vm.env, which the VM's shell sources: without ever running a shell on the host, since the VM can write the project's.
Index ¶
- Constants
- Variables
- func Drop(content, key string) string
- func InProject(dir, target string) bool
- func Lookup(content, key string) (string, int)
- func MkdirIn(top, rel string) error
- func Names(content string) []string
- func Payload(shared, dir string) string
- func ProjectEnvFile(dir string) string
- func ProjectPath(dir, p string) string
- func ProjectRel(dir, target string) (string, bool)
- func ReadIn(top, rel string) ([]byte, error)
- func SQEscape(s string) string
- func StripCR(content string) string
- func TouchIn(top, rel string) error
- func WriteIn(top, rel string, data []byte) error
Constants ¶
const ( Found = 0 NotFound = 1 // Refused: the file uses syntax this reader does not interpret, and no // key can be answered. Refused = 3 )
Status of a read.
Variables ¶
var ( // ErrNoFile: the file is not there (Read only). ErrNoFile = errors.New("no such file") // ErrUnsafe: a symlink, or something other than a folder or a regular // file, is on the way. ErrUnsafe = errors.New("a symlink, or not a regular file or folder, on the way") )
The ways a NoFollow call fails.
Functions ¶
func Drop ¶
Drop is content without key's assignments, whole: a value Set wrote over several lines goes with its first line. Each line keeps its newline.
func Lookup ¶
Lookup is the value content assigns to key, as a shell sourcing it would, without a shell. Accepted: an optional `export `, then single-quoted parts (which may span lines, as Set writes a value with a newline), double-quoted parts with nothing to expand, and bare characters other than $ ` \ ; & | < > ( ) ~, then an optional `# comment`. The last assignment wins. One line refused, and no key is answered: a quote left open or a trailing backslash makes the shell read the next lines into that value, and other syntax can run anything, an assignment to any key included. A line that is not an assignment, a comment or blank counts as refused.
func Payload ¶
Payload is what is pushed into the VM of the project dir: the shared file first, the project's next, so the project's value wins (the guest sources it). The project's file is only in here when AGENT_VM_PROJECT_ENV puts it outside the project; inside, the VM reads it itself (see ProjectRel).
func ProjectEnvFile ¶
ProjectEnvFile is the project dir's env file: in the project, so it follows a clone, a move and a delete.
func ProjectPath ¶
ProjectPath is a project file's path: p relative to the project dir unless absolute. An integrator moves the env file and the runtime script into a folder of its own (".mytool/env") with AGENT_VM_PROJECT_ENV and AGENT_VM_PROJECT_RUNTIME.
func ProjectRel ¶
ProjectRel is target relative to the project dir, when it is inside it, where the VM can write. The host must not read such a file by its path: the VM can make it a symlink, and the host would follow it to any file of the user's and hand the content over. It is read in the VM, or with NoFollow.
Inside by its spelling, or by where it leads: the project reached through a link of the user's, the other spelling of a linked folder (/tmp and /private/tmp on macOS), another case where the file system ignores it. So target is resolved one component at a time, links followed one hop at a time, and the first step that reaches the project decides, before anything in it is followed. Before that point, every link is outside the project, where the VM cannot change it.
func StripCR ¶
StripCR is content with a CR ending a line removed, each line ending with a newline: a CRLF file (Windows) would put a CR at the end of every value in the guest.
Types ¶
This section is empty.