Skip to content

Commit

Permalink
fix: there is no destinction between prompts
Browse files Browse the repository at this point in the history
with distrobox 1.7, the hostname is now in sync with the host. This commit explicitly sets the hostname to the subsystem name. Also allows to set a custom one using the Hostname key in the Subsystem struct.
  • Loading branch information
mirkobrombin committed May 19, 2024
1 parent 8d279e6 commit 288e000
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/subsyStems.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func newSubSystem(cmd *cobra.Command, args []string) error {
return err
}

subSystem, err := core.NewSubSystem(subSystemName, stack, home, isInit, false, false, false, true)
subSystem, err := core.NewSubSystem(subSystemName, stack, home, isInit, false, false, false, true, "")
if err != nil {
return err
}
Expand Down
8 changes: 7 additions & 1 deletion core/dbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func (d *dbox) ContainerDelete(name string, rootFull bool) error {
return err
}

func (d *dbox) CreateContainer(name string, image string, additionalPackages []string, home string, labels map[string]string, withInit bool, rootFull bool, unshared bool, withNvidiaIntegration bool) error {
func (d *dbox) CreateContainer(name string, image string, additionalPackages []string, home string, labels map[string]string, withInit bool, rootFull bool, unshared bool, withNvidiaIntegration bool, hostname string) error {
args := []string{
"--image", image,
"--name", name,
Expand All @@ -263,6 +263,12 @@ func (d *dbox) CreateContainer(name string, image string, additionalPackages []s
args = append(args, "--unshare-all")
}

if hostname != "" {
args = append(args, "--hostname", hostname)
} else {
args = append(args, "--hostname", name)
}

if len(additionalPackages) > 0 {
args = append(args, "--additional-packages")
args = append(args, strings.Join(additionalPackages, " "))
Expand Down
5 changes: 4 additions & 1 deletion core/subSystem.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ type SubSystem struct {
IsRootfull bool
IsUnshared bool
HasNvidiaIntegration bool
Hostname string
}

func NewSubSystem(name string, stack *Stack, home string, hasInit bool, isManaged bool, isRootfull bool, isUnshared bool, hasNvidiaIntegration bool) (*SubSystem, error) {
func NewSubSystem(name string, stack *Stack, home string, hasInit bool, isManaged bool, isRootfull bool, isUnshared bool, hasNvidiaIntegration bool, hostname string) (*SubSystem, error) {
internalName := genInternalName(name)
return &SubSystem{
InternalName: internalName,
Expand All @@ -46,6 +47,7 @@ func NewSubSystem(name string, stack *Stack, home string, hasInit bool, isManage
IsRootfull: isRootfull,
IsUnshared: isUnshared,
HasNvidiaIntegration: hasNvidiaIntegration,
Hostname: hostname,
}, nil
}

Expand Down Expand Up @@ -150,6 +152,7 @@ func (s *SubSystem) Create() error {
s.IsRootfull,
s.IsUnshared,
s.HasNvidiaIntegration,
s.Hostname,
)
if err != nil {
return err
Expand Down

0 comments on commit 288e000

Please sign in to comment.