Documentation ¶
Overview ¶
Copyright 2023 Google LLC
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Index ¶
- Constants
- func BuilHostIndexURL(rootEndpoint, host string) string
- func BuildCVDLogsURL(rootEndpoint, host, cvd string) string
- func BuildRootEndpoint(serviceURL, version, zone string) string
- type ApiCallError
- type AuthnOpts
- type ConnectWebRTCOpts
- type ExpBackOffOptions
- type FilesUploader
- type HTTPBasic
- 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) ConnectWebRTC(device string, observer wclient.Observer, logger io.Writer, ...) (*wclient.Connection, error)
- func (c *HostOrchestratorServiceImpl) CreateCVD(req *hoapi.CreateCVDRequest, creds string) (*hoapi.CreateCVDResponse, error)
- func (c *HostOrchestratorServiceImpl) CreateCVDOp(req *hoapi.CreateCVDRequest, creds string) (*hoapi.Operation, error)
- func (c *HostOrchestratorServiceImpl) CreateUploadDir() (string, error)
- func (c *HostOrchestratorServiceImpl) DeleteCVD(id string) error
- func (c *HostOrchestratorServiceImpl) DownloadRuntimeArtifacts(dst io.Writer) error
- func (c *HostOrchestratorServiceImpl) ExtractFile(uploadDir string, filename string) (*hoapi.Operation, error)
- func (c *HostOrchestratorServiceImpl) FetchArtifacts(req *hoapi.FetchArtifactsRequest, creds string) (*hoapi.FetchArtifactsResponse, error)
- func (c *HostOrchestratorServiceImpl) ListCVDs() ([]*hoapi.CVD, 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 OIDCToken
- type RetryOptions
- type Service
- type ServiceBuilder
- type ServiceOptions
- type UploadOptions
Constants ¶
const (
// Value to pass as credentials to the Host Orchestrator service endpoints. Any non-empty value is enough.
InjectedCredentials = "inject"
)
Variables ¶
This section is empty.
Functions ¶
func BuilHostIndexURL ¶
func BuildCVDLogsURL ¶
func BuildRootEndpoint ¶
Types ¶
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
func (*ApiCallError) Is ¶
func (e *ApiCallError) Is(target error) bool
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, buildAPICredentials string) (*hoapi.CreateCVDResponse, error) CreateCVDOp(req *hoapi.CreateCVDRequest, buildAPICredentials string) (*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, buildAPICredentials string) (*hoapi.FetchArtifactsResponse, error) // Downloads runtime artifacts tar file into `dst`. DownloadRuntimeArtifacts(dst io.Writer) 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) // Wait for an operation, `result` will be populated with the relevant operation's result object. WaitForOperation(name string, result any) 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 BuildAPICredentialsHeader string }
func (*HostOrchestratorServiceImpl) ConnectWebRTC ¶
func (c *HostOrchestratorServiceImpl) ConnectWebRTC(device string, observer wclient.Observer, logger io.Writer, opts ConnectWebRTCOpts) (*wclient.Connection, error)
func (*HostOrchestratorServiceImpl) CreateCVD ¶
func (c *HostOrchestratorServiceImpl) CreateCVD(req *hoapi.CreateCVDRequest, creds string) (*hoapi.CreateCVDResponse, error)
func (*HostOrchestratorServiceImpl) CreateCVDOp ¶
func (c *HostOrchestratorServiceImpl) CreateCVDOp(req *hoapi.CreateCVDRequest, creds string) (*hoapi.Operation, error)
func (*HostOrchestratorServiceImpl) CreateUploadDir ¶
func (c *HostOrchestratorServiceImpl) CreateUploadDir() (string, error)
func (*HostOrchestratorServiceImpl) DeleteCVD ¶
func (c *HostOrchestratorServiceImpl) DeleteCVD(id string) error
func (*HostOrchestratorServiceImpl) DownloadRuntimeArtifacts ¶
func (c *HostOrchestratorServiceImpl) DownloadRuntimeArtifacts(dst io.Writer) error
func (*HostOrchestratorServiceImpl) ExtractFile ¶
func (*HostOrchestratorServiceImpl) FetchArtifacts ¶
func (c *HostOrchestratorServiceImpl) FetchArtifacts(req *hoapi.FetchArtifactsRequest, creds string) (*hoapi.FetchArtifactsResponse, error)
func (*HostOrchestratorServiceImpl) ListCVDs ¶
func (c *HostOrchestratorServiceImpl) ListCVDs() ([]*hoapi.CVD, 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 Service ¶
type Service interface { CreateHost(req *apiv1.CreateHostRequest) (*apiv1.HostInstance, error) ListHosts() (*apiv1.ListHostsResponse, error) DeleteHosts(names []string) error HostService(host string) HostOrchestratorService RootURI() string }
func NewService ¶
func NewService(opts *ServiceOptions) (Service, error)
type ServiceBuilder ¶
type ServiceBuilder func(opts *ServiceOptions) (Service, error)
type ServiceOptions ¶
type UploadOptions ¶
type UploadOptions struct { BackOffOpts ExpBackOffOptions ChunkSizeBytes int64 NumWorkers int }
func DefaultUploadOptions ¶
func DefaultUploadOptions() UploadOptions