v0.4.2 257b319

contexts_containers.go RawHistoryFolder

1// SPDX-License-Identifier: MIT
2
3package executor
4
5import (
6	"strings"
7
8	"github.com/google/uuid"
9
10	"bnema.dev/ermite-actions/expr"
11)
12
13// The job.container and job.services contexts (JobContext.cs:20-47,
14// ContainerOperationProvider.cs:96, :215-232, :237-240). The runner's
15// JobContext.Container and .Services create their dictionary when they are
16// read, which is why a recorded job that ran a docker action has
17// "container": {} (act-docker-image).
18
19// jobSub returns the dictionary at job.<key>, creating it when missing.
20func (s *State) jobSub(key string) *expr.Dictionary {
21	if v, ok := s.job.Get(key); ok {
22		if d, ok := v.(*expr.Dictionary); ok {
23			return d
24		}
25	}
26	d := expr.NewDictionary()
27	s.job = setKey(s.job, key, d)
28	return d
29}
30
31// TouchJobContainer is the read of JobContext.Container: job.container exists
32// from then on.
33func (s *State) TouchJobContainer() { s.jobSub("container") }
34
35// SetJobContainer sets job.container.<key> ("network", "id").
36func (s *State) SetJobContainer(key, value string) {
37	d := s.jobSub("container")
38	if _, ok := d.Get(key); ok {
39		s.job = setKey(s.job, "container", replaceKey(d, key, expr.String(value)))
40		return
41	}
42	d.Add(key, expr.String(value))
43}
44
45// JobContainerNetwork is job.container.network, "" when it is not set.
46func (s *State) JobContainerNetwork() string {
47	if v, ok := s.jobSub("container").Get("network"); ok {
48		return expr.CoerceString(v)
49	}
50	return ""
51}
52
53// SetJobService sets job.services.<alias> ({id, ports, network}).
54func (s *State) SetJobService(alias, id, network string, ports []portMapping) {
55	svc := expr.NewDictionary()
56	svc.Add("id", expr.String(id))
57	pd := expr.NewDictionary()
58	for _, p := range ports {
59		pd.Add(p.container, expr.String(p.host))
60	}
61	svc.Add("ports", pd)
62	svc.Add("network", expr.String(network))
63	d := s.jobSub("services")
64	s.job = setKey(s.job, "services", replaceKey(d, alias, svc))
65}
66
67func replaceKey(d *expr.Dictionary, key string, v expr.Value) *expr.Dictionary {
68	return setKey(d, key, v)
69}
70
71// newRunnerStepID is the context name of a step the runner made itself
72// (Initialize containers, Pull <image>, Build <action>): its Guid in "N" format,
73// which does not start with "__", so the entry {outcome, conclusion, outputs:
74// {}} is visible to the user's steps (JobExtension.cs:439 CreateChild(stepId,
75// ..., stepId.ToString("N"), ...), ExecutionContext.UpdateGlobalStepsContext:644;
76// recorded in ctr-basic, svc-redis, act-docker-image). runStep registers its
77// result under it (qstep.ctxID).
78func newRunnerStepID() string { return strings.ReplaceAll(uuid.NewString(), "-", "") }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 4

Tags 11

↑↓ moveenter openesc close