MCPcopy Index your code
hub / github.com/rilldata/rill / CheckProvisionerResource

Method CheckProvisionerResource

admin/deployments.go:556–609  ·  view source on GitHub ↗
(ctx context.Context, pr *database.ProvisionerResource, annotations DeploymentAnnotations)

Source from the content-addressed store, hash-verified

554}
555
556func (s *Service) CheckProvisionerResource(ctx context.Context, pr *database.ProvisionerResource, annotations DeploymentAnnotations) error {
557 // Find the provisioner
558 p, ok := s.ProvisionerSet[pr.Provisioner]
559 if !ok {
560 return fmt.Errorf("provisioner: %q is not in the provisioner set", pr.Provisioner)
561 }
562
563 // Run a check
564 r := &provisioner.Resource{
565 ID: pr.ID,
566 Type: provisioner.ResourceType(pr.Type),
567 State: pr.State,
568 Config: pr.Config,
569 }
570 r, err := p.CheckResource(ctx, r, &provisioner.ResourceOptions{
571 Args: pr.Args,
572 Annotations: annotations.ToMap(),
573 RillVersion: s.resolveRillVersion(),
574 })
575 if err != nil {
576 // For cancellations, we exit early without updating the status in the DB
577 if errors.Is(err, ctx.Err()) {
578 return err
579 }
580
581 // Set the status as errored
582 _, err2 := s.DB.UpdateProvisionerResource(ctx, pr.ID, &database.UpdateProvisionerResourceOptions{
583 Status: database.ProvisionerResourceStatusError,
584 StatusMessage: fmt.Sprintf("check failed: %s", err.Error()),
585 Args: pr.Args,
586 State: pr.State,
587 Config: pr.Config,
588 })
589 if err2 != nil {
590 return errors.Join(err, err2)
591 }
592
593 return err
594 }
595
596 // The returned resource's state may have been updated, so we update the database accordingly.
597 _, err = s.DB.UpdateProvisionerResource(ctx, pr.ID, &database.UpdateProvisionerResourceOptions{
598 Status: database.ProvisionerResourceStatusOK,
599 StatusMessage: "",
600 Args: pr.Args,
601 State: r.State,
602 Config: r.Config,
603 })
604 if err != nil {
605 return err
606 }
607
608 return nil
609}
610
611func (s *Service) OpenRuntimeClient(depl *database.Deployment) (*client.Client, error) {
612 if depl.RuntimeHost == "" {

Callers 1

Calls 8

resolveRillVersionMethod · 0.95
ResourceTypeTypeAlias · 0.92
ToMapMethod · 0.80
ErrorfMethod · 0.65
CheckResourceMethod · 0.65
ErrMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected