(p types.Project, s types.ServiceConfig)
| 1081 | } |
| 1082 | |
| 1083 | func buildContainerConfigMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) { |
| 1084 | mounts := map[string]mount.Mount{} |
| 1085 | |
| 1086 | configsBaseDir := "/" |
| 1087 | for _, config := range s.Configs { |
| 1088 | target := config.Target |
| 1089 | if config.Target == "" { |
| 1090 | target = configsBaseDir + config.Source |
| 1091 | } else if !isAbsTarget(config.Target) { |
| 1092 | target = configsBaseDir + config.Target |
| 1093 | } |
| 1094 | |
| 1095 | definedConfig := p.Configs[config.Source] |
| 1096 | if definedConfig.External { |
| 1097 | return nil, fmt.Errorf("unsupported external config %s", definedConfig.Name) |
| 1098 | } |
| 1099 | |
| 1100 | if definedConfig.Driver != "" { |
| 1101 | return nil, errors.New("Docker Compose does not support configs.*.driver") //nolint:staticcheck |
| 1102 | } |
| 1103 | if definedConfig.TemplateDriver != "" { |
| 1104 | return nil, errors.New("Docker Compose does not support configs.*.template_driver") //nolint:staticcheck |
| 1105 | } |
| 1106 | |
| 1107 | if definedConfig.Environment != "" || definedConfig.Content != "" { |
| 1108 | continue |
| 1109 | } |
| 1110 | |
| 1111 | if config.UID != "" || config.GID != "" || config.Mode != nil { |
| 1112 | logrus.Warn("config `uid`, `gid` and `mode` are not supported, they will be ignored") |
| 1113 | } |
| 1114 | |
| 1115 | bindMount, err := buildMount(p, types.ServiceVolumeConfig{ |
| 1116 | Type: types.VolumeTypeBind, |
| 1117 | Source: definedConfig.File, |
| 1118 | Target: target, |
| 1119 | ReadOnly: true, |
| 1120 | }) |
| 1121 | if err != nil { |
| 1122 | return nil, err |
| 1123 | } |
| 1124 | mounts[target] = bindMount |
| 1125 | } |
| 1126 | values := make([]mount.Mount, 0, len(mounts)) |
| 1127 | for _, v := range mounts { |
| 1128 | values = append(values, v) |
| 1129 | } |
| 1130 | return values, nil |
| 1131 | } |
| 1132 | |
| 1133 | func buildContainerSecretMounts(p types.Project, s types.ServiceConfig) ([]mount.Mount, error) { |
| 1134 | mounts := map[string]mount.Mount{} |
no test coverage detected