MCPcopy
hub / github.com/docker/compose / processExtends

Function processExtends

pkg/compose/publish.go:200–228  ·  view source on GitHub ↗
(ctx context.Context, project *types.Project, extFiles map[string]string)

Source from the content-addressed store, hash-verified

198}
199
200func 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
230func 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)

Callers 1

createLayersMethod · 0.85

Calls 2

DescriptorForComposeFileFunction · 0.92
processFileFunction · 0.85

Tested by

no test coverage detected