Documentation ¶
Overview ¶
Package metaservice implements the meta-data service that the guests use to talk to the host.
The meta-data service is exposed to the guest on 169.254.169.254:80. This is how the command and environment variables enter the virtual machine. It is also the services that the guest uses to report logs and final result.
Index ¶
- Constants
- type Action
- type Error
- type Execute
- type Files
- type MetaService
- func (s *MetaService) ExecShell(command []string, tty bool) (engines.Shell, error)
- func (s *MetaService) GetArtifact(path string) (ioext.ReadSeekCloser, error)
- func (s *MetaService) KillProcess() error
- func (s *MetaService) ListFolder(path string) ([]string, error)
- func (s *MetaService) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (s *MetaService) StopPollers()
Constants ¶
const ( ErrorCodeMethodNotAllowed = "MethodNotAllowed" ErrorCodeNoSuchEndPoint = "NoSuchEndPoint" ErrorCodeInternalError = "InternalError" ErrorCodeResourceConflict = "ResourceConflict" ErrorCodeUnknownActionID = "UnknownActionId" ErrorCodeInvalidPayload = "InvalidPayload" )
List of API error codes for using the Error struct.
const PollTimeout = 30 * time.Second
PollTimeout is the maximum amount of time a poll request will be left hanging before getting a response (even if the response is none).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Action ¶
type Action struct { ID string `json:"id"` // id, to be used when replying Type string `json:"type"` // none, get-artifact, list-folder, exec-shell, kill-process Path string `json:"path"` // file path, if get-artifact/list-folder Command []string `json:"command"` // Command for exec-shell TTY bool `json:"tty"` // TTY or not for exec-shell }
Action is the response payload for the /engine/v1/poll end-point.
type Files ¶
type Files struct { Files []string `json:"files"` // List of absolute file paths NotFound bool `json:"notFound"` // true, if path doesn't exist }
Files is the request payload for the /engine/v1/list-folder end-point.
type MetaService ¶
type MetaService struct {
// contains filtered or unexported fields
}
MetaService implements the meta-data service that communicates worker process running inside the virtual machine. This is how the command to run gets into the virtual machine, and how logs and artifacts are copied out.
func New ¶
func New( command []string, env map[string]string, logDrain io.Writer, resultCallback func(bool), environment *runtime.Environment, ) *MetaService
New returns a new MetaService that will tell the virtual machine to run command, with environment variables env. It will write the logs to logDrain.
The callback resultCallback will be called when the guest reports that the command is done.
func (*MetaService) ExecShell ¶
ExecShell will send an action to guest-tools to execute a shell, then wait for guest-tools to callback establish a websocket and connect to an implementation of engines.Shell
func (*MetaService) GetArtifact ¶
func (s *MetaService) GetArtifact(path string) (ioext.ReadSeekCloser, error)
GetArtifact will tell polling guest-tools to send a given artifact.
func (*MetaService) KillProcess ¶ added in v0.1.0
func (s *MetaService) KillProcess() error
KillProcess will send an action to guest-tools to kill the process executing the main command.
Note: For robustness this shouldn't be relied upon.
func (*MetaService) ListFolder ¶
func (s *MetaService) ListFolder(path string) ([]string, error)
ListFolder the contents of a folder (recursively)
func (*MetaService) ServeHTTP ¶
func (s *MetaService) ServeHTTP(w http.ResponseWriter, r *http.Request)
ServeHTTP handles request to the meta-data service.
func (*MetaService) StopPollers ¶
func (s *MetaService) StopPollers()
StopPollers will stop all polling requests. This is only used for testing, where it is important that clients stop polling or we can't Close the server.