This repository has been archived on 2023-05-06. You can view files and clone it, but cannot push or open issues or pull requests.
helix/internal/docker/network.go

36 lines
822 B
Go
Raw Normal View History

2021-06-26 01:26:06 +01:00
package docker
import (
"fmt"
"github.com/pulumi/pulumi-docker/sdk/v3/go/docker"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
// DockerNetworkConfig is the configuration
// used for creating a Docker network.
type DockerNetworkConfig struct {
Name pulumi.StringInput
Subnet pulumi.StringInput
Driver pulumi.StringInput
}
// CreateNetwork creates the forge platform's Docker network.
func CreateNetwork(ctx *pulumi.Context, c DockerNetworkConfig, label string) error {
args := docker.NetworkArgs{
Name: c.Name,
IpamDriver: c.Driver,
IpamConfigs: docker.NetworkIpamConfigArray{
docker.NetworkIpamConfigArgs{
Subnet: c.Subnet,
},
},
}
_, err := docker.NewNetwork(ctx, label, &args)
if err != nil {
return fmt.Errorf("unable to create the docker network, %w", err)
}
return nil
}