mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-10 21:47:13 +08:00
controller: rename ref to sessionID and set buildRef back to ref
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
@ -22,7 +22,7 @@ import (
|
||||
func NewLocalBuildxController(ctx context.Context, dockerCli command.Cli, logger progress.SubLogger) control.BuildxController {
|
||||
return &localController{
|
||||
dockerCli: dockerCli,
|
||||
ref: "local",
|
||||
sessionID: "local",
|
||||
processes: processes.NewManager(),
|
||||
}
|
||||
}
|
||||
@ -36,7 +36,7 @@ type buildConfig struct {
|
||||
|
||||
type localController struct {
|
||||
dockerCli command.Cli
|
||||
ref string
|
||||
sessionID string
|
||||
buildConfig buildConfig
|
||||
processes *processes.Manager
|
||||
|
||||
@ -57,30 +57,30 @@ func (b *localController) Build(ctx context.Context, options *controllerapi.Buil
|
||||
buildOptions: options,
|
||||
}
|
||||
if buildErr != nil {
|
||||
var buildRef string
|
||||
var ref string
|
||||
var ebr *desktop.ErrorWithBuildRef
|
||||
if errors.As(buildErr, &ebr) {
|
||||
buildRef = ebr.Ref
|
||||
ref = ebr.Ref
|
||||
}
|
||||
buildErr = controllererrors.WrapBuild(buildErr, b.ref, buildRef)
|
||||
buildErr = controllererrors.WrapBuild(buildErr, b.sessionID, ref)
|
||||
}
|
||||
}
|
||||
if buildErr != nil {
|
||||
return "", nil, nil, buildErr
|
||||
}
|
||||
return b.ref, resp, dockerfileMappings, nil
|
||||
return b.sessionID, resp, dockerfileMappings, nil
|
||||
}
|
||||
|
||||
func (b *localController) ListProcesses(ctx context.Context, ref string) (infos []*controllerapi.ProcessInfo, retErr error) {
|
||||
if ref != b.ref {
|
||||
return nil, errors.Errorf("unknown ref %q", ref)
|
||||
func (b *localController) ListProcesses(ctx context.Context, sessionID string) (infos []*controllerapi.ProcessInfo, retErr error) {
|
||||
if sessionID != b.sessionID {
|
||||
return nil, errors.Errorf("unknown session ID %q", sessionID)
|
||||
}
|
||||
return b.processes.ListProcesses(), nil
|
||||
}
|
||||
|
||||
func (b *localController) DisconnectProcess(ctx context.Context, ref, pid string) error {
|
||||
if ref != b.ref {
|
||||
return errors.Errorf("unknown ref %q", ref)
|
||||
func (b *localController) DisconnectProcess(ctx context.Context, sessionID, pid string) error {
|
||||
if sessionID != b.sessionID {
|
||||
return errors.Errorf("unknown session ID %q", sessionID)
|
||||
}
|
||||
return b.processes.DeleteProcess(pid)
|
||||
}
|
||||
@ -89,9 +89,9 @@ func (b *localController) cancelRunningProcesses() {
|
||||
b.processes.CancelRunningProcesses()
|
||||
}
|
||||
|
||||
func (b *localController) Invoke(ctx context.Context, ref string, pid string, cfg *controllerapi.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser) error {
|
||||
if ref != b.ref {
|
||||
return errors.Errorf("unknown ref %q", ref)
|
||||
func (b *localController) Invoke(ctx context.Context, sessionID string, pid string, cfg *controllerapi.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser) error {
|
||||
if sessionID != b.sessionID {
|
||||
return errors.Errorf("unknown session ID %q", sessionID)
|
||||
}
|
||||
|
||||
proc, ok := b.processes.Get(pid)
|
||||
@ -136,7 +136,7 @@ func (b *localController) Close() error {
|
||||
}
|
||||
|
||||
func (b *localController) List(ctx context.Context) (res []string, _ error) {
|
||||
return []string{b.ref}, nil
|
||||
return []string{b.sessionID}, nil
|
||||
}
|
||||
|
||||
func (b *localController) Disconnect(ctx context.Context, key string) error {
|
||||
@ -144,9 +144,9 @@ func (b *localController) Disconnect(ctx context.Context, key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *localController) Inspect(ctx context.Context, ref string) (*controllerapi.InspectResponse, error) {
|
||||
if ref != b.ref {
|
||||
return nil, errors.Errorf("unknown ref %q", ref)
|
||||
func (b *localController) Inspect(ctx context.Context, sessionID string) (*controllerapi.InspectResponse, error) {
|
||||
if sessionID != b.sessionID {
|
||||
return nil, errors.Errorf("unknown session ID %q", sessionID)
|
||||
}
|
||||
return &controllerapi.InspectResponse{Options: b.buildConfig.buildOptions}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user