Skip to content

Commit eb15c66

Browse files
committed
controller: rename ref to sessionID and set buildRef back to ref
Signed-off-by: CrazyMax <[email protected]>
1 parent 1060328 commit eb15c66

11 files changed

Lines changed: 537 additions & 530 deletions

File tree

controller/errdefs/build.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,21 @@ func (e *BuildError) ToProto() grpcerrors.TypedErrorProto {
2626
}
2727

2828
func (e *BuildError) PrintBuildDetails(w io.Writer) error {
29-
if e.BuildRef == "" {
29+
if e.Ref == "" {
3030
return nil
3131
}
3232
ebr := &desktop.ErrorWithBuildRef{
33-
Ref: e.BuildRef,
33+
Ref: e.Ref,
3434
Err: e.error,
3535
}
3636
return ebr.Print(w)
3737
}
3838

39-
func WrapBuild(err error, ref string, buildRef string) error {
39+
func WrapBuild(err error, sessionID string, ref string) error {
4040
if err == nil {
4141
return nil
4242
}
43-
return &BuildError{Build: &Build{Ref: ref, BuildRef: buildRef}, error: err}
43+
return &BuildError{Build: &Build{SessionID: sessionID, Ref: ref}, error: err}
4444
}
4545

4646
func (b *Build) WrapError(err error) error {

controller/errdefs/errdefs.pb.go

Lines changed: 14 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/errdefs/errdefs.proto

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ package docker.buildx.errdefs;
55
option go_package = "github.com/docker/buildx/controller/errdefs";
66

77
message Build {
8-
string Ref = 1;
9-
string BuildRef = 2;
8+
string SessionID = 1;
9+
string Ref = 2;
1010
}

controller/errdefs/errdefs_vtproto.pb.go

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controller/local/controller.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
func NewLocalBuildxController(ctx context.Context, dockerCli command.Cli, logger progress.SubLogger) control.BuildxController {
2323
return &localController{
2424
dockerCli: dockerCli,
25-
ref: "local",
25+
sessionID: "local",
2626
processes: processes.NewManager(),
2727
}
2828
}
@@ -36,7 +36,7 @@ type buildConfig struct {
3636

3737
type localController struct {
3838
dockerCli command.Cli
39-
ref string
39+
sessionID string
4040
buildConfig buildConfig
4141
processes *processes.Manager
4242

@@ -57,30 +57,30 @@ func (b *localController) Build(ctx context.Context, options *controllerapi.Buil
5757
buildOptions: options,
5858
}
5959
if buildErr != nil {
60-
var buildRef string
60+
var ref string
6161
var ebr *desktop.ErrorWithBuildRef
6262
if errors.As(buildErr, &ebr) {
63-
buildRef = ebr.Ref
63+
ref = ebr.Ref
6464
}
65-
buildErr = controllererrors.WrapBuild(buildErr, b.ref, buildRef)
65+
buildErr = controllererrors.WrapBuild(buildErr, b.sessionID, ref)
6666
}
6767
}
6868
if buildErr != nil {
6969
return "", nil, nil, buildErr
7070
}
71-
return b.ref, resp, dockerfileMappings, nil
71+
return b.sessionID, resp, dockerfileMappings, nil
7272
}
7373

74-
func (b *localController) ListProcesses(ctx context.Context, ref string) (infos []*controllerapi.ProcessInfo, retErr error) {
75-
if ref != b.ref {
76-
return nil, errors.Errorf("unknown ref %q", ref)
74+
func (b *localController) ListProcesses(ctx context.Context, sessionID string) (infos []*controllerapi.ProcessInfo, retErr error) {
75+
if sessionID != b.sessionID {
76+
return nil, errors.Errorf("unknown session ID %q", sessionID)
7777
}
7878
return b.processes.ListProcesses(), nil
7979
}
8080

81-
func (b *localController) DisconnectProcess(ctx context.Context, ref, pid string) error {
82-
if ref != b.ref {
83-
return errors.Errorf("unknown ref %q", ref)
81+
func (b *localController) DisconnectProcess(ctx context.Context, sessionID, pid string) error {
82+
if sessionID != b.sessionID {
83+
return errors.Errorf("unknown session ID %q", sessionID)
8484
}
8585
return b.processes.DeleteProcess(pid)
8686
}
@@ -89,9 +89,9 @@ func (b *localController) cancelRunningProcesses() {
8989
b.processes.CancelRunningProcesses()
9090
}
9191

92-
func (b *localController) Invoke(ctx context.Context, ref string, pid string, cfg *controllerapi.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser) error {
93-
if ref != b.ref {
94-
return errors.Errorf("unknown ref %q", ref)
92+
func (b *localController) Invoke(ctx context.Context, sessionID string, pid string, cfg *controllerapi.InvokeConfig, ioIn io.ReadCloser, ioOut io.WriteCloser, ioErr io.WriteCloser) error {
93+
if sessionID != b.sessionID {
94+
return errors.Errorf("unknown session ID %q", sessionID)
9595
}
9696

9797
proc, ok := b.processes.Get(pid)
@@ -136,17 +136,17 @@ func (b *localController) Close() error {
136136
}
137137

138138
func (b *localController) List(ctx context.Context) (res []string, _ error) {
139-
return []string{b.ref}, nil
139+
return []string{b.sessionID}, nil
140140
}
141141

142142
func (b *localController) Disconnect(ctx context.Context, key string) error {
143143
b.Close()
144144
return nil
145145
}
146146

147-
func (b *localController) Inspect(ctx context.Context, ref string) (*controllerapi.InspectResponse, error) {
148-
if ref != b.ref {
149-
return nil, errors.Errorf("unknown ref %q", ref)
147+
func (b *localController) Inspect(ctx context.Context, sessionID string) (*controllerapi.InspectResponse, error) {
148+
if sessionID != b.sessionID {
149+
return nil, errors.Errorf("unknown session ID %q", sessionID)
150150
}
151151
return &controllerapi.InspectResponse{Options: b.buildConfig.buildOptions}, nil
152152
}

0 commit comments

Comments
 (0)