Dan Anglin
99cf3dca17
Here we rename the containers stack to the docker stack. The docker_network stack is now deleted and the docker network is now managed in the docker stack.
46 lines
1,013 B
Go
46 lines
1,013 B
Go
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
|
|
}
|
|
|
|
type DockerNetworkResults struct {
|
|
Name pulumi.StringOutput
|
|
}
|
|
|
|
// CreateNetwork creates the forge platform's Docker network.
|
|
func CreateNetwork(ctx *pulumi.Context, c DockerNetworkConfig) (DockerNetworkResults, error) {
|
|
var result DockerNetworkResults
|
|
|
|
args := docker.NetworkArgs{
|
|
Name: c.Name,
|
|
IpamDriver: c.Driver,
|
|
IpamConfigs: docker.NetworkIpamConfigArray{
|
|
docker.NetworkIpamConfigArgs{
|
|
Subnet: c.Subnet,
|
|
},
|
|
},
|
|
}
|
|
|
|
n, err := docker.NewNetwork(ctx, "docker_network", &args)
|
|
if err != nil {
|
|
return result, fmt.Errorf("unable to create the docker network...\n%w", err)
|
|
}
|
|
|
|
result = DockerNetworkResults{
|
|
Name: n.Name,
|
|
}
|
|
|
|
return result, nil
|
|
}
|