(env, yml []byte)
| 91 | } |
| 92 | |
| 93 | func GetImagesFromDockerCompose(env, yml []byte) ([]string, error) { |
| 94 | envVars, err := loadEnvFile(env) |
| 95 | if err != nil { |
| 96 | return nil, fmt.Errorf("load env failed: %v", err) |
| 97 | } |
| 98 | |
| 99 | var compose ComposeProject |
| 100 | if err := yaml.Unmarshal(yml, &compose); err != nil { |
| 101 | return nil, fmt.Errorf("parse docker-compose file failed: %v", err) |
| 102 | } |
| 103 | |
| 104 | var images []string |
| 105 | for _, service := range compose.Services { |
| 106 | if service.Image != "" { |
| 107 | resolvedImage := replaceEnvVars(service.Image, envVars) |
| 108 | images = append(images, resolvedImage) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | return images, nil |
| 113 | } |
| 114 | |
| 115 | func loadEnvFile(env []byte) (map[string]string, error) { |
| 116 | envVars := make(map[string]string) |
nothing calls this directly
no test coverage detected