9db5480aad
Implements one part of forgejo/runner#119. The other part is a corresponding PR in forgejo/runner: forgejo/runner#120. Reviewed-on: https://code.forgejo.org/forgejo/act/pulls/24 Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org> Co-authored-by: s3lph <codeberg@s3lph.me> Co-committed-by: s3lph <codeberg@s3lph.me>
37 lines
719 B
Go
37 lines
719 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, config *types.NetworkCreate) common.Executor {
|
|
return func(ctx context.Context) error {
|
|
cli, err := GetDockerClient(ctx)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
_, err = cli.NetworkCreate(ctx, name, *config)
|
|
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)
|
|
}
|
|
}
|