parsing

package
v0.0.78 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2022 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const StartupTestBinary = "namespacelabs.dev/foundation/std/startup/testdriver"

Variables

View Source
var (
	FrameworkHandlers = map[schema.Framework]FrameworkHandler{}
)
View Source
var ModuleLoader interface {
	FindModuleRoot(string) (string, error)
	ModuleAt(context.Context, string) (pkggraph.WorkspaceData, error)
}

Functions

func Ensure

func Ensure(ctx context.Context, packages pkggraph.PackageLoader, packageName schema.PackageName) error

func FinalizePackage

func FinalizePackage(ctx context.Context, env *schema.Environment, pl EarlyPackageLoader, pp *pkggraph.Package) (*pkggraph.Package, error)

This function contains frontend-agnostic validation and processing code.

func FindModuleRoot

func FindModuleRoot(dir string) (string, error)

func FindProvider

func FindProvider(pkg *pkggraph.Package, packageName schema.PackageName, typeName string) (*schema.Node, *schema.Provides)

func GetExtension

func GetExtension(extensions []*anypb.Any, msg proto.Message) bool

func IsSecretResource

func IsSecretResource(ref packageRefLike) bool

func IsServerResource

func IsServerResource(ref packageRefLike) bool

func LoadPackageByName

func LoadPackageByName(ctx context.Context, env cfg.Context, name schema.PackageName) (*pkggraph.Package, error)

func MakeProtoParseOpts

func MakeProtoParseOpts(ctx context.Context, p pkggraph.PackageLoader, workspace *schema.Workspace) (protos.ParseOpts, error)

func ModuleAt

func ModuleAt(ctx context.Context, path string, args ModuleAtArgs) (pkggraph.WorkspaceData, error)

Loads and validates a module at a given path.

func ModuleHead

func ModuleHead(ctx context.Context, resolved *ResolvedPackage) (*schema.Workspace_Dependency, error)

func MustExtension

func MustExtension(extensions []*anypb.Any, msg proto.Message) error

func RawFindModuleRoot

func RawFindModuleRoot(dir string, names ...string) (string, error)

func RawModuleAt

func RawModuleAt(ctx context.Context, path string) (pkggraph.WorkspaceData, error)

RawModuleAt returns a schema.WorkspaceData with a reference to the workspace filename tried, even when errors are returned.

func RegisterFrameworkHandler

func RegisterFrameworkHandler(framework schema.Framework, handler FrameworkHandler)

func ResolveModuleVersion

func ResolveModuleVersion(ctx context.Context, packageName string) (*schema.Workspace_Dependency, error)

func TransformFunction

func TransformFunction(loc pkggraph.Location, function *schema.ExperimentalFunction) error

func TransformNode

func TransformNode(ctx context.Context, pl pkggraph.PackageLoader, loc pkggraph.Location, node *schema.Node, kind schema.Node_Kind) error

func TransformServer

func TransformServer(ctx context.Context, pl pkggraph.PackageLoader, srv *schema.Server, pp *pkggraph.Package) (*schema.Server, error)

func ValidateServerID

func ValidateServerID(n *schema.Server) error

func WithMissingModuleResolver

func WithMissingModuleResolver(moduleResolver MissingModuleResolver) packageLoaderOpt

Types

type CueService

type CueService struct {
	ProtoTypename string `json:"protoTypename"`
	GoPackage     string `json:"goPackage"`
}

type EarlyPackageLoader

type EarlyPackageLoader interface {
	pkggraph.PackageLoader
	WorkspaceOf(context.Context, *pkggraph.Module) (fs.FS, error)
}

EarlyPackageLoader is available during package graph construction, and has the ability to load workspace contents as well. All of the contents that are loaded through WorkspaceOf are retained, and stored as part of the config image, so that package loading is fully reproducible.

type ExtendNodeHookResult

type ExtendNodeHookResult struct {
	Import       []schema.PackageName
	LoadPackages []schema.PackageName // Packages to also be loaded by nodes, but that won't be listed as dependencies.
}

type ExtendServerHookResult

type ExtendServerHookResult struct {
	Import []schema.PackageName
}

type FrameworkHandler

type FrameworkHandler interface {
	PreParseServer(context.Context, pkggraph.Location, *ServerFrameworkExt) error
	PostParseServer(context.Context, *Sealed) error
	// List of packages that should be added as server dependencies, when the target environment's purpose is DEVELOPMENT.
	DevelopmentPackages() []schema.PackageName
}

XXX we're injection Location in these, which allows for loading arbitrary files for the workspace; Ideally we'd pass a PackageLoader instead.

type Frontend

type Frontend interface {
	ParsePackage(context.Context, pkggraph.Location) (*pkggraph.Package, error)
	GuessPackageType(context.Context, schema.PackageName) (PackageType, error)
}

