Feature 57 (config and provisioning): modules declare config and provisions, their files rendered from templates; synced with main (issues of feature 57, 874)
This commit is contained in:
@@ -24,11 +24,13 @@ type manifest struct {
|
||||
Claims []any `json:"claims"`
|
||||
Seats []any `json:"seats"`
|
||||
Shell []any `json:"shell"`
|
||||
Contributions []struct {
|
||||
Seat string `json:"seat"`
|
||||
Kind string `json:"kind"`
|
||||
Content string `json:"content"`
|
||||
} `json:"contributions"`
|
||||
Moved bool `json:"moved"`
|
||||
Contributions []any `json:"contributions"`
|
||||
Items []struct {
|
||||
Collection string `json:"collection"`
|
||||
Name string `json:"name"`
|
||||
Template string `json:"template"`
|
||||
} `json:"items"`
|
||||
Environment any `json:"environment"`
|
||||
Build struct {
|
||||
Artifacts []map[string]any `json:"artifacts"`
|
||||
@@ -72,15 +74,12 @@ func TestItInstallsNothingAndOwnsNoFile(t *testing.T) {
|
||||
|
||||
func TestTheOneContributionIsTheStartAndTheWindowRules(t *testing.T) {
|
||||
m, _ := readManifest(t)
|
||||
if len(m.Contributions) != 1 {
|
||||
t.Fatalf("%+v", m.Contributions)
|
||||
}
|
||||
c := m.Contributions[0]
|
||||
if c.Seat != "node-display-session" || c.Kind != "config" || !strings.HasSuffix(c.Content, "\n") {
|
||||
t.Fatalf("%+v", c)
|
||||
content := displayLines(t, m)
|
||||
if !strings.HasSuffix(content, "\n") {
|
||||
t.Fatalf("%q", content)
|
||||
}
|
||||
var execs, rules []string
|
||||
for _, l := range strings.Split(c.Content, "\n") {
|
||||
for _, l := range strings.Split(content, "\n") {
|
||||
l = strings.TrimSpace(l)
|
||||
switch {
|
||||
case strings.HasPrefix(l, "exec"):
|
||||
@@ -112,7 +111,7 @@ func TestTheOneContributionIsTheStartAndTheWindowRules(t *testing.T) {
|
||||
}
|
||||
// The placed lines start Slack once: the fake i3 configuration below holds exactly this content.
|
||||
f := newFake(t)
|
||||
f.write(testHome+"/"+i3Main, "exec --no-startup-id dex --autostart --environment i3\n# slack\n"+c.Content)
|
||||
f.write(testHome+"/"+i3Main, "exec --no-startup-id dex --autostart --environment i3\n# slack\n"+content)
|
||||
if s := f.starts(); len(s) != 1 || !s[0].Mine {
|
||||
t.Fatalf("%+v", s)
|
||||
}
|
||||
@@ -139,7 +138,7 @@ func TestTheToolsAgreeWithTheManifest(t *testing.T) {
|
||||
for name := range served {
|
||||
t.Errorf("the bundle serves %s, which module.json does not list", name)
|
||||
}
|
||||
if len(m.Build.Artifacts) != 1 {
|
||||
if len(m.Build.Artifacts) != 2 { // the tools bundle and the archive of its template
|
||||
t.Fatalf("%v", m.Build.Artifacts)
|
||||
}
|
||||
b := m.Build.Artifacts[0]
|
||||
@@ -154,3 +153,18 @@ func TestTheToolsAgreeWithTheManifest(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// displayLines is the module's lines for the window manager: the text of the template of its one item of the
|
||||
// collection contribution:node-display-session:config (design 57 L3, issue 848).
|
||||
func displayLines(t *testing.T, m manifest) string {
|
||||
t.Helper()
|
||||
if !m.Moved || len(m.Contributions) != 0 || len(m.Items) != 1 ||
|
||||
m.Items[0].Collection != "contribution:node-display-session:config" {
|
||||
t.Fatalf("moved %v, contributions %v, items %+v", m.Moved, m.Contributions, m.Items)
|
||||
}
|
||||
text, err := os.ReadFile(filepath.Join("..", "..", m.Items[0].Template))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
return string(text)
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ func newSlack(t *testing.T) (*fake, map[string]string) {
|
||||
|
||||
func contribution(t *testing.T) string {
|
||||
m, _ := readManifest(t)
|
||||
return m.Contributions[0].Content
|
||||
return displayLines(t, m)
|
||||
}
|
||||
|
||||
func noSecrets(t *testing.T, v any) string {
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
# Slack (module slack, novox/hq ADR 0208, ADR 0212). Owned by the mesh: replaced at every push.
|
||||
# Its one start: at login, to the tray (-s), with the arguments of the package's own desktop entry.
|
||||
# No XDG autostart entry starts it as well; slack_check names one if it appears.
|
||||
exec --no-startup-id /usr/bin/slack --gtk-version=3 -s
|
||||
# The chat window. Slack owns four X windows, and the only one i3 manages has the class "slack" in
|
||||
# lower case; the three of class "Slack" (the packaged entry's StartupWMClass) are its unmanaged
|
||||
# helpers and its tray icon, so a rule on class="Slack" matches nothing. window_role keeps a call or
|
||||
# screen-share window out of the rules. $ws3 is i3's, in scope here.
|
||||
for_window [class="(?i)^slack$" window_role="browser-window"] move to workspace $ws3
|
||||
for_window [class="(?i)^slack$" window_role="browser-window"] floating disable
|
||||
for_window [class="(?i)^slack$" window_role="browser-window"] border pixel 2
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"module": "slack",
|
||||
"version": "1",
|
||||
"moved": true,
|
||||
"requires": [
|
||||
"x11-display"
|
||||
],
|
||||
@@ -22,14 +23,19 @@
|
||||
"loads": [
|
||||
"slack-tools"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "files",
|
||||
"kind": "archive",
|
||||
"from": "files"
|
||||
}
|
||||
]
|
||||
},
|
||||
"contributions": [
|
||||
"items": [
|
||||
{
|
||||
"seat": "node-display-session",
|
||||
"kind": "config",
|
||||
"content": "# Slack (module slack, novox/hq ADR 0208, ADR 0212). Owned by the mesh: replaced at every push.\n# Its one start: at login, to the tray (-s), with the arguments of the package's own desktop entry.\n# No XDG autostart entry starts it as well; slack_check names one if it appears.\nexec --no-startup-id /usr/bin/slack --gtk-version=3 -s\n# The chat window. Slack owns four X windows, and the only one i3 manages has the class \"slack\" in\n# lower case; the three of class \"Slack\" (the packaged entry's StartupWMClass) are its unmanaged\n# helpers and its tray icon, so a rule on class=\"Slack\" matches nothing. window_role keeps a call or\n# screen-share window out of the rules. $ws3 is i3's, in scope here.\nfor_window [class=\"(?i)^slack$\" window_role=\"browser-window\"] move to workspace $ws3\nfor_window [class=\"(?i)^slack$\" window_role=\"browser-window\"] floating disable\nfor_window [class=\"(?i)^slack$\" window_role=\"browser-window\"] border pixel 2\n"
|
||||
"collection": "contribution:node-display-session:config",
|
||||
"name": "display-session",
|
||||
"template": "files/display-session"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user