(ctx context.Context, project *types.Project, service types.ServiceConfig, id string, mountType mountType)
| 44 | } |
| 45 | |
| 46 | func (s *composeService) injectFileReferences(ctx context.Context, project *types.Project, service types.ServiceConfig, id string, mountType mountType) error { |
| 47 | mounts, sources := s.getFilesAndMap(project, service, mountType) |
| 48 | |
| 49 | for _, mount := range mounts { |
| 50 | content, err := s.resolveFileContent(project, sources[mount.Source], mountType) |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | if content == "" { |
| 55 | continue |
| 56 | } |
| 57 | |
| 58 | if service.ReadOnly { |
| 59 | return fmt.Errorf("cannot create %s %q in read-only service %s: `file` is the sole supported option", mountType, sources[mount.Source].Name, service.Name) |
| 60 | } |
| 61 | |
| 62 | s.setDefaultTarget(&mount, mountType) |
| 63 | |
| 64 | if err := s.copyFileToContainer(ctx, id, content, mount); err != nil { |
| 65 | return err |
| 66 | } |
| 67 | } |
| 68 | return nil |
| 69 | } |
| 70 | |
| 71 | func (s *composeService) getFilesAndMap(project *types.Project, service types.ServiceConfig, mountType mountType) ([]types.FileReferenceConfig, map[string]types.FileObjectConfig) { |
| 72 | var files []types.FileReferenceConfig |
no test coverage detected