parsing

package
v0.0.257 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: Apache-2.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const StartupTestBinary schema.PackageName = "namespacelabs.dev/foundation/std/startup/testdriver"
View Source
const Version_GolangBaseVersionMarker = 68
View Source
const Version_LibraryIntentsChanged = 48

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)
	NewModule(context.Context, string, *schema.Workspace) (pkggraph.WorkspaceData, error)
}

Functions

func AddServersAsResources added in v0.0.83

func AddServersAsResources(ctx context.Context, pl pkggraph.PackageLoader, owner *schema.PackageRef, servers []schema.PackageName, frag *schema.ServerFragment) error

func AddServersAsResourcesToPack added in v0.0.157

func AddServersAsResourcesToPack(ctx context.Context, pl pkggraph.PackageLoader, owner *schema.PackageRef, servers []schema.PackageName, pack *schema.ResourcePack) 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 LookupResourceProvider added in v0.0.111

func LookupResourceProvider(ctx context.Context, pl pkggraph.PackageLoader, pkg *pkggraph.Package, provider string, classRef *schema.PackageRef) (*pkggraph.ResourceProvider, error)

func MakeProtoParseOpts

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

func MergeResourcePack added in v0.0.157

func MergeResourcePack(src, out *schema.ResourcePack)

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 NewJsonNumberDecoder added in v0.0.145

func NewJsonNumberDecoder(s string) *json.Decoder

JSON decoder that maps numbers to json.Number. This allows us to recover integer types with native error checking as JSON uses float64 for all numbers by default.

func NewModule added in v0.0.100

func NewModule(ctx context.Context, dir string, w *schema.Workspace) (pkggraph.WorkspaceData, error)

func RawFindModuleRoot

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

func RegisterFrameworkHandler

func RegisterFrameworkHandler(framework schema.Framework, handler FrameworkHandler)

func RequireFeature added in v0.0.112

func RequireFeature(module *pkggraph.Module, feature string) error

func ResolveModuleVersion

func ResolveModuleVersion(ctx context.Context, packageName string) (*schema.Workspace_Dependency, 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 TransformServerFragment added in v0.0.157

func TransformServerFragment(ctx context.Context, pl pkggraph.PackageLoader, frag *schema.ServerFragment, pp *pkggraph.Package) (*schema.ServerFragment, 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
	SkipModuleNameValidation 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) Ensure added in v0.0.121

func (pl *PackageLoader) Ensure(ctx context.Context, packageName schema.PackageName) error

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
	PackageType_NewSyntax // TODO consider refining
)

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
	Result        *SealerResult
	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 SealerResult added in v0.0.157

type SealerResult struct {
	Server          *schema.Server
	Nodes           []*schema.Node
	ServerFragments []*schema.ServerFragment
}

func (*SealerResult) ExtsAndServices added in v0.0.157

func (se *SealerResult) ExtsAndServices() []*schema.Node

func (*SealerResult) ImportsOf added in v0.0.157

func (se *SealerResult) ImportsOf(pkg schema.PackageName) []schema.PackageName

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