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

loader.Load from content fails #699

Closed
lionello opened this issue Oct 15, 2024 · 1 comment
Closed

loader.Load from content fails #699

lionello opened this issue Oct 15, 2024 · 1 comment

Comments

@lionello
Copy link
Contributor

	var content []byte
	// set content
	project, err := loader.LoadWithContext(context.TODO(), compose.ConfigDetails{ConfigFiles: []compose.ConfigFile{{Content: content}}})

fails with err failed to read file "": open : no such file or directory because it's trying to load the Compose config from "" in order to get the project name.

Workaround is to set the project name ourselves:

	project, err := loader.LoadWithContext(context.TODO(), compose.ConfigDetails{ConfigFiles: []compose.ConfigFile{{Content: content}}}, func(o *loader.Options) {
		o.SetProjectName("project1", true) // HACK: workaround for a bug in compose-go where it insists on loading the project name from the first file
	})
@lionello
Copy link
Contributor Author

My bad. It appears to do this only when the content does not have a top-level name:

@lionello lionello closed this as not planned Won't fix, can't repro, duplicate, stale Oct 15, 2024
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

1 participant