app

package
v0.3.22 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 56 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CategoryBasic      = "Basic Commands"
	CategoryManagement = "Management Commands"
	CategoryExpert     = "Expert Commands"
	CategorySettings   = "Setting Commands"
	CategoryOther      = "Other Commands"
)
View Source
const (
	SINGLE_SELECT   string = "single select"
	MULTIPLE_SELECT string = "multiple select"
	INPUT           string = "input"
)
View Source
const (
	LabelLanguage          string = "Language"
	LabelCuda              string = "Cuda"
	LabelCudaChoice        string = "Cuda Choice"
	LabelJupyterChoice     string = "Jupyter Choice"
	LabelPythonPackage     string = "Python Package"
	LabelRPackage          string = "R Package"
	LabelCondaEnv          string = "Conda Env"
	LabelPythonRequirement string = "Python Requirement"
)

Variables

View Source
var CommandBootstrap = &cli.Command{
	Name:     "bootstrap",
	Category: CategorySettings,
	Usage:    "Bootstrap the envd installation",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "buildkit",
			Usage:   "Download the image and bootstrap buildkit",
			Aliases: []string{"b"},
			Value:   true,
		},
		&cli.BoolFlag{
			Name:  "with-autocomplete",
			Usage: "Add envd autocompletions",
			Value: true,
		},
		&cli.StringFlag{
			Name:    "dockerhub-mirror",
			Usage:   "Dockerhub mirror to use",
			Aliases: []string{"m"},
		},
		&cli.StringFlag{
			Name:    "registry-ca-keypair",
			Usage:   "Specify the ca/key/cert file path for the private registry (format: 'ca=/etc/config/ca.pem,key=/etc/config/key.pem,cert=/etc/config/cert.pem')",
			Aliases: []string{"ca"},
		},
		&cli.StringSliceFlag{
			Name: "ssh-keypair",
			Usage: fmt.Sprintf("Manually specify ssh key pair as `publicKey,privateKey`. Envd will generate a keypair at %s and %s if not specified",
				sshconfig.GetPublicKeyOrPanic(), sshconfig.GetPrivateKeyOrPanic()),
			Aliases: []string{"k"},
		},
	},

	Action: bootstrap,
}
View Source
var CommandBuild = &cli.Command{
	Name:     "build",
	Category: CategoryBasic,
	Aliases:  []string{"b"},
	Usage:    "Build the envd environment",
	Description: `
To build an image using build.envd:
	$ envd build
To build and push the image to a registry:
	$ envd build --output type=image,name=docker.io/username/image,push=true
`,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:        "tag",
			Usage:       "Name and optionally a tag in the 'name:tag' format",
			Aliases:     []string{"t"},
			DefaultText: "PROJECT:dev",
		},
		&cli.PathFlag{
			Name:    "from",
			Usage:   "Function to execute, format `file:func`",
			Aliases: []string{"f"},
			Value:   "build.envd:build",
		},
		&cli.BoolFlag{
			Name:    "use-proxy",
			Usage:   "Use HTTPS_PROXY/HTTP_PROXY/NO_PROXY in the build process",
			Aliases: []string{"proxy"},
			Value:   false,
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Path to the directory containing the build.envd",
			Aliases: []string{"p"},
			Value:   ".",
		},
		&cli.PathFlag{
			Name:    "public-key",
			Usage:   "Path to the public key",
			Aliases: []string{"pubk"},
			Value:   sshconfig.GetPublicKeyOrPanic(),
			Hidden:  true,
		},
		&cli.StringFlag{
			Name:    "output",
			Usage:   "Output destination (e.g. type=tar,dest=path,push=true)",
			Aliases: []string{"o"},
		},
		&cli.BoolFlag{
			Name:  "force",
			Usage: "Force rebuild the image",
			Value: false,
		},

		&cli.StringFlag{
			Name:    "export-cache",
			Usage:   "Export the cache (e.g. type=registry,ref=<image>)",
			Aliases: []string{"ec"},
		},
		&cli.StringFlag{
			Name:    "import-cache",
			Usage:   "Import the cache (e.g. type=registry,ref=<image>)",
			Aliases: []string{"ic"},
		},
		&cli.StringFlag{
			Name: "platform",
			Usage: `Specify the target platforms for the build output (for example, windows/amd64 or linux/amd64,darwin/arm64).
	Build images with same tags could cause image overwriting, platform suffixes will be added to differentiate the images.`,
			DefaultText: runtimeutil.GetRuntimePlatform(),
		},
	},
	Action: build,
}
View Source
var CommandCompletion = &cli.Command{
	Name:     "completion",
	Category: CategorySettings,
	Usage:    "Install shell completion scripts for envd",
	Flags: []cli.Flag{
		&cli.StringSliceFlag{
			Name:    "shell",
			Usage:   "Shell type to install completion",
			Aliases: []string{"s"},
		},
		&cli.BoolFlag{
			Name:  "no-install",
			Usage: "Only output the completion script and don't install it",
		},
	},

	Action: completion,
}
View Source
var CommandContext = &cli.Command{
	Name:     "context",
	Category: CategoryManagement,
	Usage:    "Manage envd contexts",
	Subcommands: []*cli.Command{
		CommandContextCreate,
		CommandContextList,
		CommandContextRemove,
		CommandContextUse,
	},
}
View Source
var CommandContextCreate = &cli.Command{
	Name:  "create",
	Usage: "Create envd context",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "name",
			Usage:    "Name of the context",
			Value:    "",
			Required: true,
		},
		&cli.StringFlag{
			Name:  "builder",
			Usage: "Builder to use (docker-container, kube-pod, tcp, unix)",
			Value: string(types.BuilderTypeDocker),
		},
		&cli.StringFlag{
			Name:  "builder-address",
			Usage: "Builder address",
			Value: "envd_buildkitd",
		},
		&cli.StringFlag{
			Name:  "runner",
			Usage: "Runner to use(docker, envd-server)",
			Value: string(types.RunnerTypeDocker),
		},
		&cli.StringFlag{
			Name:  "runner-address",
			Usage: "Runner address",
		},
		&cli.BoolFlag{
			Name:  "use",
			Usage: "Use the context",
		},
	},
	Action: contextCreate,
}
View Source
var CommandContextList = &cli.Command{
	Name:  "ls",
	Usage: "List envd contexts",
	Flags: []cli.Flag{
		&formatter.FormatFlag,
	},
	Action: contextList,
}
View Source
var CommandContextRemove = &cli.Command{
	Name:  "rm",
	Usage: "Remove envd context",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "name",
			Usage:    "Name of the context",
			Value:    "",
			Required: true,
		},
	},
	Action: contextRemove,
}
View Source
var CommandContextUse = &cli.Command{
	Name:  "use",
	Usage: "Use the specified envd context",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "name",
			Usage:    "Name of the context",
			Value:    "",
			Required: true,
		},
	},
	Action: contextUse,
}
View Source
var CommandCreate = &cli.Command{
	Name:        "run",
	Category:    CategoryBasic,
	Aliases:     []string{"c"},
	Usage:       "Run the envd environment from the existing image",
	Hidden:      false,
	Description: `run is only supported in envd-server runner currently`,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:        "image",
			Usage:       "image name",
			DefaultText: "PROJECT:dev",
			Required:    true,
		},
		&cli.StringFlag{
			Name:  "name",
			Usage: "environment name",
		},
		&cli.DurationFlag{
			Name:  "timeout",
			Usage: "Timeout of container creation",
			Value: time.Second * 1800,
		},
		&cli.BoolFlag{
			Name:  "detach",
			Usage: "Detach from the container",
			Value: false,
		},
		&cli.PathFlag{
			Name:    "private-key",
			Usage:   "Path to the private key",
			Aliases: []string{"k"},
			Value:   sshconfig.GetPrivateKeyOrPanic(),
			Hidden:  true,
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Working directory path to be used as project root",
			Aliases: []string{"p"},
			Value:   ".",
		},
		&cli.StringFlag{
			Name:  "host",
			Usage: "Assign the host address for environment ssh acesss server listening",
			Value: envd.Localhost,
		},
		&cli.IntFlag{
			Name:  "shm-size",
			Usage: "Configure the shared memory size (megabyte)",
			Value: 2048,
		},
		&cli.StringFlag{
			Name:  "cpus",
			Usage: "Request CPU resources (number of cores), such as 0.5, 1, 2",
			Value: "",
		},
		&cli.StringFlag{
			Name:  "memory",
			Usage: "Request Memory, such as 512M, 2G",
			Value: "",
		},
		&cli.StringFlag{
			Name:  "gpu",
			Usage: "Request GPU resources (number of gpus), such as 1, 2",
			Value: "",
		},
		&cli.BoolFlag{
			Name:  "sync",
			Usage: "Sync the local directory with the remote container",
			Value: false,
		},
		&cli.StringSliceFlag{
			Name:    "volume",
			Usage:   "Mount host directory into container",
			Aliases: []string{"v"},
		},
	},
	Action: run,
}
View Source
var CommandDebug = &cli.Command{
	Name:        "debug",
	Category:    CategoryOther,
	Aliases:     []string{"b"},
	Usage:       "Debug commands",
	Description: ``,

	Subcommands: []*cli.Command{
		CommandDebugLLB,
	},
}
View Source
var CommandDebugLLB = &cli.Command{
	Name:        "llb",
	Category:    CategoryOther,
	Aliases:     []string{"b"},
	Usage:       "dump buildkit LLB in human-readable format.",
	Description: ``,

	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:  "dot",
			Usage: "Output dot format",
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Path to the directory containing the build.envd",
			Aliases: []string{"p"},
			Value:   ".",
		},
		&cli.PathFlag{
			Name:    "from",
			Usage:   "Function to execute, format `file:func`",
			Aliases: []string{"f"},
			Value:   "build.envd:build",
		},
		&cli.PathFlag{
			Name:    "public-key",
			Usage:   "Path to the public key",
			Aliases: []string{"pubk"},
			Value:   sshconfig.GetPublicKeyOrPanic(),
			Hidden:  true,
		},
	},

	Action: debugLLB,
}
View Source
var CommandDescribeEnvironment = &cli.Command{
	Name:    "describe",
	Aliases: []string{"d"},
	Usage:   "Show details about environments, including dependencies and port binding",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "env",
			Usage:   "Specify the envd environment to use",
			Aliases: []string{"e"},
			Value:   getCurrentDirOrPanic(),
		},
		&formatter.FormatFlag,
	},
	Action: getEnvironmentDescriptions,
}
View Source
var CommandDescribeImage = &cli.Command{
	Name:    "describe",
	Aliases: []string{"d"},
	Usage:   "Show details about image, including dependencies",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "image",
			Usage:   "Specify the image to use",
			Aliases: []string{"i"},
		},
		&formatter.FormatFlag,
	},
	Action: getImageDependency,
}
View Source
var CommandDestroy = &cli.Command{
	Name:     "destroy",
	Category: CategoryBasic,
	Aliases:  []string{"down", "d"},
	Usage:    "Destroy the envd environment",
	Flags: []cli.Flag{
		&cli.PathFlag{
			Name:        "path",
			Usage:       "Path to the directory containing the build.envd",
			Aliases:     []string{"p"},
			DefaultText: "current directory",
		},
		&cli.PathFlag{
			Name:    "name",
			Usage:   "Name of the environment or container ID",
			Aliases: []string{"n"},
		},
	},

	Action: destroy,
}
View Source
var CommandEnvironment = &cli.Command{
	Name:     "envs",
	Category: CategoryManagement,
	Aliases:  []string{"env", "e"},
	Usage:    "Manage envd environments",

	Subcommands: []*cli.Command{
		CommandDescribeEnvironment,
		CommandListEnv,
	},
}
View Source
var CommandImage = &cli.Command{
	Name:     "images",
	Category: CategoryManagement,
	Aliases:  []string{"image"},
	Usage:    "Manage envd images",

	Subcommands: []*cli.Command{
		CommandDescribeImage,
		CommandListImage,
		CommandPruneImages,
		CommandRemoveImage,
	},
}
View Source
var CommandInit = &cli.Command{
	Name:     "init",
	Category: CategoryBasic,
	Aliases:  []string{"i"},
	Usage:    "Automatically generate the build.envd",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "lang",
			Usage:    "language usage. Support Python, R, Julia",
			Aliases:  []string{"l"},
			Required: false,
		},
		&cli.BoolFlag{
			Name:     "force",
			Usage:    "overwrite the build.envd if existed",
			Aliases:  []string{"f"},
			Required: false,
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Path to the directory containing the build.envd",
			Aliases: []string{"p"},
			Value:   ".",
		},
	},
	Action: initCommand,
}
View Source
var CommandListEnv = &cli.Command{
	Name:    "list",
	Aliases: []string{"ls", "l"},
	Usage:   "List envd environments",
	Flags: []cli.Flag{
		&formatter.FormatFlag,
	},
	Action: getEnvironment,
}
View Source
var CommandListImage = &cli.Command{
	Name:    "list",
	Aliases: []string{"ls", "l"},
	Usage:   "List envd images",
	Flags: []cli.Flag{
		&formatter.FormatFlag,
	},
	Action: getImage,
}
View Source
var CommandLogin = &cli.Command{
	Name:     "login",
	Category: CategoryManagement,
	Hidden:   false,
	Usage:    "Login to the envd server defined in the current context",
	Action:   login,
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:     "username",
			Usage:    "the login name in envd server",
			Aliases:  []string{"u"},
			Required: false,
		},
		&cli.StringFlag{
			Name:     "password",
			Usage:    "password",
			Aliases:  []string{"p"},
			Required: false,
		},
	},
}
View Source
var CommandPause = &cli.Command{
	Name:     "pause",
	Category: CategoryExpert,
	Aliases:  []string{"p"},
	Usage:    "Pause the envd environment",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "env",
			Usage:   "Environment name",
			Aliases: []string{"e"},
		},
	},

	Action: pause,
}
View Source
var CommandPrune = &cli.Command{
	Name:     "prune",
	Category: CategorySettings,
	Usage:    "Clean up the build cache",
	Flags: []cli.Flag{
		&cli.DurationFlag{
			Name:  "keep-duration",
			Usage: "Keep data newer than this limit",
		},
		&cli.Float64Flag{
			Name:  "keep-storage",
			Usage: "Keep data below this limit (in MB)",
		},
		&cli.StringSliceFlag{
			Name:   "filter, f",
			Usage:  "Filter records",
			Hidden: true,
		},
		&cli.BoolFlag{
			Name:  "all",
			Usage: "Include internal caches (oh-my-zsh, vscode extensions and other envd caches)",
		},
		&cli.BoolFlag{
			Name:  "verbose, v",
			Usage: "Verbose output",
		},
	},

	Action: prune,
}
View Source
var CommandPruneImages = &cli.Command{
	Name:   "prune",
	Usage:  "Remove unused images",
	Action: pruneImages,
}
View Source
var CommandRemoveImage = &cli.Command{
	Name:    "remove",
	Aliases: []string{"r", "rm"},
	Usage:   "Remove an envd image",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "image",
			Usage:   "Specify the image name to be removed",
			Aliases: []string{"i"},
		},
		&cli.StringFlag{
			Name:        "tag",
			Usage:       "Remove the image with a specific tag",
			Aliases:     []string{"t"},
			DefaultText: "dev",
		},
	},
	Action: removeImage,
}
View Source
var CommandResume = &cli.Command{
	Name:     "resume",
	Category: CategoryExpert,
	Aliases:  []string{"r"},
	Usage:    "Resume the envd environment",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:    "env",
			Usage:   "Environment name",
			Aliases: []string{"e"},
		},
	},

	Action: resume,
}
View Source
var CommandRun = &cli.Command{
	Name:     "exec",
	Category: CategoryExpert,
	Usage:    "Spawns a command installed into the environment.",
	Flags: []cli.Flag{
		&cli.PathFlag{
			Name:    "name",
			Usage:   "Name of the environment",
			Aliases: []string{"n"},
		},
		&cli.StringFlag{
			Name:    "command",
			Usage:   "Command defined in build.envd to execute",
			Aliases: []string{"c"},
		},
		&cli.PathFlag{
			Name:    "from",
			Usage:   "Function to execute, format `file:func`",
			Aliases: []string{"f"},
			Value:   "build.envd:build",
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Path to the directory containing the build.envd",
			Aliases: []string{"p"},
			Value:   ".",
		},
		&cli.StringFlag{
			Name:    "raw",
			Usage:   "Raw command to execute",
			Aliases: []string{"r"},
		},
	},

	Action: exec,
}
View Source
var CommandTop = &cli.Command{
	Name:     "top",
	Category: CategoryManagement,
	Usage:    "Show statistics about the containers managed by the environment.",
	Flags:    []cli.Flag{},
	Action:   top,
}
View Source
var CommandUp = &cli.Command{
	Name:     "up",
	Category: CategoryBasic,
	Aliases:  []string{"u"},
	Usage:    "Build and run the envd environment",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:        "tag",
			Usage:       "Name and optionally a tag in the 'name:tag' format",
			Aliases:     []string{"t"},
			DefaultText: "PROJECT:dev",
		},
		&cli.StringFlag{
			Name:  "name",
			Usage: "environment name",
			Value: "",
		},
		&cli.PathFlag{
			Name:    "path",
			Usage:   "Path to the directory containing the build.envd",
			Aliases: []string{"p"},
			Value:   ".",
		},
		&cli.StringSliceFlag{
			Name:    "volume",
			Usage:   "Mount host directory into container",
			Aliases: []string{"v"},
		},
		&cli.PathFlag{
			Name:    "from",
			Usage:   "Function to execute, format `file:func`",
			Aliases: []string{"f"},
			Value:   "build.envd:build",
		},
		&cli.BoolFlag{
			Name:    "use-proxy",
			Usage:   "Use HTTPS_PROXY/HTTP_PROXY/NO_PROXY in the build process",
			Aliases: []string{"proxy"},
			Value:   false,
		},
		&cli.PathFlag{
			Name:    "private-key",
			Usage:   "Path to the private key",
			Aliases: []string{"k"},
			Value:   sshconfig.GetPrivateKeyOrPanic(),
			Hidden:  true,
		},
		&cli.PathFlag{
			Name:    "public-key",
			Usage:   "Path to the public key",
			Aliases: []string{"pubk"},
			Value:   sshconfig.GetPublicKeyOrPanic(),
			Hidden:  true,
		},
		&cli.DurationFlag{
			Name:  "timeout",
			Usage: "Timeout of container creation",
			Value: time.Second * 30,
		},
		&cli.IntFlag{
			Name:  "shm-size",
			Usage: "Configure the shared memory size (megabyte)",
			Value: 2048,
		},
		&cli.StringFlag{
			Name:  "cpus",
			Usage: "Request CPU resources (number of cores), such as 0.5, 1, 2",
			Value: "",
		},
		&cli.StringFlag{
			Name:  "cpu-set",
			Usage: "Limit the specific CPUs or cores the environment can use, such as `0-3`, `1,3`",
			Value: "",
		},
		&cli.StringFlag{
			Name:  "memory",
			Usage: "Request Memory, such as 512Mb, 2Gb",
			Value: "",
		},
		&cli.BoolFlag{
			Name:  "detach",
			Usage: "Detach from the container",
			Value: false,
		},
		&cli.BoolFlag{
			Name:  "no-gpu",
			Usage: "Launch the CPU container",
			Value: false,
		},
		&cli.BoolFlag{
			Name:  "force",
			Usage: "Force rebuild and run the container although the previous container is running",
			Value: false,
		},
		&cli.StringFlag{
			Name:  "host",
			Usage: "Assign the host address for environment ssh acesss server listening",
			Value: envd.Localhost,
		},

		&cli.StringFlag{
			Name:    "export-cache",
			Usage:   "Export the cache (e.g. type=registry,ref=<image>)",
			Aliases: []string{"ec"},
		},
		&cli.StringFlag{
			Name:    "import-cache",
			Usage:   "Import the cache (e.g. type=registry,ref=<image>)",
			Aliases: []string{"ic"},
		},
		&cli.StringFlag{
			Name:        "platform",
			Usage:       "Specify the target platform for the build output, (for example, windows/amd64, linux/amd64, or darwin/arm64)",
			DefaultText: runtimeutil.GetRuntimePlatform(),
		},
	},

	Action: up,
}
View Source
var CommandVersion = &cli.Command{
	Name:     "version",
	Category: CategoryOther,
	Aliases:  []string{"v"},
	Usage:    "Print envd version information",
	Flags: []cli.Flag{
		&cli.BoolFlag{
			Name:    "short",
			Usage:   "Only print the version number",
			Value:   false,
			Aliases: []string{"s"},
		},
		&cli.BoolFlag{
			Name:    "detail",
			Usage:   "Print details about the envd environment",
			Value:   false,
			Aliases: []string{"d"},
		},
		&formatter.FormatFlag,
	},
	Action: outputVersion,
}
View Source
var CudaChoice = input{
	// contains filtered or unexported fields
}
View Source
var CudaVersionChoice = input{
	// contains filtered or unexported fields
}
View Source
var JupyterChoice = input{
	// contains filtered or unexported fields
}
View Source
var LanguageChoice = input{
	// contains filtered or unexported fields
}
View Source
var PythonPackageChoice = input{
	// contains filtered or unexported fields
}
View Source
var RPackageChoice = input{
	// contains filtered or unexported fields
}

Functions

func InitModel added in v0.2.6

func InitModel(input input) model

func InitPythonEnv added in v0.2.6

func InitPythonEnv(dir string) error

Types

type EnvdApp

type EnvdApp struct {
	cli.App
}

func New

func New() EnvdApp

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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