modules

package
v0.2.0-rc7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package modules provides facilities to track the parsed state of modules and provider completion and hover contexts, among other things.

Index

Constants

View Source
const (
	// XRDFile is a metadata file in the same directory as a module to discover
	// the API version and kind of the composite resource such that this can
	// provide intelligent completion for the `req.composite` external variable.
	XRDFile = ".xrd.yaml"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	EventBus *eventbus.EventBus    // event bus to listen on
	DocStore DocStore              // document store
	FS       ReadOnlyFS            // filesystem that can provide unsaved document changes
	Provider DynamicSchemaProvider // provider to get dynamic schemas for a module, for autocomplete
}

Config is the feature configuration.

type DocStore

type DocStore interface {
	// HasOpenDocuments returns true if the supplied directory has documents open.
	HasOpenDocuments(dirHandle document.DirHandle) bool
	// IsDocumentOpen returns true if the supplied document is currently open.
	IsDocumentOpen(dh document.Handle) bool
}

DocStore provides minimal information about the state of the document store for efficient module processing.

type DynamicSchemaProvider

type DynamicSchemaProvider func(modPath string) DynamicSchemas

DynamicSchemaProvider provides dynamic schema information for a module rooted at the supplied path.

type DynamicSchemas

type DynamicSchemas interface {
	Keys() []resource.Key                                   // return all known keys
	Schema(apiVersion, kind string) *schema.AttributeSchema // return schema for the supplied key
}

DynamicSchemas provides schemas on demand for an API version, kind tuple. It can also list all such known tuples.

type Modules

type Modules struct {
	// contains filtered or unexported fields
}

Modules groups everything related to modules. Its internal state keeps track of all modules in the workspace.

func New

func New(c Config) (*Modules, error)

New returns a new Modules instance.

func (*Modules) PathCompletionContext

func (m *Modules) PathCompletionContext(p lang.Path, filename string, pos hcl.Pos) (decoder.CompletionContext, error)

PathCompletionContext returns the completion/ hover context for the supplied path, for a given position in a specific file. This takes into account the variables that are visible from that position.

func (*Modules) PathContext

func (m *Modules) PathContext(p lang.Path) (decoder.Context, error)

PathContext returns the context for the supplied path.

func (*Modules) Paths

func (m *Modules) Paths() ([]lang.Path, error)

func (*Modules) ProcessOpenForTesting

func (m *Modules) ProcessOpenForTesting(dir string) error

ProcessOpenForTesting processes an open event in a completely synchronous fashion for use by unit tests in other packages. It assumes that the dir has not been opened.

func (*Modules) ReferenceMap

func (m *Modules) ReferenceMap(p lang.Path) (*target.ReferenceMap, error)

ReferenceMap returns the map of document references from declaration to references and vice-versa.

func (*Modules) Start

func (m *Modules) Start(ctx context.Context)

Start starts background activities. It terminates when the supplied context is closed.

func (*Modules) WaitUntilProcessed

func (m *Modules) WaitUntilProcessed(dir string)

WaitUntilProcessed waits until all jobs currently queued for the supplied directory complete.

type ReadOnlyFS

type ReadOnlyFS interface {
	fs.FS                                       // extends a base FS
	ReadDir(name string) ([]fs.DirEntry, error) // allows listing directory contents.
	ReadFile(name string) ([]byte, error)       // convenience method to read a file.
	Stat(name string) (fs.FileInfo, error)      // provides file information
}

ReadOnlyFS is a read-only filesystem needed for module processing.

Directories

Path Synopsis
Package store tracks derived information for modules.
Package store tracks derived information for modules.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL