Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example to load config file from string? #707

Closed
vsoch opened this issue Nov 2, 2024 · 1 comment
Closed

Example to load config file from string? #707

vsoch opened this issue Nov 2, 2024 · 1 comment

Comments

@vsoch
Copy link

vsoch commented Nov 2, 2024

This is likely a more rare use case, but I want to use go embed to include a string-ified compose file (that loads into a Project) and I'm wondering if you have an example to do that? I'm looking here: https://github.com/compose-spec/compose-go/blob/b9d3b1deec9bc25de0fa81867ca4df75aef5c791/cli/options.go and I see that ReadConfigFiles can accept a path or stdin, but not a loaded string. I can try to dig deeper and see if I can come up with something, or fall back to reading from file for now, but I'm hoping someone has come up with something.

And a follow up question - is this just a library for implementing the spec or does it make it easy to map into https://github.com/docker/compose?

Derp - it's right here 😆 https://github.com/docker/compose/blob/eececb9add3748fce765c3094575d3c52d8cfdbf/cmd/compose/compose.go#L32-L35.

Thanks!

@vsoch vsoch changed the title Example to read config file from string? Example to load config file from string? Nov 2, 2024
@ndeloof
Copy link
Collaborator

ndeloof commented Jan 23, 2025

To parse a model from a string, you can rely on LoadWithContext passing yaml string as ConfigDetails.ConfigFile.Content

compose-go is a library implementing the compose-spec, docker/compose 100% relies on it (docker/compose is the reference implementation for the spec)

@ndeloof ndeloof closed this as completed Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants