1 package remotecmd 2 3 // RemoteProcessStatus is an enum type for representing process statuses. 4 type RemoteProcessStatus string 5 6 const ( 7 // Unknown represents a process for which the status cannot be determined reliably or is not handled yet by us. 8 Unknown RemoteProcessStatus = "unknown" 9 10 // Starting represents a process that is just about to start. 11 Starting = "starting" 12 13 // Stopped represents a process stopped. 14 Stopped = "stopped" 15 16 // Errored represents a process that errored out, i.e. exited with a non-zero status code. 17 Errored = "errored" 18 19 // Running represents a running process. 20 Running = "running" 21 ) 22 23 const ( 24 // ShellExecutable is the shell executable 25 ShellExecutable = "/bin/sh" 26 ) 27 28 // RemoteProcessInfo represents a given remote process linked to a given Devfile command 29 type RemoteProcessInfo struct { 30 // Pid of the process 31 Pid int 32 33 // Status of the process 34 Status RemoteProcessStatus 35 } 36 37 // CommandDefinition represents the structure of any given command that would be handled by implementations of RemoteProcessHandler. 38 type CommandDefinition struct { 39 // Id is any unique (and short) identifier that helps manage the process associated to this command. 40 Id string 41 42 // PidDirectory is the directory where the PID file for this process will be stored. 43 // The directory needs to be present in the remote container and be writable by the user (in the container) executing the command. 44 PidDirectory string 45 46 // WorkingDir is the working directory from which the command should get executed. 47 WorkingDir string 48 49 // EnvVars are environment variables to set. 50 EnvVars []CommandEnvVar 51 52 // CmdLine is the command-line that will get executed. 53 CmdLine string 54 } 55 56 // CommandEnvVar represents an environment variable used as part of running any CommandDefinition. 57 type CommandEnvVar struct { 58 59 // Key of the environment variable. 60 Key string 61 62 // Value of the environment variable. 63 Value string 64 } 65 66 // CommandOutputHandler is a function that is expected to handle the output and error returned by a command executed. 67 type CommandOutputHandler func(status RemoteProcessStatus, stdout []string, stderr []string, err error) 68