2023-04-19 03:19:38 -05:00
|
|
|
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows))
|
|
|
|
|
2023-04-18 22:23:28 -05:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/nektos/act/pkg/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
func NewDockerNetworkCreateExecutor(name string) common.Executor {
|
|
|
|
return func(ctx context.Context) error {
|
|
|
|
cli, err := GetDockerClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
_, err = cli.NetworkCreate(ctx, name, types.NetworkCreate{
|
|
|
|
Driver: "bridge",
|
|
|
|
Scope: "local",
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDockerNetworkRemoveExecutor(name string) common.Executor {
|
|
|
|
return func(ctx context.Context) error {
|
|
|
|
cli, err := GetDockerClient(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return cli.NetworkRemove(ctx, name)
|
|
|
|
}
|
|
|
|
}
|