From 887e7caadfa690bf1cc0fd6e0c144bfb4347a9d8 Mon Sep 17 00:00:00 2001 From: "Jorge E. Moreira" Date: Mon, 23 Oct 2023 17:08:17 -0700 Subject: [PATCH] Host orchestrator client depends only on HO api --- pkg/client/client.go | 11 ----------- pkg/client/host_orchestrator_client.go | 23 ++++++++++++++++------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/pkg/client/client.go b/pkg/client/client.go index 2ac02365..130c0398 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -26,7 +26,6 @@ import ( apiv1 "github.com/google/cloud-android-orchestration/api/v1" "github.com/hashicorp/go-multierror" - "github.com/pion/webrtc/v3" ) type OpTimeoutError string @@ -150,16 +149,6 @@ func (c *serviceImpl) waitForOperation(op *apiv1.Operation, res any) error { return c.httpHelper.NewPostRequest(path, nil).Do(res) } -func asWebRTCICEServers(in []apiv1.IceServer) []webrtc.ICEServer { - out := []webrtc.ICEServer{} - for _, s := range in { - out = append(out, webrtc.ICEServer{ - URLs: s.URLs, - }) - } - return out -} - const headerNameCOInjectBuildAPICreds = "X-Cutf-Cloud-Orchestrator-Inject-BuildAPI-Creds" func (s *serviceImpl) RootURI() string { diff --git a/pkg/client/host_orchestrator_client.go b/pkg/client/host_orchestrator_client.go index 91104b1a..caed50f9 100644 --- a/pkg/client/host_orchestrator_client.go +++ b/pkg/client/host_orchestrator_client.go @@ -19,7 +19,6 @@ import ( "net/http" "time" - apiv1 "github.com/google/cloud-android-orchestration/api/v1" wclient "github.com/google/cloud-android-orchestration/pkg/webrtcclient" hoapi "github.com/google/android-cuttlefish/frontend/src/liboperator/api/v1" @@ -59,8 +58,8 @@ type hostOrchestratorServiceImpl struct { ChunkUploadBackOffOpts BackOffOpts } -func (c *hostOrchestratorServiceImpl) getInfraConfig() (*apiv1.InfraConfig, error) { - var res apiv1.InfraConfig +func (c *hostOrchestratorServiceImpl) getInfraConfig() (*hoapi.InfraConfig, error) { + var res hoapi.InfraConfig if err := c.httpHelper.NewGetRequest(fmt.Sprintf("/infra_config")).Do(&res); err != nil { return nil, err } @@ -167,7 +166,7 @@ func (c *hostOrchestratorServiceImpl) webRTCForward(srcCh chan any, connID strin close(stopPollCh) break } - forwardMsg := apiv1.ForwardMsg{Payload: msg} + forwardMsg := hoapi.ForwardMsg{Payload: msg} path := fmt.Sprintf("/polled_connections/%s/:forward", connID) i := 0 for ; i < maxConsecutiveErrors; i++ { @@ -186,9 +185,9 @@ func (c *hostOrchestratorServiceImpl) webRTCForward(srcCh chan any, connID strin } } -func (c *hostOrchestratorServiceImpl) createPolledConnection(device string) (*apiv1.NewConnReply, error) { - var res apiv1.NewConnReply - rb := c.httpHelper.NewPostRequest("/polled_connections", &apiv1.NewConnMsg{DeviceId: device}) +func (c *hostOrchestratorServiceImpl) createPolledConnection(device string) (*hoapi.NewConnReply, error) { + var res hoapi.NewConnReply + rb := c.httpHelper.NewPostRequest("/polled_connections", &hoapi.NewConnMsg{DeviceId: device}) if err := rb.Do(&res); err != nil { return nil, err } @@ -282,3 +281,13 @@ func (c *hostOrchestratorServiceImpl) UploadFiles(uploadDir string, filenames [] } return uploader.Upload(filenames) } + +func asWebRTCICEServers(in []hoapi.IceServer) []webrtc.ICEServer { + out := []webrtc.ICEServer{} + for _, s := range in { + out = append(out, webrtc.ICEServer{ + URLs: s.URLs, + }) + } + return out +}