(volumes []container.MountPoint)
| 168 | } |
| 169 | |
| 170 | func (s *composeService) toComposeVolumes(volumes []container.MountPoint) (map[string]types.VolumeConfig, |
| 171 | []types.ServiceVolumeConfig, map[string]types.SecretConfig, []types.ServiceSecretConfig, |
| 172 | ) { |
| 173 | volumeConfigs := make(map[string]types.VolumeConfig) |
| 174 | secretConfigs := make(map[string]types.SecretConfig) |
| 175 | var serviceVolumeConfigs []types.ServiceVolumeConfig |
| 176 | var serviceSecretConfigs []types.ServiceSecretConfig |
| 177 | |
| 178 | for _, volume := range volumes { |
| 179 | serviceVC := types.ServiceVolumeConfig{ |
| 180 | Type: string(volume.Type), |
| 181 | Source: volume.Source, |
| 182 | Target: volume.Destination, |
| 183 | ReadOnly: !volume.RW, |
| 184 | } |
| 185 | switch volume.Type { |
| 186 | case mount.TypeVolume: |
| 187 | serviceVC.Source = volume.Name |
| 188 | vol := types.VolumeConfig{} |
| 189 | if volume.Driver != "local" { |
| 190 | vol.Driver = volume.Driver |
| 191 | vol.Name = volume.Name |
| 192 | } |
| 193 | volumeConfigs[volume.Name] = vol |
| 194 | serviceVolumeConfigs = append(serviceVolumeConfigs, serviceVC) |
| 195 | case mount.TypeBind: |
| 196 | if strings.HasPrefix(volume.Destination, "/run/secrets") { |
| 197 | destination := strings.Split(volume.Destination, "/") |
| 198 | secret := types.SecretConfig{ |
| 199 | Name: destination[len(destination)-1], |
| 200 | File: strings.TrimPrefix(volume.Source, "/host_mnt"), |
| 201 | } |
| 202 | secretConfigs[secret.Name] = secret |
| 203 | serviceSecretConfigs = append(serviceSecretConfigs, types.ServiceSecretConfig{ |
| 204 | Source: secret.Name, |
| 205 | Target: volume.Destination, |
| 206 | }) |
| 207 | } else { |
| 208 | serviceVolumeConfigs = append(serviceVolumeConfigs, serviceVC) |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | return volumeConfigs, serviceVolumeConfigs, secretConfigs, serviceSecretConfigs |
| 213 | } |
| 214 | |
| 215 | func (s *composeService) toComposeNetwork(networks map[string]*network.EndpointSettings) (map[string]types.NetworkConfig, map[string]*types.ServiceNetworkConfig) { |
| 216 | networkConfigs := make(map[string]types.NetworkConfig) |
no outgoing calls
no test coverage detected