cli

package
v3.0.0-alpha.1+incompa... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 19, 2018 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SyCloudLibrary holds sylabs cloud library base URI
	// for more info refer to https://cloud.sylabs.io/library
	SyCloudLibrary = "library"
	// Shub holds singularity hub base URI
	// for more info refer to https://singularity-hub.org/
	Shub = "shub"
)

Variables

View Source
var (
	BindPaths   []string
	HomePath    string
	OverlayPath []string
	ScratchPath []string
	WorkdirPath string
	PwdPath     string
	ShellPath   string
	Hostname    string

	IsBoot       bool
	IsFakeroot   bool
	IsCleanEnv   bool
	IsContained  bool
	IsContainAll bool
	IsWritable   bool
	Nvidia       bool
	NoHome       bool

	NetNamespace  bool
	UtsNamespace  bool
	UserNamespace bool
	PidNamespace  bool
	IpcNamespace  bool

	AllowSUID bool
	KeepPrivs bool
	NoPrivs   bool
	AddCaps   []string
	DropCaps  []string
)

actionflags.go contains flag variables for action-like commands to draw from

View Source
var (
	CapUser    string
	CapGroup   string
	CapDesc    bool
	CapListAll bool
)

contains flag variables for capability commands

View Source
var BuildCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Args:                  cobra.ExactArgs(2),

	Use:     docs.BuildUse,
	Short:   docs.BuildShort,
	Long:    docs.BuildLong,
	Example: docs.BuildExample,
	PreRun:  sylabsToken,

	Run: func(cmd *cobra.Command, args []string) {
		buildFormat := "sif"
		if sandbox {
			buildFormat = "sandbox"
		}

		dest := args[0]
		spec := args[1]

		if ok := checkBuildTargetCollision(dest, force); !ok {
			os.Exit(1)
		}

		if remote {

			if authToken == "" {
				sylog.Fatalf("Unable to submit build job: %v", authWarning)
			}

			def, err := build.MakeDef(spec)
			if err != nil {
				return
			}

			b, err := build.NewRemoteBuilder(dest, libraryURL, def, detached, builderURL, authToken)
			if err != nil {
				sylog.Fatalf("failed to create builder: %v", err)
			}
			b.Build(context.TODO())
		} else {
			b, err := build.NewBuild(spec, dest, buildFormat)
			if err != nil {
				sylog.Fatalf("Unable to create build: %v\n", err)
				os.Exit(1)
			}

			if sections[0] == "all" {
				b.Full()
			} else {
				sylog.Fatalf("Running specific sections of definitions not implemented.")
			}
		}
	},
	TraverseChildren: true,
}

BuildCmd represents the build command

View Source
var CapabilityAddCmd = &cobra.Command{
	Args:                  cobra.MinimumNArgs(1),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		manageCap(args[0], capAdd)
	},

	Use:     docs.CapabilityAddUse,
	Short:   docs.CapabilityAddShort,
	Long:    docs.CapabilityAddLong,
	Example: docs.CapabilityAddExample,
}

CapabilityAddCmd singularity capability add

View Source
var CapabilityCmd = &cobra.Command{
	Run:                   nil,
	DisableFlagsInUseLine: true,

	Use:     docs.CapabilityUse,
	Short:   docs.CapabilityShort,
	Long:    docs.CapabilityLong,
	Example: docs.CapabilityExample,
}

CapabilityCmd is the capability command

View Source
var CapabilityDropCmd = &cobra.Command{
	Args:                  cobra.MinimumNArgs(1),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		manageCap(args[0], capDrop)
	},

	Use:     docs.CapabilityDropUse,
	Short:   docs.CapabilityDropShort,
	Long:    docs.CapabilityDropLong,
	Example: docs.CapabilityDropExample,
}

CapabilityDropCmd singularity capability drop

View Source
var CapabilityListCmd = &cobra.Command{
	Args:                  cobra.MinimumNArgs(0),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		manageCap("", capList)
	},

	Use:     docs.CapabilityListUse,
	Short:   docs.CapabilityListShort,
	Long:    docs.CapabilityListLong,
	Example: docs.CapabilityListExample,
}

CapabilityListCmd singularity capability list

View Source
var ExecCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	TraverseChildren:      true,
	Args:                  cobra.MinimumNArgs(2),
	Run: func(cmd *cobra.Command, args []string) {
		a := append([]string{"/.singularity.d/actions/exec"}, args[1:]...)
		execWrapper(cmd, args[0], a)
	},

	Use:     docs.ExecUse,
	Short:   docs.ExecShort,
	Long:    docs.ExecLong,
	Example: docs.ExecExamples,
}

ExecCmd represents the exec command

