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

Method Create

runtime/controller.go:493–527  ·  view source on GitHub ↗

Create creates a resource and enqueues it for reconciliation. If a resource with the same name is currently being deleted, the deletion will be cancelled.

(ctx context.Context, name *runtimev1.ResourceName, refs []*runtimev1.ResourceName, owner *runtimev1.ResourceName, paths []string, hidden bool, r *runtimev1.Resource)

Source from the content-addressed store, hash-verified

491// Create creates a resource and enqueues it for reconciliation.
492// If a resource with the same name is currently being deleted, the deletion will be cancelled.
493func (c *Controller) Create(ctx context.Context, name *runtimev1.ResourceName, refs []*runtimev1.ResourceName, owner *runtimev1.ResourceName, paths []string, hidden bool, r *runtimev1.Resource) error {
494 if err := c.checkRunning(); err != nil {
495 return err
496 }
497 if ctx.Err() != nil {
498 return ctx.Err()
499 }
500 c.lock(ctx, false)
501 defer c.unlock(ctx, false)
502
503 // A deleted resource with the same name may exist and be running. If so, we first cancel it.
504 requeued := false
505 if inv, ok := c.invocations[nameStr(name)]; ok && !inv.deletedSelf {
506 r, err := c.catalog.get(name, true, false)
507 if err != nil {
508 return fmt.Errorf("internal: got catalog error for reconciling resource: %w", err)
509 }
510 if r.Meta.DeletedOn == nil {
511 // If a non-deleted resource exists with the same name, we should return an error instead of cancelling.
512 return drivers.ErrResourceAlreadyExists
513 }
514 inv.cancel(true)
515 requeued = true
516 }
517
518 err := c.catalog.create(name, refs, owner, paths, hidden, r)
519 if err != nil {
520 return err
521 }
522
523 if !requeued {
524 c.enqueue(name)
525 }
526 return nil
527}
528
529// UpdateMeta updates a resource's meta fields and enqueues it for reconciliation.
530// If called from outside the resource's reconciler and the resource is currently reconciling, the current reconciler will be cancelled first.

Callers 15

PushToGithubMethod · 0.80
testSelfHostedDeployFunction · 0.80
prepareStripeConfigFunction · 0.80
createGithubRepositoryFunction · 0.80
genMarkdownTreeCustomFunction · 0.80
downloadFileFunction · 0.80
ensureProjectParserMethod · 0.80
ExecuteMethod · 0.80
PutMethod · 0.80
prepareConfigMethod · 0.80
downloadFileFunction · 0.80

Calls 10

checkRunningMethod · 0.95
lockMethod · 0.95
unlockMethod · 0.95
enqueueMethod · 0.95
nameStrFunction · 0.85
ErrMethod · 0.65
ErrorfMethod · 0.65
getMethod · 0.45
cancelMethod · 0.45
createMethod · 0.45