mirror of https://github.com/docker/buildx.git
lint: gopls fixes
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
parent
ec98985b4e
commit
b30566438b
|
@ -37,7 +37,7 @@ func NewContainer(ctx context.Context, resultCtx *ResultHandle, cfg *controllera
|
||||||
cancel()
|
cancel()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
containerCfg, err := resultCtx.getContainerConfig(ctx, c, cfg)
|
containerCfg, err := resultCtx.getContainerConfig(cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,10 +292,10 @@ func (r *ResultHandle) build(buildFunc gateway.BuildFunc) (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *ResultHandle) getContainerConfig(ctx context.Context, c gateway.Client, cfg *controllerapi.InvokeConfig) (containerCfg gateway.NewContainerRequest, _ error) {
|
func (r *ResultHandle) getContainerConfig(cfg *controllerapi.InvokeConfig) (containerCfg gateway.NewContainerRequest, _ error) {
|
||||||
if r.res != nil && r.solveErr == nil {
|
if r.res != nil && r.solveErr == nil {
|
||||||
logrus.Debugf("creating container from successful build")
|
logrus.Debugf("creating container from successful build")
|
||||||
ccfg, err := containerConfigFromResult(ctx, r.res, c, *cfg)
|
ccfg, err := containerConfigFromResult(r.res, *cfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return containerCfg, err
|
return containerCfg, err
|
||||||
}
|
}
|
||||||
|
@ -327,7 +327,7 @@ func (r *ResultHandle) getProcessConfig(cfg *controllerapi.InvokeConfig, stdin i
|
||||||
return processCfg, nil
|
return processCfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func containerConfigFromResult(ctx context.Context, res *gateway.Result, c gateway.Client, cfg controllerapi.InvokeConfig) (*gateway.NewContainerRequest, error) {
|
func containerConfigFromResult(res *gateway.Result, cfg controllerapi.InvokeConfig) (*gateway.NewContainerRequest, error) {
|
||||||
if cfg.Initial {
|
if cfg.Initial {
|
||||||
return nil, errors.Errorf("starting from the container from the initial state of the step is supported only on the failed steps")
|
return nil, errors.Errorf("starting from the container from the initial state of the step is supported only on the failed steps")
|
||||||
}
|
}
|
||||||
|
|
|
@ -340,7 +340,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions)
|
||||||
if confutil.IsExperimental() {
|
if confutil.IsExperimental() {
|
||||||
resp, retErr = runControllerBuild(ctx, dockerCli, opts, options, printer)
|
resp, retErr = runControllerBuild(ctx, dockerCli, opts, options, printer)
|
||||||
} else {
|
} else {
|
||||||
resp, retErr = runBasicBuild(ctx, dockerCli, opts, options, printer)
|
resp, retErr = runBasicBuild(ctx, dockerCli, opts, printer)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := printer.Wait(); retErr == nil {
|
if err := printer.Wait(); retErr == nil {
|
||||||
|
@ -387,7 +387,7 @@ func getImageID(resp map[string]string) string {
|
||||||
return dgst
|
return dgst
|
||||||
}
|
}
|
||||||
|
|
||||||
func runBasicBuild(ctx context.Context, dockerCli command.Cli, opts *controllerapi.BuildOptions, options buildOptions, printer *progress.Printer) (*client.SolveResponse, error) {
|
func runBasicBuild(ctx context.Context, dockerCli command.Cli, opts *controllerapi.BuildOptions, printer *progress.Printer) (*client.SolveResponse, error) {
|
||||||
resp, res, err := cbuild.RunBuild(ctx, dockerCli, *opts, dockerCli.In(), printer, false)
|
resp, res, err := cbuild.RunBuild(ctx, dockerCli, *opts, dockerCli.In(), printer, false)
|
||||||
if res != nil {
|
if res != nil {
|
||||||
res.Done()
|
res.Done()
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
type installOptions struct {
|
type installOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runInstall(dockerCli command.Cli, in installOptions) error {
|
func runInstall(_ command.Cli, _ installOptions) error {
|
||||||
dir := config.Dir()
|
dir := config.Dir()
|
||||||
if err := os.MkdirAll(dir, 0755); err != nil {
|
if err := os.MkdirAll(dir, 0755); err != nil {
|
||||||
return errors.Wrap(err, "could not create docker config")
|
return errors.Wrap(err, "could not create docker config")
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
type uninstallOptions struct {
|
type uninstallOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func runUninstall(dockerCli command.Cli, in uninstallOptions) error {
|
func runUninstall(_ command.Cli, _ uninstallOptions) error {
|
||||||
dir := config.Dir()
|
dir := config.Dir()
|
||||||
cfg, err := config.Load(dir)
|
cfg, err := config.Load(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
func runVersion(dockerCli command.Cli) error {
|
func runVersion(_ command.Cli) error {
|
||||||
fmt.Println(version.Package, version.Version, version.Revision)
|
fmt.Println(version.Package, version.Version, version.Revision)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -189,7 +189,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
resp, res, err := buildTargets(ctx, dockerCli, b.NodeGroup, nodes, map[string]build.Options{defaultTargetName: opts}, progress, generateResult)
|
resp, res, err := buildTargets(ctx, dockerCli, nodes, map[string]build.Options{defaultTargetName: opts}, progress, generateResult)
|
||||||
err = wrapBuildError(err, false)
|
err = wrapBuildError(err, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// NOTE: buildTargets can return *build.ResultHandle even on error.
|
// NOTE: buildTargets can return *build.ResultHandle even on error.
|
||||||
|
@ -203,7 +203,7 @@ func RunBuild(ctx context.Context, dockerCli command.Cli, in controllerapi.Build
|
||||||
// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultHandle,
|
// NOTE: When an error happens during the build and this function acquires the debuggable *build.ResultHandle,
|
||||||
// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
|
// this function returns it in addition to the error (i.e. it does "return nil, res, err"). The caller can
|
||||||
// inspect the result and debug the cause of that error.
|
// inspect the result and debug the cause of that error.
|
||||||
func buildTargets(ctx context.Context, dockerCli command.Cli, ng *store.NodeGroup, nodes []builder.Node, opts map[string]build.Options, progress progress.Writer, generateResult bool) (*client.SolveResponse, *build.ResultHandle, error) {
|
func buildTargets(ctx context.Context, dockerCli command.Cli, nodes []builder.Node, opts map[string]build.Options, progress progress.Writer, generateResult bool) (*client.SolveResponse, *build.ResultHandle, error) {
|
||||||
var res *build.ResultHandle
|
var res *build.ResultHandle
|
||||||
var resp map[string]*client.SolveResponse
|
var resp map[string]*client.SolveResponse
|
||||||
var err error
|
var err error
|
||||||
|
|
|
@ -77,7 +77,7 @@ func (d *Driver) Bootstrap(ctx context.Context, l progress.Logger) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return sub.Wrap("starting container "+d.Name, func() error {
|
return sub.Wrap("starting container "+d.Name, func() error {
|
||||||
if err := d.start(ctx, sub); err != nil {
|
if err := d.start(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return d.wait(ctx, sub)
|
return d.wait(ctx, sub)
|
||||||
|
@ -188,7 +188,7 @@ func (d *Driver) create(ctx context.Context, l progress.SubLogger) error {
|
||||||
if err := d.copyToContainer(ctx, d.InitConfig.Files); err != nil {
|
if err := d.copyToContainer(ctx, d.InitConfig.Files); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := d.start(ctx, l); err != nil {
|
if err := d.start(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ func (d *Driver) run(ctx context.Context, cmd []string, stdout, stderr io.Writer
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Driver) start(ctx context.Context, l progress.SubLogger) error {
|
func (d *Driver) start(ctx context.Context) error {
|
||||||
return d.DockerAPI.ContainerStart(ctx, d.Name, container.StartOptions{})
|
return d.DockerAPI.ContainerStart(ctx, d.Name, container.StartOptions{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
|
|
||||||
func gitPath(wd string) (string, error) {
|
func gitPath(_ string) (string, error) {
|
||||||
return exec.LookPath("git.exe")
|
return exec.LookPath("git.exe")
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,14 +120,14 @@ func TestMuxIO(t *testing.T) {
|
||||||
|
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
inBuf, end, in := newTestIn(t)
|
inBuf, end, in := newTestIn()
|
||||||
var outBufs []*outBuf
|
var outBufs []*outBuf
|
||||||
var outs []MuxOut
|
var outs []MuxOut
|
||||||
if tt.outputsNum != len(tt.wants) {
|
if tt.outputsNum != len(tt.wants) {
|
||||||
t.Fatalf("wants != outputsNum")
|
t.Fatalf("wants != outputsNum")
|
||||||
}
|
}
|
||||||
for i := 0; i < tt.outputsNum; i++ {
|
for i := 0; i < tt.outputsNum; i++ {
|
||||||
outBuf, out := newTestOut(t, i)
|
outBuf, out := newTestOut(i)
|
||||||
outBufs = append(outBufs, outBuf)
|
outBufs = append(outBufs, outBuf)
|
||||||
outs = append(outs, MuxOut{out, nil, nil})
|
outs = append(outs, MuxOut{out, nil, nil})
|
||||||
}
|
}
|
||||||
|
@ -223,7 +223,7 @@ type inBuf struct {
|
||||||
doneCh chan struct{}
|
doneCh chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestIn(t *testing.T) (*inBuf, Out, In) {
|
func newTestIn() (*inBuf, Out, In) {
|
||||||
ti := &inBuf{
|
ti := &inBuf{
|
||||||
doneCh: make(chan struct{}),
|
doneCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ type outBuf struct {
|
||||||
doneCh chan struct{}
|
doneCh chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func newTestOut(t *testing.T, idx int) (*outBuf, Out) {
|
func newTestOut(idx int) (*outBuf, Out) {
|
||||||
to := &outBuf{
|
to := &outBuf{
|
||||||
idx: idx,
|
idx: idx,
|
||||||
doneCh: make(chan struct{}),
|
doneCh: make(chan struct{}),
|
||||||
|
@ -285,7 +285,7 @@ func newTestOut(t *testing.T, idx int) (*outBuf, Out) {
|
||||||
errW.CloseWithError(err)
|
errW.CloseWithError(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
to.stdin = string(buf.Bytes())
|
to.stdin = buf.String()
|
||||||
outW.Close()
|
outW.Close()
|
||||||
errW.Close()
|
errW.Close()
|
||||||
close(to.doneCh)
|
close(to.doneCh)
|
||||||
|
|
Loading…
Reference in New Issue