6a876c4f99
Fix the build failure in https://gitea.com/gitea/act_runner/actions/runs/278/jobs/0 Reviewed-on: https://gitea.com/gitea/act/pulls/44 Reviewed-by: Jason Song <i@wolfogre.com> Co-authored-by: Zettat123 <zettat123@gmail.com> Co-committed-by: Zettat123 <zettat123@gmail.com>
40 lines
748 B
Go
40 lines
748 B
Go
//go:build !(WITHOUT_DOCKER || !(linux || darwin || windows))
|
|
|
|
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)
|
|
}
|
|
}
|