mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
monitor: extend monitor interface from controller
Signed-off-by: Justin Chadwell <me@jedevc.com>
This commit is contained in:

committed by
Kohei Tokunaga

parent
9f884edbbf
commit
a43837d26c
@ -58,7 +58,7 @@ func (cm *AttachCmd) Exec(ctx context.Context, args []string) error {
|
||||
}
|
||||
|
||||
func isProcessID(ctx context.Context, c types.Monitor, ref string) (bool, error) {
|
||||
infos, err := c.ListProcesses(ctx)
|
||||
infos, err := c.ListProcesses(ctx, c.AttachedSessionID())
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ func (cm *DisconnectCmd) Exec(ctx context.Context, args []string) error {
|
||||
}
|
||||
isProcess, err := isProcessID(ctx, cm.m, target)
|
||||
if err == nil && isProcess {
|
||||
if err := cm.m.DisconnectProcess(ctx, target); err != nil {
|
||||
if err := cm.m.DisconnectProcess(ctx, cm.m.AttachedSessionID(), target); err != nil {
|
||||
return errors.Errorf("disconnecting from process failed %v", target)
|
||||
}
|
||||
return nil
|
||||
|
@ -23,7 +23,8 @@ func (cm *PsCmd) Info() types.CommandInfo {
|
||||
}
|
||||
|
||||
func (cm *PsCmd) Exec(ctx context.Context, args []string) error {
|
||||
plist, err := cm.m.ListProcesses(ctx)
|
||||
ref := cm.m.AttachedSessionID()
|
||||
plist, err := cm.m.ListProcesses(ctx, ref)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -32,9 +32,9 @@ func (cm *ReloadCmd) Info() types.CommandInfo {
|
||||
|
||||
func (cm *ReloadCmd) Exec(ctx context.Context, args []string) error {
|
||||
var bo *controllerapi.BuildOptions
|
||||
if cm.m.AttachedSessionID() != "" {
|
||||
if ref := cm.m.AttachedSessionID(); ref != "" {
|
||||
// Rebuilding an existing session; Restore the build option used for building this session.
|
||||
res, err := cm.m.Inspect(ctx)
|
||||
res, err := cm.m.Inspect(ctx, ref)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to inspect the current build session: %v\n", err)
|
||||
} else {
|
||||
@ -46,8 +46,8 @@ func (cm *ReloadCmd) Exec(ctx context.Context, args []string) error {
|
||||
if bo == nil {
|
||||
return errors.Errorf("no build option is provided")
|
||||
}
|
||||
if cm.m.AttachedSessionID() != "" {
|
||||
if err := cm.m.Disconnect(ctx); err != nil {
|
||||
if ref := cm.m.AttachedSessionID(); ref != "" {
|
||||
if err := cm.m.Disconnect(ctx, ref); err != nil {
|
||||
fmt.Println("disconnect error", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user