Commit 18b19a6
authored
Refactor utility placement: move shared helpers out of specialized files and remove micro-packages/files (#4117)
Semantic clustering flagged utility outliers and micro-file/package
sprawl across `internal/`. This PR consolidates shared helpers into
appropriate common packages and removes single-purpose file/package
fragmentation while preserving existing behavior.
- **Version composition moved to `internal/version`**
- Extracted `buildVersionString` from `main.go` into
`version.BuildVersionString(mainVersion, gitCommit, buildDate)`.
- `main` now delegates version-string assembly to `internal/version`,
making logic package-local and testable outside `main`.
- **Transient HTTP classification centralized in `httputil`**
- Promoted config-local `isTransientHTTPError` to shared
`httputil.IsTransientHTTPError`.
- Updated config schema fetch retry path to call the shared helper.
- Moved associated test coverage from `internal/config` to
`internal/httputil`.
- **Removed `timeutil` micro-package**
- Moved `FormatDuration` from `internal/timeutil` to `internal/strutil`.
- Updated logger time-diff formatting call sites to
`strutil.FormatDuration`.
- Deleted `internal/timeutil` files.
- **Collapsed micro-files in `auth` and `oidc`**
- Merged `GenerateRandomAPIKey` (and logger) into
`internal/auth/header.go`; removed `internal/auth/apikey.go`.
- Merged `ErrMissingOIDCEnvVar` into `internal/oidc/provider.go`;
removed `internal/oidc/errors.go`.
- **Inlined single-use logger helper**
- Removed `getMapKeys` from `internal/logger/rpc_helpers.go`.
- Inlined key extraction at the call site and dropped now-obsolete unit
test for that private helper.
- **Docs alignment**
- Updated package-structure docs to reflect removal of
`internal/timeutil` and expanded `internal/strutil` role.
```go
// before (main.go)
versionStr := buildVersionString()
// after
versionStr := version.BuildVersionString(Version, GitCommit, BuildDate)
```
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `example.com`
> - Triggering command: `/tmp/go-build3787159813/b514/launcher.test
/tmp/go-build3787159813/b514/launcher.test
-test.testlogfile=/tmp/go-build3787159813/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build3787159813/b423/vet.cfg
rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go =0 x_amd64/vet --gdwarf-5
esource/v1 -o x_amd64/vet --de�� _.a --debug-prefix-m-ifaceassert
x_amd64/vet -I go-sdk/mcp -I x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build2056270914/b513/launcher.test
/tmp/go-build2056270914/b513/launcher.test
-test.testlogfile=/tmp/go-build2056270914/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s know��
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustgit
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustpush
x_amd64/compile known-linux-gnu/git known-linux-gnu/ls-files
known-linux-gnu/--exclude-standard x_amd64/compile know��
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-2b6a8d2f6e1dc71b.rlib
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libadler2-39ffdbc27c978ccc.rlib
/opt/containerd/bin/bash /run/containerd/git 7213e0dede2210feconfig json
7213e0dede2210fed31/init.pid` (dns block)
> - `invalid-host-that-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3787159813/b496/config.test
/tmp/go-build3787159813/b496/config.test
-test.testlogfile=/tmp/go-build3787159813/b496/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build3787159813/b317/vet.cfg @v1.1.3/cpu/cpu.-errorsas
89155655/b151//_-ifaceassert x_amd64/vet --gdwarf-5 --64 155655/b151/
x_amd64/vet -w ache/go/1.25.8/x-errorsas dHAhgBmen x_amd64/vet OUTPUT -d
ut-3746032072.c x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build1806864329/b491/config.test
/tmp/go-build1806864329/b491/config.test
-test.testlogfile=/tmp/go-build1806864329/b491/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.04.rcgu-importcfg
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.05.rcgu/tmp/go-build1806864329/b237/importcfg
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.06.rcgu-pack
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.07.rcgu/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/internal/difc/agent.go
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.08.rcgu/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/internal/difc/capabilities.go
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.09.rcgu.o
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.10.rcgu.o
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.11.rcgu.o
bug/��
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.13.rcgu.o
bug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.14.rcgu.o
-guard/target/de--build-id
ntime.v2.task/mo/opt/copilot-runtime/copilot-developer-action-main/dist/ripgrep/bin/linux-x64/rg-trimpath
/tmp/go-build389--files lib/rustlib/x86_--hidden lib/rustlib/x86_--glob`
(dns block)
> - `nonexistent.local`
> - Triggering command: `/tmp/go-build3787159813/b514/launcher.test
/tmp/go-build3787159813/b514/launcher.test
-test.testlogfile=/tmp/go-build3787159813/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build3787159813/b423/vet.cfg
rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go =0 x_amd64/vet --gdwarf-5
esource/v1 -o x_amd64/vet --de�� _.a --debug-prefix-m-ifaceassert
x_amd64/vet -I go-sdk/mcp -I x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build2056270914/b513/launcher.test
/tmp/go-build2056270914/b513/launcher.test
-test.testlogfile=/tmp/go-build2056270914/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s know��
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustgit
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustpush
x_amd64/compile known-linux-gnu/git known-linux-gnu/ls-files
known-linux-gnu/--exclude-standard x_amd64/compile know��
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-2b6a8d2f6e1dc71b.rlib
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libadler2-39ffdbc27c978ccc.rlib
/opt/containerd/bin/bash /run/containerd/git 7213e0dede2210feconfig json
7213e0dede2210fed31/init.pid` (dns block)
> - `slow.example.com`
> - Triggering command: `/tmp/go-build3787159813/b514/launcher.test
/tmp/go-build3787159813/b514/launcher.test
-test.testlogfile=/tmp/go-build3787159813/b514/testlog.txt
-test.paniconexit0 -test.timeout=10m0s
/tmp/go-build3787159813/b423/vet.cfg
rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go =0 x_amd64/vet --gdwarf-5
esource/v1 -o x_amd64/vet --de�� _.a --debug-prefix-m-ifaceassert
x_amd64/vet -I go-sdk/mcp -I x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build2056270914/b513/launcher.test
/tmp/go-build2056270914/b513/launcher.test
-test.testlogfile=/tmp/go-build2056270914/b513/testlog.txt
-test.paniconexit0 -test.timeout=10m0s know��
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustgit
known-linux-gnu/lib/rustlib/x86_/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/guards/github-guard/rustpush
x_amd64/compile known-linux-gnu/git known-linux-gnu/ls-files
known-linux-gnu/--exclude-standard x_amd64/compile know��
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-2b6a8d2f6e1dc71b.rlib
known-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libadler2-39ffdbc27c978ccc.rlib
/opt/containerd/bin/bash /run/containerd/git 7213e0dede2210feconfig json
7213e0dede2210fed31/init.pid` (dns block)
> - `this-host-does-not-exist-12345.com`
> - Triggering command: `/tmp/go-build3787159813/b523/mcp.test
/tmp/go-build3787159813/b523/mcp.test
-test.testlogfile=/tmp/go-build3787159813/b523/testlog.txt
-test.paniconexit0 -test.timeout=10m0s -W cfg
/tmp/go-build389-ifaceassert x_amd64/vet _amd64.s
g/protobuf/proto--version --64 x_amd64/vet cfg 155655/b281/_pkg_.a -fPIC
x_amd64/vet -pthread .io/otel/exporte/usr/bin/runc
-fmessage-length--version x_amd64/vet` (dns block)
> - Triggering command: `/tmp/go-build2056270914/b522/mcp.test
/tmp/go-build2056270914/b522/mcp.test
-test.testlogfile=/tmp/go-build2056270914/b522/testlog.txt
-test.paniconexit0 -test.timeout=10m0s go1.25.8 -c=4 -nolocalimports
-importcfg /tmp/go-build3333051407/b001/importcfg -pack
/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/main.go
/home/REDACTED/work/gh-aw-mcpg/gh-aw-mcpg/version.go ive.��
ive.12123747d8da05ed-cgu.02.rcgugo1.25.8
ive.12123747d8da05ed-cgu.03.rcgu-c=4
ive.12123747d8da05ed-cgu.04.rcgu-nolocalimports
ive.12123747d8da/opt/hostedtoolcache/go/1.25.8/x64/pkg/tool/linux_amd64/link
ive.12123747d8da-V=full ive.12123747d8da05ed-cgu.07.rcgu-bool
ive.12123747d8da05ed-cgu.08.rcgu-buildtags` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/github/gh-aw-mcpg/settings/copilot/coding_agent)
(admins only)
>
> </details>File tree
17 files changed
+108
-182
lines changed- internal
- auth
- config
- httputil
- logger
- oidc
- strutil
- version
17 files changed
+108
-182
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | | - | |
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
274 | | - | |
275 | 274 | | |
276 | 275 | | |
277 | 276 | | |
| |||
293 | 292 | | |
294 | 293 | | |
295 | 294 | | |
296 | | - | |
| 295 | + | |
297 | 296 | | |
298 | 297 | | |
299 | 298 | | |
300 | | - | |
301 | 299 | | |
302 | 300 | | |
303 | 301 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| |||
180 | 182 | | |
181 | 183 | | |
182 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | 53 | | |
61 | 54 | | |
62 | 55 | | |
| |||
260 | 253 | | |
261 | 254 | | |
262 | 255 | | |
263 | | - | |
| 256 | + | |
264 | 257 | | |
265 | 258 | | |
266 | 259 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
Lines changed: 4 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | | - | |
125 | | - | |
| 124 | + | |
| 125 | + | |
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
152 | | - | |
| 152 | + | |
153 | 153 | | |
154 | | - | |
| 154 | + | |
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
10 | 9 | | |
11 | 10 | | |
12 | 11 | | |
| |||
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | 86 | | |
84 | 87 | | |
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | 91 | | |
98 | 92 | | |
99 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | | - | |
343 | | - | |
344 | | - | |
345 | | - | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
374 | | - | |
375 | | - | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | 333 | | |
381 | 334 | | |
382 | 335 | | |
| |||
0 commit comments