github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/engine/engine.go (about) 1 package engine 2 3 import ( 4 "context" 5 "io" 6 "time" 7 8 enginetypes "github.com/projecteru2/core/engine/types" 9 resourcetypes "github.com/projecteru2/core/resource/types" 10 coresource "github.com/projecteru2/core/source" 11 ) 12 13 // API define a remote engine 14 type API interface { 15 Info(ctx context.Context) (*enginetypes.Info, error) 16 Ping(ctx context.Context) error 17 CloseConn() error 18 19 Execute(ctx context.Context, ID string, config *enginetypes.ExecConfig) (execID string, stdout, stderr io.ReadCloser, stdin io.WriteCloser, err error) 20 ExecResize(ctx context.Context, execID string, height, width uint) (err error) 21 ExecExitCode(ctx context.Context, ID, execID string) (int, error) 22 23 NetworkConnect(ctx context.Context, network, target, ipv4, ipv6 string) ([]string, error) 24 NetworkDisconnect(ctx context.Context, network, target string, force bool) error 25 NetworkList(ctx context.Context, drivers []string) ([]*enginetypes.Network, error) 26 27 ImageList(ctx context.Context, image string) ([]*enginetypes.Image, error) 28 ImageRemove(ctx context.Context, image string, force, prune bool) ([]string, error) 29 ImagesPrune(ctx context.Context) error 30 ImagePull(ctx context.Context, ref string, all bool) (io.ReadCloser, error) 31 ImagePush(ctx context.Context, ref string) (io.ReadCloser, error) 32 ImageBuild(ctx context.Context, input io.Reader, refs []string, platform string) (io.ReadCloser, error) 33 ImageBuildCachePrune(ctx context.Context, all bool) (uint64, error) 34 ImageLocalDigests(ctx context.Context, image string) ([]string, error) 35 ImageRemoteDigest(ctx context.Context, image string) (string, error) 36 ImageBuildFromExist(ctx context.Context, ID string, refs []string, user string) (string, error) 37 38 BuildRefs(ctx context.Context, opts *enginetypes.BuildRefOptions) []string 39 BuildContent(ctx context.Context, scm coresource.Source, opts *enginetypes.BuildContentOptions) (string, io.Reader, error) 40 41 VirtualizationCreate(ctx context.Context, opts *enginetypes.VirtualizationCreateOptions) (*enginetypes.VirtualizationCreated, error) 42 VirtualizationCopyTo(ctx context.Context, ID, target string, content []byte, uid, gid int, mode int64) error 43 VirtualizationCopyChunkTo(ctx context.Context, ID, target string, size int64, content io.Reader, uid, gid int, mode int64) error 44 VirtualizationStart(ctx context.Context, ID string) error 45 VirtualizationStop(ctx context.Context, ID string, gracefulTimeout time.Duration) error 46 VirtualizationRemove(ctx context.Context, ID string, volumes, force bool) error 47 VirtualizationSuspend(ctx context.Context, ID string) error 48 VirtualizationResume(ctx context.Context, ID string) error 49 VirtualizationInspect(ctx context.Context, ID string) (*enginetypes.VirtualizationInfo, error) 50 VirtualizationLogs(ctx context.Context, opts *enginetypes.VirtualizationLogStreamOptions) (stdout, stderr io.ReadCloser, err error) 51 VirtualizationAttach(ctx context.Context, ID string, stream, openStdin bool) (stdout, stderr io.ReadCloser, stdin io.WriteCloser, err error) 52 VirtualizationResize(ctx context.Context, ID string, height, width uint) error 53 VirtualizationWait(ctx context.Context, ID, state string) (*enginetypes.VirtualizationWaitResult, error) 54 VirtualizationUpdateResource(ctx context.Context, ID string, params resourcetypes.Resources) error 55 VirtualizationCopyFrom(ctx context.Context, ID, path string) (content []byte, uid, gid int, mode int64, _ error) 56 57 RawEngine(ctx context.Context, opts *enginetypes.RawEngineOptions) (*enginetypes.RawEngineResult, error) 58 }