type LocalModule

type LocalModule struct {
	ModuleName string
	LocalPath  string
	Version    string
}

LocalModule represents a module that is present in the specified LocalPath.

func DownloadModule

func DownloadModule(ctx context.Context, dep *schema.Workspace_Dependency, force bool) (*LocalModule, error)

type MissingModuleResolver

type MissingModuleResolver interface {
	Resolve(context.Context, schema.PackageName) (*schema.Workspace_Dependency, error)
}

type ModuleAtArgs

type ModuleAtArgs struct {
	SkipAPIRequirements bool
}

type PackageLoader

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

Parsing packages often as an exponential factor because nodes tend to depend on complete whole sub-trees. During a single root load, we maintain a cache of already loaded packages to minimize this fan-out cost.

func NewPackageLoader

func NewPackageLoader(env cfg.Context, opt ...packageLoaderOpt) *PackageLoader

func (*PackageLoader) ExternalLocation

func (pl *PackageLoader) ExternalLocation(ctx context.Context, mod *schema.Workspace_Dependency, packageName schema.PackageName) (pkggraph.Location, error)

func (*PackageLoader) LoadByName

func (pl *PackageLoader) LoadByName(ctx context.Context, packageName schema.PackageName) (*pkggraph.Package, error)

func (*PackageLoader) MatchModuleReplace

func (pl *PackageLoader) MatchModuleReplace(ctx context.Context, packageName schema.PackageName) (*pkggraph.Location, error)

func (*PackageLoader) Resolve

func (pl *PackageLoader) Resolve(ctx context.Context, original schema.PackageName) (pkggraph.Location, error)

func (*PackageLoader) Seal

func (*PackageLoader) Stats

func (*PackageLoader) WorkspaceOf

func (pl *PackageLoader) WorkspaceOf(ctx context.Context, module *pkggraph.Module) (fs.FS, error)

type PackageLoaderStats

type PackageLoaderStats struct {
	LoadedPackageCount int
	LoadedModuleCount  int
	PerModule          map[string][]string
}

type PackageType

type PackageType int
const (
	PackageType_None PackageType = iota
	PackageType_Extension
	PackageType_Service
	PackageType_Server
	PackageType_Binary
	PackageType_Test
)

type ResolvedPackage

type ResolvedPackage struct {
	ModuleName string
	Type       string
	Repository string
	RelPath    string
}

func ResolveModule

func ResolveModule(ctx context.Context, packageName string) (*ResolvedPackage, error)

type Root

type Root struct {
	LoadedDevHost *schema.DevHost
	// contains filtered or unexported fields
}

func NewRoot

func NewRoot(w cfg.Workspace, editable pkggraph.EditableWorkspaceData) *Root

func (*Root) Abs

func (root *Root) Abs() string

func (*Root) DevHost

func (root *Root) DevHost() *schema.DevHost

func (*Root) EditableWorkspace

func (root *Root) EditableWorkspace() pkggraph.EditableWorkspaceData

func (*Root) ErrorLocation

func (root *Root) ErrorLocation() string

Implements fnerrors.Location.

func (*Root) ModuleName

func (root *Root) ModuleName() string

func (*Root) ReadOnlyFS

func (root *Root) ReadOnlyFS() fs.ReadDirFS

func (*Root) ReadWriteFS

func (root *Root) ReadWriteFS() fnfs.ReadWriteFS

func (*Root) RelPackage

func (root *Root) RelPackage(rel string) fnfs.Location

func (*Root) Workspace

func (root *Root) Workspace() cfg.Workspace

type SchemaList

type SchemaList struct {
	Root *Root

	Locations []fnfs.Location
	Types     []PackageType
}

func ListSchemas

func ListSchemas(ctx context.Context, env cfg.Context, root *Root) (SchemaList, error)

Returns a list of all of the schema definitions found under root.

type SealHelper

type SealHelper struct {
	AdditionalServerDeps func(schema.Framework) ([]schema.PackageName, error)
}

type Sealed

type Sealed struct {
	Location      pkggraph.Location
	Proto         *schema.Stack_Entry
	FileDeps      []string
	Deps          []*pkggraph.Package
	ParsedPackage *pkggraph.Package
}

func Seal

func Seal(ctx context.Context, loader pkggraph.PackageLoader, focus schema.PackageName, helper *SealHelper) (Sealed, error)

func (Sealed) HasDep

func (s Sealed) HasDep(packageName schema.PackageName) bool

type ServerFrameworkExt

type ServerFrameworkExt struct {
	Include           []schema.PackageName
	FrameworkSpecific *anypb.Any
}

type ServerInputs

type ServerInputs struct {
	Services []*schema.GrpcExportService
}

Directories

Path Synopsis
integration
api
web

Jump to

Keyboard shortcuts

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