mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-09-30 03:51:43 +02:00
* Introduce WebSocket-based RPC v2 * go test: add -ldflags="-B gobuildid" * No need to change the "controller.workerNotifier.Notify()" error message * No need to modify Protocol Buffers/gRPC generated code * rpcWatch(): explain that connection shouldn't be normally be closed * Avoid "port forwarding failed: " repetition in error messages * Improve comments and avoid repetition in IP resolution errors
32 lines
874 B
Go
32 lines
874 B
Go
package controller
|
|
|
|
import (
|
|
"github.com/cirruslabs/orchard/internal/controller/rendezvous"
|
|
"github.com/cirruslabs/orchard/internal/responder"
|
|
v1 "github.com/cirruslabs/orchard/pkg/resource/v1"
|
|
"github.com/gin-gonic/gin"
|
|
"net/http"
|
|
)
|
|
|
|
func (controller *Controller) rpcResolveIP(ctx *gin.Context) responder.Responder {
|
|
if responder := controller.authorize(ctx, v1.ServiceAccountRoleComputeWrite); responder != nil {
|
|
return responder
|
|
}
|
|
|
|
// Retrieve and parse path and query parameters
|
|
session := ctx.Query("session")
|
|
ip := ctx.Query("ip")
|
|
errorMessage := ctx.Query("errorMessage")
|
|
|
|
// Respond with the resolved IP address
|
|
_, err := controller.ipRendezvous.Respond(session, rendezvous.ResultWithErrorMessage[string]{
|
|
Result: ip,
|
|
ErrorMessage: errorMessage,
|
|
})
|
|
if err != nil {
|
|
return responder.Error(err)
|
|
}
|
|
|
|
return responder.Code(http.StatusOK)
|
|
}
|