MCPcopy Create free account
hub / github.com/openfaas/faasd / LoadComposeFileWithArch

Function LoadComposeFileWithArch

pkg/supervisor.go:399–427  ·  view source on GitHub ↗

LoadComposeFileWithArch is a helper method for loading a docker-compose file

(wd string, file string, archGetter ArchGetter)

Source from the content-addressed store, hash-verified

397
398// LoadComposeFileWithArch is a helper method for loading a docker-compose file
399func 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
429func sortedEnvKeys(env map[string]*string) (keys []string) {
430 for k := range env {

Callers 3

Test_ParseComposeFunction · 0.85
LoadComposeFileFunction · 0.85

Calls 1

GetArchSuffixFunction · 0.85

Tested by 2

Test_ParseComposeFunction · 0.68