config/network: Prepare for multiple networks

This commit futures proofs the code to allow for usage of more than one
docker network.
This commit is contained in:
Tom Wiesing 2023-03-13 10:10:37 +01:00
parent db1989a299
commit e969351f8e
No known key found for this signature in database
13 changed files with 40 additions and 28 deletions

View file

@ -135,18 +135,20 @@ func (si systemupdate) Run(context wisski_distillery.Context) (err error) {
}
}
// create the docker network
// create the docker networks
{
logging.LogMessage(context.Stderr, context.Context, "Configuring docker networks")
name := dis.Config.Docker.Network
id, existed, err := dis.Docker().CreateNetwork(context.Context, name)
if err != nil {
return errNetworkCreateFailed.Wrap(err)
}
if existed {
context.Printf("Network %s (id %s) already existed\n", name, id)
} else {
context.Printf("Network %s (id %s) created\n", name, id)
for _, name := range dis.Config.Docker.Networks() {
id, existed, err := dis.Docker().CreateNetwork(context.Context, name)
if err != nil {
return errNetworkCreateFailed.Wrap(err)
}
if existed {
context.Printf("Network %s (id %s) already existed\n", name, id)
} else {
context.Printf("Network %s (id %s) created\n", name, id)
}
}
}