Refactor to use compose-go instead of libcompose#215
Refactor to use compose-go instead of libcompose#215olljanat-ai wants to merge 13 commits intoburmilla:masterfrom
Conversation
Vendor github.com/compose-spec/compose-go v1.20.2 as preparation for migrating from the deprecated github.com/docker/libcompose library. Also vendors required transitive dependencies. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy the vendored github.com/docker/libcompose code into pkg/libcompose/ as a first step toward replacing it with compose-go. Update all imports throughout the codebase to reference the internal copy. This allows us to modify the internalized code to use compose-go types in subsequent commits. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the internal ServiceConfig (v2) type with a type alias for compose-go's types.ServiceConfig. Keep ServiceConfigV1 for YAML deserialization compatibility with candiedyaml. Add conversion functions between ServiceConfigV1 and compose-go ServiceConfig. Update orchestration code (docker/convert.go, project.go, utils.go) to work with compose-go's type system (MappingWithEquals for env, ServiceVolumeConfig for volumes, ServicePortConfig for ports, etc). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update cmd/control/os.go and cmd/control/console.go to construct compose-go ServiceConfig structs directly via CreateService(). Remove libcompose yaml type imports from engine.go and recovery.go, using plain Go types ([]string, map[string]string) instead of yaml.Command and yaml.SliceorMap. Add CreateServiceV1 helper for backward-compatible ServiceConfigV1 usage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove the deprecated libcompose library from vendor/ now that all code has been migrated to use the internal pkg/libcompose package (which uses compose-go types) instead. Update trash.conf to reflect the dependency change. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Apply gofmt formatting to all files that were modified during the libcompose-to-compose-go migration. Fix go vet errors in validation.go by wrapping non-constant format strings with %s. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
compose-go's ServiceConfig uses pointer types for Logging (*LoggingConfig) and Build (*BuildConfig), unlike the old libcompose which used value types. Add nil checks before accessing these fields to prevent SIGSEGV crashes at boot when services have no logging or build configuration set. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Comment from Grok Expert https://grok.com/share/c2hhcmQtMi1jb3B5_9061f65b-a8e4-49ba-9490-e401e34c8714 |
Comment from ChatGPTReview of PR #215 + Grok feedbackThanks for the contribution and for including the AI review — that’s helpful context. I went through both the PR and the Grok comment, and here’s my structured feedback: 👍 What looks good
|
- Add ValidateV1ServiceConfig() to catch invalid port specs, empty volumes, and missing image/build before conversion - ConvertV1Services now validates and skips broken services with a log message instead of panicking at boot - missingImage() now handles nil config/environment map safely and defaults REGISTRY_DOMAIN to "docker.io" when unset - Fix potential index-out-of-range in image tag parsing when image has no tag or unexpected format Addresses review concern: lack of validation / guardrails. https://claude.ai/code/session_01Hrmn1bwgpnXhVyXhg3zYhF
- Add depAliases map to ServiceFactory for maintainable service name aliasing instead of inline if-statements - Guard against nil Labels map in ServiceFactory.Create - Add comments explaining why DependentServices auto-dependencies are safe when referenced services don't exist (appendLink is a no-op) - Validate serviceValue in LoadSpecialService before proceeding - Handle missing REGISTRY_DOMAIN and malformed image paths gracefully in missingImage() with safe defaults Addresses review concern: coupling to implicit assumptions. https://claude.ai/code/session_01Hrmn1bwgpnXhVyXhg3zYhF
- Add package-level doc to compat.go explaining that existing cloud-config YAML files require no changes after the compose-go migration - Document ConvertServices as the main entry point with compatibility guarantees - Add migration notes to ServiceConfig type alias documenting the key differences from old libcompose types (pointer fields, type changes) and which helper functions to use Addresses review concern: upgrade / backward compatibility impact. https://claude.ai/code/session_01Hrmn1bwgpnXhVyXhg3zYhF
21 tests covering: - ServiceConfigV1ToServiceConfig: nil input, basic fields, logging (nil and non-nil), build config, port parsing (all formats), volume parsing (bind/named/readonly), environment mapping - ConvertV1Services: name assignment, nil service skipping - Helper functions: VolumesToStringSlice, PortsToStringSlice, EnvironmentToSlice, LoggingDriver, LoggingOptions (nil-safe) - ValidateV1ServiceConfig: valid config, nil config, empty volume, unsupported protocol Addresses review concern: missing test coverage. https://claude.ai/code/session_01Hrmn1bwgpnXhVyXhg3zYhF
- Extract convertLogging, convertBuild, convertUlimits from the main conversion function to make each pointer-field conversion self-contained - Extract isPathLike helper for volume type detection - Add doc comments to parsePortString and parseVolumeString explaining all supported format variations - Rename ambiguous variables in preprocessServiceMap (k/k2/v/v2 -> serviceName/service/key/value) and add explanatory comment - Rename unclear 'unchanged' flag to 'mapCopied' in addServices and add comments explaining the copy-on-write and hash-skip logic Addresses review concern: readability / maintainability. https://claude.ai/code/session_01Hrmn1bwgpnXhVyXhg3zYhF
…nts-5xLgu Claude/address pr review comments 5x lgu
|
Honestly I have no idea if all these changes makes sense but I asked Claude Code to handle feedbacks from Grok and ChatGPT. Result was olljanat-ai#1 which was just merged. Will test those later. |
|
Grok seems to accept that fixes implement by Claude are correct: ChatGPT was not able to connect here for some reason. |
|
Review from Google Gemini for all above: PR Review: Legacy Dependencies FixThanks for putting in the hard work to get these legacy dependencies updated! Keeping our base OS dependencies current is crucial for the security, stability, and long-term maintainability of BurmillaOS. Overall, the direction of these changes looks solid. Since dependency bumps (especially legacy ones in an OS environment) can have unintended downstream effects, please ensure the following points are covered before we go ahead and merge: 🔍 Review Checklist:
💬 Feedback:The code changes look correct based on standard dependency upgrade practices. If you've verified that the OS still boots cleanly and System Docker spins up without issues, this is good to go. Status: Approved conditionally upon green CI and successful boot testing. Great work! 👍 |
|
@prologic this is massive refactoring for code so might be two big to read it all. Most important logic is in |
|
Are we censoring yhe libcompose package here? |
Not sure what you mean with word "censoring" but the key functionality of BurmillaOS is that it uses https://github.com/burmilla/os/blob/master/os-config.tpl.yml and deployment specific extra configuration control whole system and it currently uses customized version of libcompose. Look #214 for more context. |
100% build by Claude Code. Closes #214
At least boots normally from both ISO and disk and passes unit tests which Rancher have created but needs more testing before merging.
EDIT: FYI, for anyone who is interested: Tools used in this are: