Skip to content

Commit 810dc0e

Browse files
committed
sidecar: disable networking if no network dependencies are present
The newer version of Compose used with Mutagen Compose v0.18.0 doesn't like an empty network map and tries to connect the sidecar container to a network with an empty name if there are no networks present in the service configuration. To fix this, we'll disable networking for the sidecar if not needed. Signed-off-by: Jacob Howard <[email protected]>
1 parent 3c59b77 commit 810dc0e

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

pkg/mutagen/liaison.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,13 @@ func (l *Liaison) processProject(project *types.Project) error {
464464
}
465465
composeVersion := strings.TrimPrefix(versions.Compose, "v")
466466

467+
// If there are no network dependencies, then disable networking.
468+
var networkMode string
469+
if len(networkDependencies) == 0 {
470+
networkMode = "none"
471+
networkDependencies = nil
472+
}
473+
467474
// Create and record the Mutagen sidecar service definition. The service
468475
// configuration we generate here needs to match (as closely as possible)
469476
// those generated by projectOptions.toProject in Compose. In particular,
@@ -476,9 +483,10 @@ func (l *Liaison) processProject(project *types.Project) error {
476483
sidecarRoleLabelKey: sidecarRoleLabelValue,
477484
sidecarVersionLabelKey: mutagen.Version,
478485
},
479-
Networks: networkDependencies,
480-
Volumes: serviceVolumeDependencies,
481-
CapAdd: capabilities,
486+
NetworkMode: networkMode,
487+
Networks: networkDependencies,
488+
Volumes: serviceVolumeDependencies,
489+
CapAdd: capabilities,
482490
CustomLabels: types.Labels{
483491
api.ProjectLabel: project.Name,
484492
api.ServiceLabel: sidecarServiceName,

0 commit comments

Comments
 (0)