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

Method trackResourceNamesForDataPaths

runtime/parser/parse_model.go:366–408  ·  view source on GitHub ↗
(ctx context.Context, name ResourceName, inputProps map[string]any)

Source from the content-addressed store, hash-verified

364}
365
366func (p *Parser) trackResourceNamesForDataPaths(ctx context.Context, name ResourceName, inputProps map[string]any) error {
367 c, ok := inputProps["invalidate_on_change"].(bool)
368 if ok && !c {
369 return nil
370 }
371 path, ok := inputProps["path"].(string)
372 if !ok {
373 return nil
374 }
375
376 var localPaths []string
377 if fileutil.IsGlob(path) {
378 entries, err := p.Repo.ListGlob(ctx, path, true)
379 if err != nil || len(entries) == 0 {
380 // The actual error will be returned by the model reconciler
381 return nil
382 }
383
384 for _, entry := range entries {
385 localPaths = append(localPaths, entry.Path)
386 }
387 } else {
388 localPaths = []string{normalizePath(path)}
389 }
390
391 // Update parser's resourceNamesForDataPaths map to track which resources depend on the local file
392 for _, path := range localPaths {
393 resources := p.resourceNamesForDataPaths[path]
394 if !slices.Contains(resources, name) {
395 resources = append(resources, name)
396 p.resourceNamesForDataPaths[path] = resources
397 }
398 }
399
400 // Calculate hash of local files
401 hash, err := p.Repo.Hash(ctx, localPaths)
402 if err != nil {
403 return err
404 }
405 // Add hash to input properties so that the model spec is considered updated when the local file changes
406 inputProps["local_files_hash"] = hash
407 return nil
408}
409
410// findLineNumber returns the line number of the pos in the given text.
411// Lines are counted starting from 1, and positions start from 0.

Callers 1

parseModelMethod · 0.95

Calls 5

IsGlobFunction · 0.92
normalizePathFunction · 0.85
ContainsMethod · 0.80
ListGlobMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected