Skip to content

Commit

Permalink
start: Add support for arbitrary profile images
Browse files Browse the repository at this point in the history
Signed-off-by: Paulo Gomes <[email protected]>
  • Loading branch information
pjbgf committed May 31, 2024
1 parent 7126181 commit ea67adb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
18 changes: 9 additions & 9 deletions internal/profiles/profiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ import (

var (
ContainerNameFormat = "qubesome-%s"

profileImage = "ghcr.io/qubesome/xorg:latest"
defaultProfileImage = "ghcr.io/qubesome/xorg:latest"
)

func Run(opts ...command.Option[Options]) error {
Expand Down Expand Up @@ -66,11 +65,7 @@ func validGitDir(path string) bool {

// Confirm the repository exists and is a valid Git repository.
_, err = git.PlainOpen(path)
if err != nil {
return false
}

return true
return err == nil
}

func StartFromGit(name, gitURL, path, local string) error {
Expand All @@ -90,7 +85,7 @@ func StartFromGit(name, gitURL, path, local string) error {
}
}

if local != "" && validGitDir(local) {
if local != "" && validGitDir(local) { //nolint
slog.Debug("start from local", "path", local)
dir = local
} else if validGitDir(dir) {
Expand Down Expand Up @@ -169,6 +164,11 @@ func Start(profile *types.Profile, cfg *types.Config) (err error) {
return fmt.Errorf("cannot start profile: config is nil")
}

if profile.Image == "" {
slog.Debug("no profile image set, using default instead", "default-image", defaultProfileImage)
profile.Image = defaultProfileImage
}

// Block profile from starting if external drive is not available.
if len(profile.ExternalDrives) > 0 {
slog.Debug("profile has required external drives", "drives", profile.ExternalDrives)
Expand Down Expand Up @@ -382,7 +382,7 @@ func createNewDisplay(profile *types.Profile, display string) error {
dockerArgs = append(dockerArgs, paths...)

dockerArgs = append(dockerArgs, fmt.Sprintf("--name=%s", fmt.Sprintf(ContainerNameFormat, profile.Name)))
dockerArgs = append(dockerArgs, profileImage)
dockerArgs = append(dockerArgs, profile.Image)
dockerArgs = append(dockerArgs, command)
dockerArgs = append(dockerArgs, cArgs...)

Expand Down
5 changes: 5 additions & 0 deletions internal/types/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,16 @@ type Profile struct {
// ExternalDrives defines the required external drives to run the profile.
ExternalDrives []string `yaml:"externalDrives"`

// Image is the container image name used for running the profile.
// It should contain Xephyr and any additional window managers required.
Image string

// WindowManager holds the command to run the Window Manager once
// the X server is running.
//
// Example: exec awesome
WindowManager string `yaml:"windowManager"`

// XephyrArgs defines additional args to be passed on to Xephyr.
XephyrArgs string `yaml:"xephyrArgs"`
}
Expand Down

0 comments on commit ea67adb

Please sign in to comment.