Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions cmd/internal/cli/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,6 @@ func launchContainer(cmd *cobra.Command, ep launcher.ExecParams) error {
launcher.OptOverlayPaths(overlayPath),
launcher.OptScratchDirs(scratchPath),
launcher.OptWorkDir(workdirPath),
launcher.OptHome(
homePath,
cmd.Flag(actionHomeFlag.Name).Changed,
noHome,
),
launcher.OptMounts(bindPaths, mounts, fuseMount),
launcher.OptNoMount(noMount),
launcher.OptNvidia(nvidia, nvCCLI),
Expand Down Expand Up @@ -388,6 +383,13 @@ func launchContainer(cmd *cobra.Command, ep launcher.ExecParams) error {
launcher.OptNoCompat(noCompat),
launcher.OptNoTmpSandbox(noTmpSandbox),
}
if cmd.Flag(actionHomeFlag.Name) != nil {
opts = append(opts, launcher.OptHome(
homePath,
cmd.Flag(actionHomeFlag.Name).Changed,
noHome,
))
}

// Explicitly use the interface type here, as we will add alternative launchers later...
var l launcher.Launcher
Expand Down
4 changes: 4 additions & 0 deletions cmd/internal/cli/build_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,10 @@ func getEncryptionMaterial(cmd *cobra.Command) (*cryptkey.KeyInfo, error) {
pemPathEnv, pemPathEnvOK := os.LookupEnv("SINGULARITY_ENCRYPTION_PEM_PATH")

// checks for no flags/envvars being set
if (PEMFlag == nil) || (passphraseFlag == nil) {
return nil, nil
}

if !(PEMFlag.Changed || pemPathEnvOK || passphraseFlag.Changed || passphraseEnvOK) {
return nil, nil
}
Expand Down
17 changes: 17 additions & 0 deletions cmd/internal/cli/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/spf13/cobra"
"github.com/sylabs/sif/v2/pkg/sif"
"github.com/sylabs/singularity/v4/docs"
"github.com/sylabs/singularity/v4/internal/pkg/runtime/launcher"
"github.com/sylabs/singularity/v4/internal/pkg/util/env"
"github.com/sylabs/singularity/v4/pkg/cmdline"
"github.com/sylabs/singularity/v4/pkg/image"
Expand Down Expand Up @@ -171,6 +172,8 @@ func init() {
cmdManager.RegisterFlagForCmd(&inspectTestFlag, InspectCmd)
cmdManager.RegisterFlagForCmd(&inspectAppsListFlag, InspectCmd)
cmdManager.RegisterFlagForCmd(&inspectAllFlag, InspectCmd)

cmdManager.RegisterFlagForCmd(&commonOCIFlag, InspectCmd)
})
}

Expand Down Expand Up @@ -639,6 +642,20 @@ var InspectCmd = &cobra.Command{
Example: docs.InspectExample,

Run: func(cmd *cobra.Command, args []string) {
if isOCI {
actionPreRun(cmd, args)
// singularity inspect <image> [args...]
ep := launcher.ExecParams{
Image: args[0],
Action: "inspect",
Args: args[1:],
}
if err := launchContainer(cmd, ep); err != nil {
sylog.Fatalf("%s", err)
}
return
}

img, err := image.Init(args[0], false)
if err != nil {
sylog.Fatalf("Failed to open image %s: %s", args[0], err)
Expand Down
9 changes: 6 additions & 3 deletions internal/pkg/runtime/launcher/oci/process_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (l *Launcher) getProcess(ctx context.Context, imgSpec imgspecv1.Image, bund
return nil, nil, fmt.Errorf("while getting ProcessArgs: %w", err)
}
sylog.Debugf("Native SIF container process/args: %v", args)
case l.cfg.AppName != "":
case (l.cfg.AppName != "") || (ep.Action == "inspect"):
sylog.Debugf("SCIF app %q requested", l.cfg.AppName)
specArgs := getSpecArgs(imgSpec)
if len(specArgs) < 1 {
Expand Down Expand Up @@ -128,8 +128,11 @@ func (l *Launcher) getProcess(ctx context.Context, imgSpec imgspecv1.Image, bund

func (l *Launcher) argsForSCIF(specArgs []string, ep launcher.ExecParams) ([]string, error) {
switch ep.Action {
case "run", "exec", "shell":
args := []string{specArgs[0], ep.Action, l.cfg.AppName}
case "run", "exec", "shell", "inspect":
args := []string{specArgs[0], ep.Action}
if l.cfg.AppName != "" {
args = append(args, l.cfg.AppName)
}
args = append(args, specArgs[1:]...)
if ep.Process != "" {
args = append(args, ep.Process)
Expand Down