Documentation ¶
Index ¶
- Constants
- type AccessTokenBuildAPICreds
- type ApiCallError
- type BuildAPICreds
- type ConnectWebRTCOpts
- type ExpBackOffOptions
- type FilesUploader
- type HTTPHelper
- func (h *HTTPHelper) NewDeleteRequest(path string) *HTTPRequestBuilder
- func (h *HTTPHelper) NewGetRequest(path string) *HTTPRequestBuilder
- func (h *HTTPHelper) NewPostRequest(path string, jsonBody any) *HTTPRequestBuilder
- func (h *HTTPHelper) NewUploadFileRequest(ctx context.Context, path string, body io.Reader, contentType string) *HTTPRequestBuilder
- type HTTPRequestBuilder
- func (rb *HTTPRequestBuilder) AddHeader(key, value string)
- func (rb *HTTPRequestBuilder) Do() (*http.Response, error)
- func (rb *HTTPRequestBuilder) JSONResDo(ret any) error
- func (rb *HTTPRequestBuilder) JSONResDoWithRetries(ret any, retryOpts RetryOptions) error
- func (rb *HTTPRequestBuilder) SetBasicAuth()
- func (rb *HTTPRequestBuilder) SetHeader(key, value string)
- type HostOrchestratorService
- type HostOrchestratorServiceImpl
- func (c *HostOrchestratorServiceImpl) ConnectADBWebSocket(device string) (*websocket.Conn, error)
- func (c *HostOrchestratorServiceImpl) ConnectWebRTC(device string, observer wclient.Observer, logger io.Writer, ...) (*wclient.Connection, error)
- func (c *HostOrchestratorServiceImpl) CreateBugreport(group string, dst io.Writer) error
- func (c *HostOrchestratorServiceImpl) CreateCVD(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.CreateCVDResponse, error)
- func (c *HostOrchestratorServiceImpl) CreateCVDOp(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.Operation, error)
- func (c *HostOrchestratorServiceImpl) CreateSnapshot(groupName, instanceName string) (*hoapi.CreateSnapshotResponse, error)
- func (c *HostOrchestratorServiceImpl) CreateUploadDir() (string, error)
- func (c *HostOrchestratorServiceImpl) DeleteCVD(id string) error
- func (c *HostOrchestratorServiceImpl) ExtractFile(uploadDir string, filename string) (*hoapi.Operation, error)
- func (c *HostOrchestratorServiceImpl) FetchArtifacts(req *hoapi.FetchArtifactsRequest, creds BuildAPICreds) (*hoapi.FetchArtifactsResponse, error)
- func (c *HostOrchestratorServiceImpl) ListCVDs() ([]*hoapi.CVD, error)
- func (c *HostOrchestratorServiceImpl) Powerwash(groupName, instanceName string) error
- func (c *HostOrchestratorServiceImpl) Start(groupName, instanceName string, req *hoapi.StartCVDRequest) error
- func (c *HostOrchestratorServiceImpl) Stop(groupName, instanceName string) error
- func (c *HostOrchestratorServiceImpl) UploadFile(uploadDir string, filename string) error
- func (c *HostOrchestratorServiceImpl) UploadFileWithOptions(uploadDir string, filename string, uploadOpts UploadOptions) error
- func (c *HostOrchestratorServiceImpl) WaitForOperation(name string, res any) error
- type RetryOptions
- type UploadOptions
Constants ¶
View Source
const ( HTTPHeaderBuildAPICreds = "X-Cutf-Host-Orchestrator-BuildAPI-Creds" HTTPHeaderBuildAPICredsUserProjectID = "X-Cutf-Host-Orchestrator-BuildAPI-Creds-User-Project-ID" // If used, the Cloud Orchestrator proxy would set/override the "X-Cutf-Host-Orchestrator-BuildAPI-Creds" // http header. HTTPHeaderCOInjectBuildAPICreds = "X-Cutf-Cloud-Orchestrator-Inject-BuildAPI-Creds" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenBuildAPICreds ¶
func (*AccessTokenBuildAPICreds) ApplyToHTTPRequest ¶
func (c *AccessTokenBuildAPICreds) ApplyToHTTPRequest(rb *HTTPRequestBuilder)
type ApiCallError ¶
type ApiCallError struct { Code int `json:"code,omitempty"` ErrorMsg string `json:"error,omitempty"` Details string `json:"details,omitempty"` }
func (*ApiCallError) Error ¶
func (e *ApiCallError) Error() string
type BuildAPICreds ¶
type BuildAPICreds interface {
ApplyToHTTPRequest(rb *HTTPRequestBuilder)
}
type ConnectWebRTCOpts ¶
type ExpBackOffOptions ¶
type FilesUploader ¶
type FilesUploader struct { HTTPHelper HTTPHelper UploadDir string DumpOut io.Writer UploadOptions }
func (*FilesUploader) Upload ¶
func (u *FilesUploader) Upload(files []string) error
type HTTPHelper ¶
type HTTPHelper struct { Client *http.Client RootEndpoint string Dumpster io.Writer AccessToken string HTTPBasicUsername string }
func (*HTTPHelper) NewDeleteRequest ¶
func (h *HTTPHelper) NewDeleteRequest(path string) *HTTPRequestBuilder
func (*HTTPHelper) NewGetRequest ¶
func (h *HTTPHelper) NewGetRequest(path string) *HTTPRequestBuilder
func (*HTTPHelper) NewPostRequest ¶
func (h *HTTPHelper) NewPostRequest(path string, jsonBody any) *HTTPRequestBuilder
func (*HTTPHelper) NewUploadFileRequest ¶
func (h *HTTPHelper) NewUploadFileRequest(ctx context.Context, path string, body io.Reader, contentType string) *HTTPRequestBuilder
type HTTPRequestBuilder ¶
type HTTPRequestBuilder struct {
// contains filtered or unexported fields
}
func (*HTTPRequestBuilder) AddHeader ¶
func (rb *HTTPRequestBuilder) AddHeader(key, value string)
func (*HTTPRequestBuilder) JSONResDo ¶
func (rb *HTTPRequestBuilder) JSONResDo(ret any) error
Expects a response with JSON body to be decoded into `ret`.
func (*HTTPRequestBuilder) JSONResDoWithRetries ¶
func (rb *HTTPRequestBuilder) JSONResDoWithRetries(ret any, retryOpts RetryOptions) error
Expects a response with JSON body to be decoded into `ret`.
func (*HTTPRequestBuilder) SetBasicAuth ¶
func (rb *HTTPRequestBuilder) SetBasicAuth()
func (*HTTPRequestBuilder) SetHeader ¶
func (rb *HTTPRequestBuilder) SetHeader(key, value string)
type HostOrchestratorService ¶
type HostOrchestratorService interface { // Lists currently running devices. ListCVDs() ([]*hoapi.CVD, error) // Creates a directory in the host where user artifacts can be uploaded to. CreateUploadDir() (string, error) // Uploads file into the given directory. UploadFile(uploadDir string, filename string) error UploadFileWithOptions(uploadDir string, filename string, options UploadOptions) error // Extracts a compressed file. ExtractFile(uploadDir string, filename string) (*hoapi.Operation, error) // Create a new device with artifacts from the build server or previously uploaded by the user. // If not empty, the provided credentials will be used to download necessary artifacts from the build api. CreateCVD(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.CreateCVDResponse, error) CreateCVDOp(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.Operation, error) // Deletes an existing cvd instance. DeleteCVD(id string) error // Calls cvd fetch in the remote host, the downloaded artifacts can be used to create a CVD later. // If not empty, the provided credentials will be used by the host orchestrator to access the build api. FetchArtifacts(req *hoapi.FetchArtifactsRequest, creds BuildAPICreds) (*hoapi.FetchArtifactsResponse, error) // Creates a webRTC connection to a device running in this host. ConnectWebRTC(device string, observer wclient.Observer, logger io.Writer, opts ConnectWebRTCOpts) (*wclient.Connection, error) // Connect to ADB WebSocket endpoint. ConnectADBWebSocket(device string) (*websocket.Conn, error) // Wait for an operation, `result` will be populated with the relevant operation's result object. WaitForOperation(name string, result any) error // Create cvd bugreport. CreateBugreport(group string, dst io.Writer) error // Powerwash the device. Powerwash(groupName, instanceName string) error // Stop the device. Stop(groupName, instanceName string) error // Start the device. Start(groupName, instanceName string, req *hoapi.StartCVDRequest) error // Create device snapshot. CreateSnapshot(groupName, instanceName string) (*hoapi.CreateSnapshotResponse, error) }
A client to the host orchestrator service running in a remote host.
func NewHostOrchestratorService ¶
func NewHostOrchestratorService(url string) HostOrchestratorService
type HostOrchestratorServiceImpl ¶
type HostOrchestratorServiceImpl struct { HTTPHelper HTTPHelper ProxyURL string }
func (*HostOrchestratorServiceImpl) ConnectADBWebSocket ¶
func (c *HostOrchestratorServiceImpl) ConnectADBWebSocket(device string) (*websocket.Conn, error)
func (*HostOrchestratorServiceImpl) ConnectWebRTC ¶
func (c *HostOrchestratorServiceImpl) ConnectWebRTC(device string, observer wclient.Observer, logger io.Writer, opts ConnectWebRTCOpts) (*wclient.Connection, error)
func (*HostOrchestratorServiceImpl) CreateBugreport ¶
func (c *HostOrchestratorServiceImpl) CreateBugreport(group string, dst io.Writer) error
func (*HostOrchestratorServiceImpl) CreateCVD ¶
func (c *HostOrchestratorServiceImpl) CreateCVD(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.CreateCVDResponse, error)
func (*HostOrchestratorServiceImpl) CreateCVDOp ¶
func (c *HostOrchestratorServiceImpl) CreateCVDOp(req *hoapi.CreateCVDRequest, creds BuildAPICreds) (*hoapi.Operation, error)
func (*HostOrchestratorServiceImpl) CreateSnapshot ¶
func (c *HostOrchestratorServiceImpl) CreateSnapshot(groupName, instanceName string) (*hoapi.CreateSnapshotResponse, error)
func (*HostOrchestratorServiceImpl) CreateUploadDir ¶
func (c *HostOrchestratorServiceImpl) CreateUploadDir() (string, error)
func (*HostOrchestratorServiceImpl) DeleteCVD ¶
func (c *HostOrchestratorServiceImpl) DeleteCVD(id string) error
func (*HostOrchestratorServiceImpl) ExtractFile ¶
func (*HostOrchestratorServiceImpl) FetchArtifacts ¶
func (c *HostOrchestratorServiceImpl) FetchArtifacts(req *hoapi.FetchArtifactsRequest, creds BuildAPICreds) (*hoapi.FetchArtifactsResponse, error)
func (*HostOrchestratorServiceImpl) ListCVDs ¶
func (c *HostOrchestratorServiceImpl) ListCVDs() ([]*hoapi.CVD, error)
func (*HostOrchestratorServiceImpl) Powerwash ¶
func (c *HostOrchestratorServiceImpl) Powerwash(groupName, instanceName string) error
func (*HostOrchestratorServiceImpl) Start ¶
func (c *HostOrchestratorServiceImpl) Start(groupName, instanceName string, req *hoapi.StartCVDRequest) error
func (*HostOrchestratorServiceImpl) Stop ¶
func (c *HostOrchestratorServiceImpl) Stop(groupName, instanceName string) error
func (*HostOrchestratorServiceImpl) UploadFile ¶
func (c *HostOrchestratorServiceImpl) UploadFile(uploadDir string, filename string) error
func (*HostOrchestratorServiceImpl) UploadFileWithOptions ¶
func (c *HostOrchestratorServiceImpl) UploadFileWithOptions(uploadDir string, filename string, uploadOpts UploadOptions) error
func (*HostOrchestratorServiceImpl) WaitForOperation ¶
func (c *HostOrchestratorServiceImpl) WaitForOperation(name string, res any) error
type RetryOptions ¶
type UploadOptions ¶
type UploadOptions struct { BackOffOpts ExpBackOffOptions ChunkSizeBytes int64 NumWorkers int }
func DefaultUploadOptions ¶
func DefaultUploadOptions() UploadOptions
Click to show internal directories.
Click to hide internal directories.