mirror of
https://github.com/abiosoft/colima.git
synced 2026-05-17 12:10:34 +00:00
misc: improve password prompt message for network setup
Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
This commit is contained in:
+3
-3
@@ -54,7 +54,7 @@ type namedCommandChain struct {
|
|||||||
log *log.Entry
|
log *log.Entry
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n namedCommandChain) Logger(ctx context.Context) *log.Entry {
|
func (n *namedCommandChain) Logger(ctx context.Context) *log.Entry {
|
||||||
if quiet, _ := ctx.Value(CtxKeyQuiet).(bool); quiet {
|
if quiet, _ := ctx.Value(CtxKeyQuiet).(bool); quiet {
|
||||||
l := log.New()
|
l := log.New()
|
||||||
l.SetOutput(io.Discard)
|
l.SetOutput(io.Discard)
|
||||||
@@ -66,7 +66,7 @@ func (n namedCommandChain) Logger(ctx context.Context) *log.Entry {
|
|||||||
return n.log
|
return n.log
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n namedCommandChain) Init(ctx context.Context) *ActiveCommandChain {
|
func (n *namedCommandChain) Init(ctx context.Context) *ActiveCommandChain {
|
||||||
return &ActiveCommandChain{
|
return &ActiveCommandChain{
|
||||||
log: n.Logger(ctx),
|
log: n.Logger(ctx),
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@ func (a *ActiveCommandChain) Stage(s string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stagef is like stage with string format.
|
// Stagef is like stage with string format.
|
||||||
func (a *ActiveCommandChain) Stagef(format string, s ...interface{}) {
|
func (a *ActiveCommandChain) Stagef(format string, s ...any) {
|
||||||
f := fmt.Sprintf(format, s...)
|
f := fmt.Sprintf(format, s...)
|
||||||
a.Stage(f)
|
a.Stage(f)
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-3
@@ -20,7 +20,7 @@ type Manager interface {
|
|||||||
Start(context.Context, config.Config) error
|
Start(context.Context, config.Config) error
|
||||||
Stop(context.Context, config.Config) error
|
Stop(context.Context, config.Config) error
|
||||||
Running(context.Context, config.Config) (Status, error)
|
Running(context.Context, config.Config) (Status, error)
|
||||||
Dependencies(context.Context, config.Config) (deps process.Dependency, root bool)
|
Dependency(ctx context.Context, conf config.Config, name string) (deps process.Dependency, root bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
@@ -50,9 +50,16 @@ type processManager struct {
|
|||||||
host environment.HostActions
|
host environment.HostActions
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l processManager) Dependencies(ctx context.Context, conf config.Config) (deps process.Dependency, root bool) {
|
func (l processManager) Dependency(ctx context.Context, conf config.Config, name string) (deps process.Dependency, root bool) {
|
||||||
processes := processesFromConfig(conf)
|
processes := processesFromConfig(conf)
|
||||||
return process.Dependencies(processes...)
|
|
||||||
|
for _, p := range processes {
|
||||||
|
if p.Name() == name {
|
||||||
|
return process.Dependencies(p)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return process.Dependencies()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l processManager) init() error {
|
func (l processManager) init() error {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C
|
|||||||
if conf.MountINotify {
|
if conf.MountINotify {
|
||||||
a.Add(func() error {
|
a.Add(func() error {
|
||||||
ctx = context.WithValue(ctx, ctxKeyInotify, true)
|
ctx = context.WithValue(ctx, ctxKeyInotify, true)
|
||||||
deps, _ := l.daemon.Dependencies(ctx, conf)
|
deps, _ := l.daemon.Dependency(ctx, conf, inotify.Name)
|
||||||
if err := deps.Install(l.host); err != nil {
|
if err := deps.Install(l.host); err != nil {
|
||||||
return fmt.Errorf("error setting up inotify dependencies: %w", err)
|
return fmt.Errorf("error setting up inotify dependencies: %w", err)
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C
|
|||||||
a.Stage("preparing network")
|
a.Stage("preparing network")
|
||||||
ctx = context.WithValue(ctx, ctxKeyVmnet, true)
|
ctx = context.WithValue(ctx, ctxKeyVmnet, true)
|
||||||
}
|
}
|
||||||
deps, root := l.daemon.Dependencies(ctx, conf)
|
deps, root := l.daemon.Dependency(ctx, conf, vmnet.Name)
|
||||||
if deps.Installed() {
|
if deps.Installed() {
|
||||||
ctx = context.WithValue(ctx, networkInstalledKey, true)
|
ctx = context.WithValue(ctx, networkInstalledKey, true)
|
||||||
return nil
|
return nil
|
||||||
@@ -64,7 +64,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C
|
|||||||
// if user interaction is not required (i.e. root),
|
// if user interaction is not required (i.e. root),
|
||||||
// no need for another verbose info.
|
// no need for another verbose info.
|
||||||
if root {
|
if root {
|
||||||
log.Println("dependencies missing for setting up reachable IP address")
|
log.Println("setting up reachable IP address")
|
||||||
log.Println("sudo password may be required")
|
log.Println("sudo password may be required")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user