Commit ae68923
authored
Module manager: overridable manifest source + stronger install verification (#618)
# Description
Adds the ability to temporarily point the module manager at an alternate
manifest (registry) — via a one-shot CLI switch or an interactive command —
primarily for local testing of modules and registries. Also hardens module
installation so a download is always verified against the checksum declared in
the manifest, and makes a non-default manifest impossible to miss while working
interactively.
## Changes
### 1. Temporary manifest override
- **Global `--manifest <path|url>` switch** for one-shot commands
(`internal/modmanager/modmanager.go`):
- Accepts an `http(s)` URL **or** a local filesystem path (a `file://`
prefix is also accepted), enabling fully local testing.
- May appear anywhere in the command; it is stripped from args before
subcommand dispatch (`applyManifestFlag`).
- Supports both `--manifest x.yaml` and `--manifest=x.yaml` forms.
- **Validates** that the source ends in `.yaml`/`.yml` (URL query/fragment
ignored); otherwise errors out (`validateManifestSource`).
- **Warns** whenever a non-default manifest is in use.
- **Manifest loading now supports local files** (`internal/modmanager/registry.go`):
- `fetchRegistry` reads from a local path / `file://` or fetches over
`http(s)` based on the configured source.
- New `manifestSource` package variable holds the active source (defaults to
the official registry URL).
### 2. Stronger install verification
`internal/modmanager/install.go`:
- **Refuses to install** a manifest entry that has no `sha256` checksum
("refusing to install unverifiable module") instead of failing with a
confusing mismatch.
- The downloaded archive is streamed through `verifyArchive`, which fails with
a clear `SHA256 mismatch` error when the bytes don't match the manifest. On
failure no module directory is created.
- Adds a visible `Verified SHA256 checksum.` step on success.
- Module archives referenced by a manifest `url` may now be **local paths or
`file://` URLs** (`openArchiveReader`), so a module can be installed entirely
from local files for testing — still SHA256-verified.
### 3. Interactive `manifest-source` command
`internal/modmanager/interactive.go`:
- New REPL command `manifest-source` (alias `manifest`) — the interactive
context can't use the `--manifest` switch, so this changes the source for the
rest of the session:
- no argument → prints the current source,
- `<path|url>` → validates (`.yaml`), sets it, and warns,
- `default` / `reset` → restores the default registry.
- Added to the interactive help listing.
### 4. Persistent visual warning for a non-default manifest
- When the active manifest differs from the default registry, a
**color-emphasized banner** (bold black on a yellow background) is printed
**above the prompt on every interactive iteration**, so the non-default state
stays visible the whole session (`printCustomManifestBanner`,
`warnBanner` in `internal/modmanager/color.go`). The banner disappears once
the source is reset to default.
### 5. Tests & docs
- `internal/modmanager/modmanager_test.go`: added coverage for
`validateManifestSource`, `applyManifestFlag` (and error paths),
`handleManifestSourceCommand` (show/set/reset/invalid), local-file
`fetchRegistry`, `isHTTPURL`, and `openArchiveReader` (local file + missing).
- `modules/README.md`: documented the `--manifest` switch, local-path/`file://`
support, the interactive `manifest-source` command, and that downloads are
SHA256-verified in all cases.
## Notes
- The override is **temporary** by design: the `--manifest` switch affects a
single command, and the interactive `manifest-source` command affects only
the current session. Nothing is persisted to disk.1 parent 2297bbf commit ae68923
7 files changed
Lines changed: 411 additions & 13 deletions
File tree
- internal/modmanager
- modules
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
54 | 60 | | |
55 | 61 | | |
56 | 62 | | |
| |||
63 | 69 | | |
64 | 70 | | |
65 | 71 | | |
66 | | - | |
| 72 | + | |
67 | 73 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 74 | + | |
74 | 75 | | |
| 76 | + | |
75 | 77 | | |
76 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
81 | 85 | | |
82 | 86 | | |
83 | 87 | | |
| 88 | + | |
| 89 | + | |
84 | 90 | | |
85 | 91 | | |
86 | 92 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
92 | 93 | | |
93 | 94 | | |
94 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
95 | 99 | | |
96 | 100 | | |
97 | 101 | | |
| |||
103 | 107 | | |
104 | 108 | | |
105 | 109 | | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
106 | 152 | | |
107 | 153 | | |
108 | 154 | | |
| |||
115 | 161 | | |
116 | 162 | | |
117 | 163 | | |
| 164 | + | |
118 | 165 | | |
119 | 166 | | |
120 | 167 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
16 | 22 | | |
17 | 23 | | |
18 | 24 | | |
| |||
22 | 28 | | |
23 | 29 | | |
24 | 30 | | |
25 | | - | |
26 | 31 | | |
27 | 32 | | |
28 | 33 | | |
| |||
83 | 88 | | |
84 | 89 | | |
85 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
86 | 154 | | |
87 | 155 | | |
88 | 156 | | |
| |||
105 | 173 | | |
106 | 174 | | |
107 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
108 | 182 | | |
109 | 183 | | |
110 | 184 | | |
| |||
0 commit comments