View Source
var InstanceCmd = &cobra.Command{
	Run:                   nil,
	DisableFlagsInUseLine: true,

	Use:     docs.InstanceUse,
	Short:   docs.InstanceShort,
	Long:    docs.InstanceLong,
	Example: docs.InstanceExample,
}

InstanceCmd singularity instance

View Source
var InstanceListCmd = &cobra.Command{
	Args: cobra.RangeArgs(0, 1),
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("listing instances")
	},
	DisableFlagsInUseLine: true,

	Use:     docs.InstanceListUse,
	Short:   docs.InstanceListShort,
	Long:    docs.InstanceListLong,
	Example: docs.InstanceListExample,
}

InstanceListCmd singularity instance list

View Source
var InstanceStartCmd = &cobra.Command{
	Args:                  cobra.MinimumNArgs(2),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("starting instance")
	},

	Use:     docs.InstanceStartUse,
	Short:   docs.InstanceStartShort,
	Long:    docs.InstanceStartLong,
	Example: docs.InstanceStartExample,
}

InstanceStartCmd singularity instance start

View Source
var InstanceStopCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("stopping instance")
	},

	Use:     docs.InstanceStopUse,
	Short:   docs.InstanceStopShort,
	Long:    docs.InstanceStopLong,
	Example: docs.InstanceStopExample,
}

InstanceStopCmd singularity instance stop

View Source
var KeysCmd = &cobra.Command{
	Run:                   nil,
	DisableFlagsInUseLine: true,

	Use:     docs.KeysUse,
	Short:   docs.KeysShort,
	Long:    docs.KeysLong,
	Example: docs.KeysExample,
}

KeysCmd is the 'keys' command that allows management of key stores

View Source
var KeysListCmd = &cobra.Command{
	Args:                  cobra.RangeArgs(0, 1),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		if err := doKeysListCmd(secret); err != nil {
			os.Exit(2)
		}
	},

	Use:     docs.KeysListUse,
	Short:   docs.KeysListShort,
	Long:    docs.KeysListLong,
	Example: docs.KeysListExample,
}

KeysListCmd is `singularity keys list' and lists local store PGP keys

View Source
var KeysNewPairCmd = &cobra.Command{
	Args:                  cobra.MinimumNArgs(0),
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		sypgp.GenKeyPair()
	},

	Use:     docs.KeysNewPairUse,
	Short:   docs.KeysNewPairShort,
	Long:    docs.KeysNewPairLong,
	Example: docs.KeysNewPairExample,
}

KeysNewPairCmd is `singularity keys newpair' and generate a new OpenPGP key pair

View Source
var KeysPullCmd = &cobra.Command{
	Args:                  cobra.RangeArgs(1, 2),
	DisableFlagsInUseLine: true,
	PreRun:                sylabsToken,
	Run: func(cmd *cobra.Command, args []string) {
		if err := doKeysPullCmd(args[0], url); err != nil {
			sylog.Errorf("pull failed: %s", err)
			os.Exit(2)
		}
	},

	Use:     docs.KeysPullUse,
	Short:   docs.KeysPullShort,
	Long:    docs.KeysPullLong,
	Example: docs.KeysPullExample,
}

KeysPullCmd is `singularity keys pull' and fetches public keys from a key server

View Source
var KeysPushCmd = &cobra.Command{
	Args:                  cobra.RangeArgs(1, 2),
	DisableFlagsInUseLine: true,
	PreRun:                sylabsToken,
	Run: func(cmd *cobra.Command, args []string) {
		if err := doKeysPushCmd(args[0], url); err != nil {
			sylog.Errorf("push failed: %s", err)
			os.Exit(2)
		}
	},

	Use:     docs.KeysPushUse,
	Short:   docs.KeysPushShort,
	Long:    docs.KeysPushLong,
	Example: docs.KeysPushExample,
}

KeysPushCmd is `singularity keys list' and lists local store OpenPGP keys

View Source
var KeysSearchCmd = &cobra.Command{
	Args:                  cobra.RangeArgs(1, 2),
	DisableFlagsInUseLine: true,
	PreRun:                sylabsToken,
	Run: func(cmd *cobra.Command, args []string) {
		if err := doKeysSearchCmd(args[0], url); err != nil {
			sylog.Errorf("search failed: %s", err)
			os.Exit(2)
		}
	},

	Use:     docs.KeysSearchUse,
	Short:   docs.KeysSearchShort,
	Long:    docs.KeysSearchLong,
	Example: docs.KeysSearchExample,
}

