mirror of
https://github.com/docker/compose.git
synced 2025-07-26 07:04:32 +02:00
fix panic using w shortcut on project without watch support
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
ea1c26d22a
commit
4f491ffa98
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
|
"reflect"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -69,8 +70,9 @@ func (ke *KeyboardError) error() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type KeyboardWatch struct {
|
type KeyboardWatch struct {
|
||||||
Watching bool
|
Watching bool
|
||||||
Watcher Toggle
|
Watcher Toggle
|
||||||
|
IsConfigured bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Toggle interface {
|
type Toggle interface {
|
||||||
@ -90,7 +92,6 @@ type LogKeyboard struct {
|
|||||||
kError KeyboardError
|
kError KeyboardError
|
||||||
Watch KeyboardWatch
|
Watch KeyboardWatch
|
||||||
IsDockerDesktopActive bool
|
IsDockerDesktopActive bool
|
||||||
IsWatchConfigured bool
|
|
||||||
logLevel KEYBOARD_LOG_LEVEL
|
logLevel KEYBOARD_LOG_LEVEL
|
||||||
signalChannel chan<- os.Signal
|
signalChannel chan<- os.Signal
|
||||||
}
|
}
|
||||||
@ -101,11 +102,11 @@ var KeyboardManager *LogKeyboard
|
|||||||
func NewKeyboardManager(isDockerDesktopActive bool, sc chan<- os.Signal, w bool, watcher Toggle) *LogKeyboard {
|
func NewKeyboardManager(isDockerDesktopActive bool, sc chan<- os.Signal, w bool, watcher Toggle) *LogKeyboard {
|
||||||
KeyboardManager = &LogKeyboard{
|
KeyboardManager = &LogKeyboard{
|
||||||
Watch: KeyboardWatch{
|
Watch: KeyboardWatch{
|
||||||
Watching: w,
|
Watching: w,
|
||||||
Watcher: watcher,
|
Watcher: watcher,
|
||||||
|
IsConfigured: !reflect.ValueOf(watcher).IsNil(),
|
||||||
},
|
},
|
||||||
IsDockerDesktopActive: isDockerDesktopActive,
|
IsDockerDesktopActive: isDockerDesktopActive,
|
||||||
IsWatchConfigured: true,
|
|
||||||
logLevel: INFO,
|
logLevel: INFO,
|
||||||
signalChannel: sc,
|
signalChannel: sc,
|
||||||
}
|
}
|
||||||
@ -267,7 +268,7 @@ func (lk *LogKeyboard) keyboardError(prefix string, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (lk *LogKeyboard) ToggleWatch(ctx context.Context, options api.UpOptions) {
|
func (lk *LogKeyboard) ToggleWatch(ctx context.Context, options api.UpOptions) {
|
||||||
if !lk.IsWatchConfigured {
|
if !lk.Watch.IsConfigured {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if lk.Watch.Watching {
|
if lk.Watch.Watching {
|
||||||
@ -298,7 +299,7 @@ func (lk *LogKeyboard) HandleKeyEvents(ctx context.Context, event keyboard.KeyEv
|
|||||||
case 'v':
|
case 'v':
|
||||||
lk.openDockerDesktop(ctx, project)
|
lk.openDockerDesktop(ctx, project)
|
||||||
case 'w':
|
case 'w':
|
||||||
if !lk.IsWatchConfigured {
|
if !lk.Watch.IsConfigured {
|
||||||
// we try to open watch docs if DD is installed
|
// we try to open watch docs if DD is installed
|
||||||
if lk.IsDockerDesktopActive {
|
if lk.IsDockerDesktopActive {
|
||||||
lk.openDDWatchDocs(ctx, project)
|
lk.openDDWatchDocs(ctx, project)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user