fix(enter): build --dry-run command without a live container

Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
This commit is contained in:
Luca Di Maio committed 2026-06-25 09:07:22 +02:00
1 parent cc11c2d48b
commit bc26dfcd35
2 files changed
+20 -4

No files matched your search

+10 -2
View File
@@ -522,6 +522,7 @@ func (d *Docker) Enter(
options.NoWorkDir,
options.CleanPath,
options.Verbose,
options.DryRun,
)
if err != nil {
return fmt.Errorf("err: %w", err)
@@ -726,6 +727,7 @@ func (d *Docker) generateEnterCommand(
noWorkDir bool,
cleanPath bool,
verbose bool,
dryRun bool,
) ([]string, *containermanager.InspectResult, error) {
cmd := []string{}
@@ -739,8 +741,14 @@ func (d *Docker) generateEnterCommand(
containerConfig, err := d.InspectContainer(ctx, containerName)
if err != nil {
// TODO handle missing container
return nil, nil, err
if !dryRun {
return nil, nil, err
}
// Dry-run without a live container: build the command from host state,
// matching the shell (distrobox-enter:578-588).
containerConfig = &containermanager.InspectResult{
ContainerHome: userenv.LoadUserEnvironment(ctx).Home,
}
}
// User selection
if containerConfig.UnshareGroups {
+10 -2
View File
@@ -531,6 +531,7 @@ func (p *Podman) Enter(
options.NoWorkDir,
options.CleanPath,
options.Verbose,
options.DryRun,
)
if err != nil {
return fmt.Errorf("err: %w", err)
@@ -809,6 +810,7 @@ func (p *Podman) generateEnterCommand(
noWorkDir bool,
cleanPath bool,
verbose bool,
dryRun bool,
) ([]string, *containermanager.InspectResult, error) {
cmd := []string{}
@@ -822,8 +824,14 @@ func (p *Podman) generateEnterCommand(
containerConfig, err := p.InspectContainer(ctx, containerName)
if err != nil {
// TODO handle missing container
return nil, nil, err
if !dryRun {
return nil, nil, err
}
// Dry-run without a live container: build the command from host state,
// matching the shell (distrobox-enter:578-588).
containerConfig = &containermanager.InspectResult{
ContainerHome: userenv.LoadUserEnvironment(ctx).Home,
}
}
// User selection
if containerConfig.UnshareGroups {