Skip to content

Commit

Permalink
refactor: remove unused progress type
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Goller <[email protected]>
  • Loading branch information
goller committed Oct 2, 2023
1 parent 9f2ed61 commit b557600
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 43 deletions.
2 changes: 1 addition & 1 deletion pkg/buildx/commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func RunBake(dockerCli command.Cli, in BakeOptions, validator BakeValidator) (er
return err
}

printer, finish, err := depotprogress.NewProgress(ctx2, in.buildID, in.token, depotprogress.NewProgressMode(in.progress), buildxprinter)
printer, finish, err := depotprogress.NewProgress(ctx2, in.buildID, in.token, buildxprinter)
if err != nil {
cancel()
return err
Expand Down
2 changes: 1 addition & 1 deletion pkg/buildx/commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ func buildTargets(ctx context.Context, dockerCli command.Cli, nodes []builder.No
return nil, nil, err
}

printer, finish, err := depotprogress.NewProgress(ctx2, depotOpts.buildID, depotOpts.token, depotprogress.NewProgressMode(progressMode), buildxprinter)
printer, finish, err := depotprogress.NewProgress(ctx2, depotOpts.buildID, depotOpts.token, buildxprinter)
if err != nil {
cancel()
return nil, nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/buildctl/dial-stdio.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func run() error {
return
}

state.Reporter, finishStatus, _ = progress.NewProgress(ctx2, build.ID, build.Token, progress.Quiet, buildxprinter)
state.Reporter, finishStatus, _ = progress.NewProgress(ctx2, build.ID, build.Token, buildxprinter)
state.Reporter.AddListener(listener)

state.SummaryURL = build.BuildURL
Expand Down
41 changes: 1 addition & 40 deletions pkg/progress/progress.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,14 @@ type Progress struct {
p *progress.Printer
}

type ProgressMode int

const (
Auto ProgressMode = iota
TTY
Plain
Quiet
)

type FinishFn func()
type Listener func(s *client.SolveStatus)

// NewProgress creates a new progress writer that sends build timings to the server.
// Use the ctx to cancel the long running go routine.
// Make sure to run FinishFn to flush remaining build timings to the server _AFTER_ ctx has been canceled.
// NOTE: this means that you need to defer the FinishFn before deferring the cancel.
func NewProgress(ctx context.Context, buildID, token string, mode ProgressMode, p *progress.Printer) (*Progress, FinishFn, error) {
func NewProgress(ctx context.Context, buildID, token string, p *progress.Printer) (*Progress, FinishFn, error) {
// Buffer up to 1024 vertex slices before blocking the build.
const channelBufferSize = 1024

Expand Down Expand Up @@ -475,33 +466,3 @@ type Instruction struct {
Step int
Total int
}

func (p ProgressMode) String() string {
switch p {
case Auto:
return "auto"
case TTY:
return "tty"
case Plain:
return "plain"
case Quiet:
return "quiet"
default:
return "auth"
}
}

func NewProgressMode(s string) ProgressMode {
switch s {
case "auto":
return Auto
case "tty":
return TTY
case "plain":
return Plain
case "quiet":
return Quiet
default:
return Auto
}
}

0 comments on commit b557600

Please sign in to comment.