From f50a82f02707a9eb1283489106be8a0dd2e13b22 Mon Sep 17 00:00:00 2001 From: Abiola Ibrahim Date: Wed, 20 Aug 2025 10:00:39 +0100 Subject: [PATCH] misc: improve password prompt message for network setup Signed-off-by: Abiola Ibrahim --- cli/chain.go | 6 +++--- daemon/daemon.go | 13 ++++++++++--- environment/vm/lima/daemon.go | 6 +++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/cli/chain.go b/cli/chain.go index d4a35c8..2795113 100644 --- a/cli/chain.go +++ b/cli/chain.go @@ -54,7 +54,7 @@ type namedCommandChain struct { 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 { l := log.New() l.SetOutput(io.Discard) @@ -66,7 +66,7 @@ func (n namedCommandChain) Logger(ctx context.Context) *log.Entry { return n.log } -func (n namedCommandChain) Init(ctx context.Context) *ActiveCommandChain { +func (n *namedCommandChain) Init(ctx context.Context) *ActiveCommandChain { return &ActiveCommandChain{ log: n.Logger(ctx), } @@ -99,7 +99,7 @@ func (a *ActiveCommandChain) Stage(s string) { } // 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...) a.Stage(f) } diff --git a/daemon/daemon.go b/daemon/daemon.go index 3bd7321..bbbf185 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -20,7 +20,7 @@ type Manager interface { Start(context.Context, config.Config) error Stop(context.Context, config.Config) 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 { @@ -50,9 +50,16 @@ type processManager struct { 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) - return process.Dependencies(processes...) + + for _, p := range processes { + if p.Name() == name { + return process.Dependencies(p) + } + } + + return process.Dependencies() } func (l processManager) init() error { diff --git a/environment/vm/lima/daemon.go b/environment/vm/lima/daemon.go index 81aa5da..4edb448 100644 --- a/environment/vm/lima/daemon.go +++ b/environment/vm/lima/daemon.go @@ -40,7 +40,7 @@ func (l *limaVM) startDaemon(ctx context.Context, conf config.Config) (context.C if conf.MountINotify { a.Add(func() error { 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 { 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") 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() { ctx = context.WithValue(ctx, networkInstalledKey, true) 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), // no need for another verbose info. 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") }