update backend proxy endpoint when overridden (#125)

This commit is contained in:
Michael Quigley 2022-12-02 16:18:28 -05:00
parent 135fd483fa
commit 7458c625aa
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 19 additions and 0 deletions

View File

@ -98,6 +98,23 @@ func (cmd *shareReservedCommand) run(_ *cobra.Command, args []string) {
}
logrus.Infof("sharing target endpoint: '%v'", cfg.EndpointAddress)
if resp.Payload.BackendProxyEndpoint != targetEndpoint {
upReq := service.NewUpdateShareParams()
upReq.Body = &rest_model_zrok.UpdateShareRequest{
ServiceToken: svcToken,
BackendProxyEndpoint: targetEndpoint,
}
if _, err := zrok.Service.UpdateShare(upReq, auth); err != nil {
if !panicInstead {
showError("unable to update backend proxy endpoint", err)
}
panic(err)
}
logrus.Infof("updated backend proxy endpoint to: %v", targetEndpoint)
} else {
logrus.Infof("using existing backend proxy endpoint: %v", targetEndpoint)
}
httpProxy, err := backend.NewHTTP(cfg)
if err != nil {
ui.Close()

View File

@ -15,6 +15,8 @@ func newShareHandler() *shareHandler {
}
func (h *shareHandler) Handle(params service.ShareParams, principal *rest_model_zrok.Principal) middleware.Responder {
logrus.Infof("handling")
tx, err := str.Begin()
if err != nil {
logrus.Errorf("error starting transaction: %v", err)