mirror of
				https://gitea.com/Lydanne/buildx.git
				synced 2025-11-04 18:13:42 +08:00 
			
		
		
		
	Removes gogo/protobuf from buildx and updates to a version of moby/buildkit where gogo is removed. This also changes how the proto files are generated. This is because newer versions of protobuf are more strict about name conflicts. If two files have the same name (even if they are relative paths) and are used in different protoc commands, they'll conflict in the registry. Since protobuf file generation doesn't work very well with `paths=source_relative`, this removes the `go:generate` expression and just relies on the dockerfile to perform the generation. Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package commands
 | 
						|
 | 
						|
import (
 | 
						|
	"context"
 | 
						|
	"fmt"
 | 
						|
	"io"
 | 
						|
 | 
						|
	controllerapi "github.com/docker/buildx/controller/pb"
 | 
						|
	"github.com/docker/buildx/monitor/types"
 | 
						|
	"github.com/pkg/errors"
 | 
						|
)
 | 
						|
 | 
						|
type ExecCmd struct {
 | 
						|
	m types.Monitor
 | 
						|
 | 
						|
	invokeConfig *controllerapi.InvokeConfig
 | 
						|
	stdout       io.WriteCloser
 | 
						|
}
 | 
						|
 | 
						|
func NewExecCmd(m types.Monitor, invokeConfig *controllerapi.InvokeConfig, stdout io.WriteCloser) types.Command {
 | 
						|
	return &ExecCmd{m, invokeConfig, stdout}
 | 
						|
}
 | 
						|
 | 
						|
func (cm *ExecCmd) Info() types.CommandInfo {
 | 
						|
	return types.CommandInfo{
 | 
						|
		Name:        "exec",
 | 
						|
		HelpMessage: "execute a process in the interactive container",
 | 
						|
		HelpMessageLong: `
 | 
						|
Usage:
 | 
						|
  exec COMMAND [ARG...]
 | 
						|
 | 
						|
COMMAND and ARG... will be executed in the container.
 | 
						|
`,
 | 
						|
	}
 | 
						|
}
 | 
						|
 | 
						|
func (cm *ExecCmd) Exec(ctx context.Context, args []string) error {
 | 
						|
	if ref := cm.m.AttachedSessionID(); ref == "" {
 | 
						|
		return errors.Errorf("no attaching session")
 | 
						|
	}
 | 
						|
	if len(args) < 2 {
 | 
						|
		return errors.Errorf("command must be passed")
 | 
						|
	}
 | 
						|
	cfg := &controllerapi.InvokeConfig{
 | 
						|
		Entrypoint: []string{args[1]},
 | 
						|
		Cmd:        args[2:],
 | 
						|
		NoCmd:      false,
 | 
						|
		// TODO: support other options as well via flags
 | 
						|
		Env:  cm.invokeConfig.Env,
 | 
						|
		User: cm.invokeConfig.User,
 | 
						|
		Cwd:  cm.invokeConfig.Cwd,
 | 
						|
		Tty:  true,
 | 
						|
	}
 | 
						|
	pid := cm.m.Exec(ctx, cfg)
 | 
						|
	fmt.Fprintf(cm.stdout, "Process %q started. Press Ctrl-a-c to switch to that process.\n", pid)
 | 
						|
	return nil
 | 
						|
}
 |