(ctx context.Context, project *types.Project, extFiles map[string]string)
| 198 | } |
| 199 | |
| 200 | func processExtends(ctx context.Context, project *types.Project, extFiles map[string]string) ([]v1.Descriptor, error) { |
| 201 | var layers []v1.Descriptor |
| 202 | moreExtFiles := map[string]string{} |
| 203 | envFiles := map[string]string{} |
| 204 | for xf, hash := range extFiles { |
| 205 | data, err := processFile(ctx, xf, project, moreExtFiles, envFiles) |
| 206 | if err != nil { |
| 207 | return nil, err |
| 208 | } |
| 209 | |
| 210 | layerDescriptor := oci.DescriptorForComposeFile(hash, data) |
| 211 | layerDescriptor.Annotations["com.docker.compose.extends"] = "true" |
| 212 | layers = append(layers, layerDescriptor) |
| 213 | } |
| 214 | for f, hash := range moreExtFiles { |
| 215 | if _, ok := extFiles[f]; ok { |
| 216 | delete(moreExtFiles, f) |
| 217 | } |
| 218 | extFiles[f] = hash |
| 219 | } |
| 220 | if len(moreExtFiles) > 0 { |
| 221 | extLayers, err := processExtends(ctx, project, moreExtFiles) |
| 222 | if err != nil { |
| 223 | return nil, err |
| 224 | } |
| 225 | layers = append(layers, extLayers...) |
| 226 | } |
| 227 | return layers, nil |
| 228 | } |
| 229 | |
| 230 | func processFile(ctx context.Context, file string, project *types.Project, extFiles map[string]string, envFiles map[string]string) ([]byte, error) { |
| 231 | f, err := os.ReadFile(file) |
no test coverage detected