(depl *database.Deployment)
| 609 | } |
| 610 | |
| 611 | func (s *Service) OpenRuntimeClient(depl *database.Deployment) (*client.Client, error) { |
| 612 | if depl.RuntimeHost == "" { |
| 613 | if depl.Status == database.DeploymentStatusErrored { |
| 614 | return nil, fmt.Errorf("%w: deployment %q has no runtime host: %s", ErrDeploymentNotReady, depl.ID, depl.StatusMessage) |
| 615 | } |
| 616 | return nil, fmt.Errorf("%w: deployment %q has no runtime host", ErrDeploymentNotReady, depl.ID) |
| 617 | } |
| 618 | |
| 619 | jwt, err := s.IssueRuntimeManagementToken(depl.RuntimeAudience) |
| 620 | if err != nil { |
| 621 | return nil, err |
| 622 | } |
| 623 | |
| 624 | rt, err := client.New(depl.RuntimeHost, jwt) |
| 625 | if err != nil { |
| 626 | return nil, err |
| 627 | } |
| 628 | |
| 629 | return rt, nil |
| 630 | } |
| 631 | |
| 632 | func (s *Service) IssueRuntimeManagementToken(aud string) (string, error) { |
| 633 | jwt, err := s.issuer.NewToken(auth.TokenOptions{ |
no test coverage detected