KeysSearchCmd is `singularity keys search' and look for public keys from a key server

View Source
var PullCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Args:                  cobra.RangeArgs(1, 2),
	PreRun:                sylabsToken,
	Run: func(cmd *cobra.Command, args []string) {
		var uri, image string
		image = ""
		if len(args) == 2 {
			uri = args[1]
			image = args[0]
		} else {
			uri = args[0]
		}
		BaseURI := strings.Split(uri, "://")
		switch BaseURI[0] {
		case SyCloudLibrary:
			libexec.PullImage(image, uri, PullLibraryURI, force, authToken)
		case Shub:
			sylog.Errorf("Shub not yet supported")
		default:
			sylog.Errorf("Not a supported URI")
		}
	},

	Use:     docs.PullUse,
	Short:   docs.PullShort,
	Long:    docs.PullLong,
	Example: docs.PullExample,
}

PullCmd singularity pull

View Source
var (
	// PullLibraryURI holds the base URI to a Sylabs library API instance
	PullLibraryURI string
)
View Source
var PushCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Args:                  cobra.ExactArgs(2),
	PreRun:                sylabsToken,
	Run: func(cmd *cobra.Command, args []string) {

		if authToken != "" {
			libexec.PushImage(args[0], args[1], PushLibraryURI, authToken)
		} else {
			sylog.Fatalf("Couldn't push image to library: %v", authWarning)
		}
	},

	Use:     docs.PushUse,
	Short:   docs.PushShort,
	Long:    docs.PushLong,
	Example: docs.PushExample,
}

PushCmd singularity push

View Source
var (
	// PushLibraryURI holds the base URI to a Sylabs library API instance
	PushLibraryURI string
)
View Source
var RunCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	TraverseChildren:      true,
	Args:                  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		a := append([]string{"/.singularity.d/actions/run"}, args[1:]...)
		execWrapper(cmd, args[0], a)
	},

	Use:     docs.RunUse,
	Short:   docs.RunShort,
	Long:    docs.RunLong,
	Example: docs.RunExamples,
}

RunCmd represents the run command

View Source
var ShellCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	TraverseChildren:      true,
	Args:                  cobra.MinimumNArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		a := append([]string{"/.singularity.d/actions/shell"}, args[1:]...)
		execWrapper(cmd, args[0], a)
	},

	Use:     docs.ShellUse,
	Short:   docs.ShellShort,
	Long:    docs.ShellLong,
	Example: docs.ShellExamples,
}

ShellCmd represents the shell command

View Source
var SignCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Args:                  cobra.ExactArgs(1),
	PreRun:                sylabsToken,

	Run: func(cmd *cobra.Command, args []string) {

		fmt.Printf("Signing image: %s\n", args[0])
		if err := signing.Sign(args[0], authToken); err != nil {
			sylog.Errorf("signing container failed: %s", err)
			os.Exit(2)
		}
	},

	Use:     docs.SignUse,
	Short:   docs.SignShort,
	Long:    docs.SignLong,
	Example: docs.SignExample,
}

SignCmd singularity sign

View Source
var SingularityCmd = &cobra.Command{
	TraverseChildren:      true,
	DisableFlagsInUseLine: true,
	PersistentPreRun:      setSylogMessageLevel,
	Run:                   nil,

	Use:     docs.SingularityUse,
	Version: fmt.Sprintf("%v-%v\n", buildcfg.PACKAGE_VERSION, buildcfg.GIT_VERSION),
	Short:   docs.SingularityShort,
	Long:    docs.SingularityLong,
	Example: docs.SingularityExample,
}

SingularityCmd is the base command when called without any subcommands

View Source
var VerifyCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Args:                  cobra.ExactArgs(1),
	PreRun:                sylabsToken,

	Run: func(cmd *cobra.Command, args []string) {

		fmt.Printf("Verifying image: %s\n", args[0])
		if err := signing.Verify(args[0], authToken); err != nil {
			sylog.Errorf("verification failed: %s", err)
			os.Exit(2)
		}
	},

	Use:     docs.VerifyUse,
	Short:   docs.VerifyShort,
	Long:    docs.VerifyLong,
	Example: docs.VerifyExample,
}

VerifyCmd singularity verify

View Source
var VersionCmd = &cobra.Command{
	DisableFlagsInUseLine: true,
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Printf("%v-%v\n", buildcfg.PACKAGE_VERSION, buildcfg.GIT_VERSION)
	},

	Use:   "version",
	Short: "Show application version",
}

VersionCmd displays installed singularity version

Functions

func ExecuteSingularity

func ExecuteSingularity()

ExecuteSingularity adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the root command (singularity).

func TraverseParentsUses

func TraverseParentsUses(cmd *cobra.Command) string

TraverseParentsUses walks the parent commands and outputs a properly formatted use string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL