LoadComposeFileWithArch is a helper method for loading a docker-compose file
(wd string, file string, archGetter ArchGetter)
| 397 | |
| 398 | // LoadComposeFileWithArch is a helper method for loading a docker-compose file |
| 399 | func LoadComposeFileWithArch(wd string, file string, archGetter ArchGetter) (*compose.Config, error) { |
| 400 | |
| 401 | file = path.Join(wd, file) |
| 402 | b, err := os.ReadFile(file) |
| 403 | if err != nil { |
| 404 | return nil, err |
| 405 | } |
| 406 | |
| 407 | config, err := loader.ParseYAML(b) |
| 408 | if err != nil { |
| 409 | return nil, err |
| 410 | } |
| 411 | |
| 412 | archSuffix, err := GetArchSuffix(archGetter) |
| 413 | if err != nil { |
| 414 | return nil, err |
| 415 | } |
| 416 | |
| 417 | var files []compose.ConfigFile |
| 418 | files = append(files, compose.ConfigFile{Filename: file, Config: config}) |
| 419 | |
| 420 | return loader.Load(compose.ConfigDetails{ |
| 421 | WorkingDir: wd, |
| 422 | ConfigFiles: files, |
| 423 | Environment: map[string]string{ |
| 424 | "ARCH_SUFFIX": archSuffix, |
| 425 | }, |
| 426 | }) |
| 427 | } |
| 428 | |
| 429 | func sortedEnvKeys(env map[string]*string) (keys []string) { |
| 430 | for k := range env { |