misc: improve password prompt message for network setup

Signed-off-by: Abiola Ibrahim <git@abiosoft.com>
This commit is contained in:
Abiola Ibrahim
2025-08-20 10:00:39 +01:00
parent 44716fac27
commit f50a82f027
3 changed files with 16 additions and 9 deletions
+3 -3
View File
@@ -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)
}
+10 -3
View File
@@ -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 {
+3 -3
View File
@@ -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")
}