Commit a85b23a
committed
fix(publish): support short-form port mapping with variable interpolation
When publishing a Compose project with short-form port syntax containing
environment variable substitutions (e.g. `${PORT:-3000}:3000`), `publish`
previously failed with:
'services[...].ports[0]' expected a map or struct, got "string"
During `preChecks`, `loadUnresolvedFile` loads each file with
`SkipInterpolation = true` to detect raw un-interpolated literals and
secrets. Because variable interpolation is skipped, `types.ParsePortConfig`
cannot parse the non-numeric port strings into `ServicePortConfig`
definitions, leaving them as raw string slices in the canonical dictionary.
When `loader.Transform` attempts to decode this into `types.Project`,
mapstructure fails because `types.ServiceConfig.Ports` expects a slice of
structs, not strings.
Neither `collectEnvCheckFindings` nor `checkForSensitiveData` inspects
service ports (only environment, env_files, extends, and configs are
checked). Load the raw model via `loader.LoadModelWithContext` and strip
`ports` from services before calling `loader.Transform`. Additionally,
have `composeFileAsByteReader` read the raw compose file directly from
disk so all file content is preserved for secret scanning without
unnecessary decoding.
Fixes #13672
Signed-off-by: Hooman <hooman.ghkhani@gmail.com>1 parent a255af9 commit a85b23a
2 files changed
Lines changed: 95 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
632 | 632 | | |
633 | 633 | | |
634 | 634 | | |
635 | | - | |
| 635 | + | |
636 | 636 | | |
637 | | - | |
| 637 | + | |
638 | 638 | | |
639 | 639 | | |
640 | 640 | | |
| |||
651 | 651 | | |
652 | 652 | | |
653 | 653 | | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
654 | 677 | | |
655 | 678 | | |
656 | 679 | | |
| |||
793 | 816 | | |
794 | 817 | | |
795 | 818 | | |
796 | | - | |
797 | | - | |
| 819 | + | |
| 820 | + | |
798 | 821 | | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
| 822 | + | |
804 | 823 | | |
805 | | - | |
| 824 | + | |
806 | 825 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
212 | 262 | | |
213 | 263 | | |
214 | 264 | | |
| |||
326 | 376 | | |
327 | 377 | | |
328 | 378 | | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
329 | 395 | | |
330 | 396 | | |
331 | 397 | | |
| |||
0 commit comments