workspace

package
v0.30.0-rc.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Details

type Details struct {
	Body    []byte
	NodeIDs map[NodeIdentifier]struct{}
}

Details represent file specific details.

type Node

type Node interface {
	GetAST() ast.Node
	GetFileName() string
	GetDependants() []NodeIdentifier
	GetGVK() schema.GroupVersionKind
	GetObject() runtime.Object
}

A Node is a single object in the package workspace graph.

type NodeIdentifier

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

NodeIdentifier is the unique identifier of a node in a workspace.

type Option

type Option func(*Workspace)

Option represents an option that can be applied to Workspace.

func WithFS

func WithFS(fs afero.Fs) Option

WithFS overrides the Workspace's filesystem with the supplied filesystem.

func WithLogger

func WithLogger(l logging.Logger) Option

WithLogger overrides the default logger for the Workspace with the supplied logger.

func WithPermissiveParser

func WithPermissiveParser() Option

WithPermissiveParser lets the workspace parser just print warnings when a file or a document in a file cannot be parsed. This can be used when partial results are more important than correctness.

func WithPrinter

func WithPrinter(p pterm.TextPrinter) Option

WithPrinter overrides the printer of the Workspace with the supplied printer. By default a Workspace has no printer.

type PackageNode

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

A PackageNode represents a concrete node in an xpkg. TODO(hasheddan): PackageNode should be refactored into separate implementations for each node type (e.g. XRD, Composition, CRD, etc.).

func (*PackageNode) GetAST

func (p *PackageNode) GetAST() ast.Node

GetAST gets the YAML AST node for this package node.

func (*PackageNode) GetDependants

func (p *PackageNode) GetDependants() []NodeIdentifier

GetDependants gets the set of nodes dependant on this node. TODO(hasheddan): this method signature may change depending on how we want to construct the node graph for a workspace.

func (*PackageNode) GetFileName

func (p *PackageNode) GetFileName() string

GetFileName gets the name of the file for this node.

func (*PackageNode) GetGVK

func (p *PackageNode) GetGVK() schema.GroupVersionKind

GetGVK returns the GroupVersionKind of this node.

func (*PackageNode) GetObject

func (p *PackageNode) GetObject() runtime.Object

GetObject returns the runtime.Object for this node.

type View

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

View represents the current processed view of the workspace.

func (*View) Examples

func (v *View) Examples() map[schema.GroupVersionKind][]Node

Examples returns the View's Nodes corresponding to the files found under /examples.

func (*View) FileDetails

func (v *View) FileDetails() map[span.URI]*Details

FileDetails returns the map of file details found within the parsed workspace.

func (*View) Meta

func (v *View) Meta() *meta.Meta

Meta returns the View's Meta.

func (*View) MetaLocation

func (v *View) MetaLocation() string

MetaLocation returns the meta file's location (on disk) in the current View.

func (*View) Nodes

func (v *View) Nodes() map[NodeIdentifier]Node

Nodes returns the View's Nodes.

func (*View) ParseFile

func (v *View) ParseFile(ctx context.Context, path string) error

ParseFile parses all YAML objects at the given path and updates the workspace node cache.

func (*View) XRClaimsRefs

func (v *View) XRClaimsRefs() map[schema.GroupVersionKind]schema.GroupVersionKind

XRClaimsRefs returns a map of XR GVK -> XRC GVK.

type Workspace

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

Workspace provides APIs for interacting with the current project workspace.

func New

func New(root string, opts ...Option) (*Workspace, error)

New creates a new Workspace instance.

func (*Workspace) Parse

func (w *Workspace) Parse(ctx context.Context) error

Parse parses the full workspace in order to hydrate the workspace's View.

func (*Workspace) View

func (w *Workspace) View() *View

View returns the Workspace's View. Note: this will only exist _after_ the Workspace has been parsed.

func (*Workspace) Write

func (w *Workspace) Write(m *meta.Meta) error

Write writes the supplied Meta details to the fs.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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