pkggraph

package
v0.0.244 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	PackageLoaderInjection = execution.Define[PackageLoader]("ns.pkggraph.package-loader")
	MutableModuleInjection = execution.Define[MutableModule]("ns.pkggraph.mutable-module")
)

Functions

func CheckLoad added in v0.0.117

func CheckLoad(ctx context.Context, pl PackageLoader, loc Location, ref *schema.PackageRef) error

func ParseAndLoadRef added in v0.0.117

func ParseAndLoadRef(ctx context.Context, pl PackageLoader, loc Location, ref string) (*schema.PackageRef, error)

func ValidateFoundation added in v0.0.110

func ValidateFoundation(what string, minimumVersion int, lmf LoadModuleFunc) error

Types

type Context

type Context interface {
	cfg.Context
	PackageLoader
}

type EditableWorkspaceData

type EditableWorkspaceData interface {
	FormatTo(io.Writer) error

	WithModuleName(string) WorkspaceData
	WithSetDependency(...*schema.Workspace_Dependency) WorkspaceData
	WithReplacedDependencies([]*schema.Workspace_Dependency) WorkspaceData
	WithSetEnvironment(...*schema.Workspace_EnvironmentSpec) WorkspaceData
}

type ExpectedResourceInstance

type ExpectedResourceInstance struct {
	Name            *schema.PackageRef
	Class           ResourceClass
	DefaultResource *schema.PackageRef
}

type LoadModuleFunc added in v0.0.110

type LoadModuleFunc func(schema.PackageName) (*Module, error)

func ModuleFromLoader added in v0.0.110

func ModuleFromLoader(ctx context.Context, pl PackageLoader) LoadModuleFunc

func ModuleFromModules added in v0.0.110

func ModuleFromModules(mods Modules) LoadModuleFunc

type Location

type Location struct {
	Module      *Module
	PackageName schema.PackageName
	// contains filtered or unexported fields
}

func NewLocationForTesting

func NewLocationForTesting(root *Module, packageName, path string) Location

func (Location) Abs

func (loc Location) Abs(rel ...string) string

Abs returns an absolute path to the location. If path segments are passed in, the combined relative path is returned.

func (Location) CheckRel

func (loc Location) CheckRel(rel string) (string, error)

CheckRel returns a path relative to the module. If the path attempts to escape the module, an error is returned.

func (Location) ErrorLocation

func (loc Location) ErrorLocation() string

ErrorLocation implements the fnerrors.Location interface.

func (Location) GetPackageName added in v0.0.167

func (loc Location) GetPackageName() string

GetPackageName implements the schema.PackageNameLike interface.

func (Location) Rel

func (loc Location) Rel(rel ...string) string

Rel returns a path to the location, relative to the workspace root. If path segments are passed in, the combined relative path is returned.

func (Location) String

func (loc Location) String() string

type MinimalPackageLoader added in v0.0.81

type MinimalPackageLoader interface {
	LoadByName(ctx context.Context, packageName schema.PackageName) (*Package, error)
}

type Module

type Module struct {
	Workspace *schema.Workspace
	// contains filtered or unexported fields
}

func NewModule

func NewModule(w *schema.Workspace, lf *schema.Workspace_LoadedFrom, version string) *Module

func (*Module) Abs

func (mod *Module) Abs() string

func (*Module) ChangeTrigger added in v0.0.109

func (mod *Module) ChangeTrigger(rel string, excludes []string) compute.Computable[any]

func (*Module) DefinitionFile added in v0.0.112

func (mod *Module) DefinitionFile() string

func (*Module) ErrorLocation

func (mod *Module) ErrorLocation() string

Implements fnerrors.Location.

func (*Module) IsExternal

func (mod *Module) IsExternal() bool

An external module is downloaded from a remote location and stored in the cache. It always has a version.

func (*Module) MakeLocation

func (mod *Module) MakeLocation(relPath string) Location

func (*Module) ModuleName

func (mod *Module) ModuleName() string

func (*Module) ReadOnlyFS

func (mod *Module) ReadOnlyFS(rel ...string) fs.FS

func (*Module) ReadWriteFS

func (mod *Module) ReadWriteFS() fnfs.ReadWriteFS

func (*Module) RootLocation

func (mod *Module) RootLocation() Location

func (*Module) VCS

func (mod *Module) VCS(ctx context.Context) (*runtime.BuildVCS, error)

func (*Module) Version

func (mod *Module) Version() string

type Modules added in v0.0.108

type Modules interface {
	Modules() []*Module
}

type MutableModule

type MutableModule interface {
	ModuleName() string // The module that this workspace corresponds to.
	ReadWriteFS() fnfs.ReadWriteFS
}

type Package

type Package struct {
	Location Location

	PackageSources fs.FS // Filenames included will be relative to the module root, not the package.
	NewFrontend    bool  // If set to true, the new frontend parser was used to load this package.

	// One of.
	Extension      *schema.Node
	Service        *schema.Node
	Server         *schema.Server
	ServerFragment *schema.ServerFragment

	// Includes auto-generated (e.g. server startup) tests.
	Tests []*schema.Test

	// Inlined or explicitly defined binaries.
	Binaries []*schema.Binary

	// Integration that has been applied to the server in this package. May be nil.
	// Shouldn't be used outside of workspace.FinalizePackage.
	Integration *schema.Integration

	// Parsed secret definitions within the package.
	Secrets []*schema.SecretSpec

	// Parsed volume definitions within the package.
	Volumes []*schema.Volume

	// Resources associated with node types.
	Provides    map[string]*protos.FileDescriptorSetAndDeps // key: `Provides.Name`
	Services    map[string]*protos.FileDescriptorSetAndDeps // key: fully qualified service name
	PackageData []*types.Resource

	// Parsed resources
	Resources         []ResourceInstance
	ResourceClasses   []ResourceClass
	ResourceProviders []ResourceProvider

	// Hooks
	PrepareHooks         []PrepareHook
	LegacyComputeStartup PreStartup
	ComputePlanWith      []*schema.Invocation // Will generate further plan contents.

	// Raw resources definitions within a package.
	ResourceClassSpecs     []*schema.ResourceClass
	ResourceProvidersSpecs []*schema.ResourceProvider
	ResourceInstanceSpecs  []*schema.ResourceInstance
}

func LoadBinary

func LoadBinary(ctx context.Context, pl PackageLoader, ref *schema.PackageRef) (*Package, *schema.Binary, error)

func (*Package) LookupBinary

func (pr *Package) LookupBinary(name string) (*schema.Binary, error)

func (*Package) LookupResourceClass

func (pr *Package) LookupResourceClass(name string) *ResourceClass

func (*Package) LookupResourceInstance

func (pr *Package) LookupResourceInstance(name string) *ResourceInstance

func (*Package) LookupResourceProvider

func (pr *Package) LookupResourceProvider(classRef *schema.PackageRef) *ResourceProvider

func (*Package) LookupSecret

func (pr *Package) LookupSecret(name string) *schema.SecretSpec

func (*Package) Node

func (pr *Package) Node() *schema.Node

func (*Package) PackageName

func (pr *Package) PackageName() schema.PackageName

type PackageLoader

type PackageLoader interface {
	Resolve(ctx context.Context, packageName schema.PackageName) (Location, error)
	LoadByName(ctx context.Context, packageName schema.PackageName) (*Package, error)

	// Ensure that a package is being loaded.
	// Guaranteed to return immediately if the package is already being loaded concurrently.
	// This is important to avoid deadlocks on cyclic dependencies.
	Ensure(ctx context.Context, packageName schema.PackageName) error
}

type PreStartup

type PreStartup interface {
	EvalStartup(context.Context, Context, StartupInputs, []ValueWithPath) (*schema.StartupPlan, error)
}

type PrepareHook

type PrepareHook struct {
	InvokeInternal string
	InvokeBinary   *schema.Invocation
}

type ProvisionInputs

type ProvisionInputs struct {
	ServerLocation Location
}

type ResourceClass

type ResourceClass struct {
	Ref             *schema.PackageRef
	Source          *schema.ResourceClass
	DefaultProvider schema.PackageName // May be empty.
	InstanceType    UserType
}

func LookupResourceClass

func LookupResourceClass(ctx context.Context, pl MinimalPackageLoader, owner *Package, ref *schema.PackageRef) (*ResourceClass, error)

func (ResourceClass) PackageName

func (rc ResourceClass) PackageName() schema.PackageName

type ResourceInstance

type ResourceInstance struct {
	ResourceID  string
	ResourceRef *schema.PackageRef
	Spec        ResourceSpec
}

func LookupResource added in v0.0.157

func LookupResource(ctx context.Context, pl MinimalPackageLoader, owner *Package, ref *schema.PackageRef) (*ResourceInstance, error)

type ResourceProvider

type ResourceProvider struct {
	Spec *schema.ResourceProvider

	ProviderID     string
	IntentType     *UserType
	Resources      []ResourceInstance
	ResourceInputs []ExpectedResourceInstance
}

func (ResourceProvider) LookupExpected

func (rp ResourceProvider) LookupExpected(name *schema.PackageRef) *ExpectedResourceInstance

type ResourceSpec

type ResourceSpec struct {
	Source         *schema.ResourceInstance
	Intent         *anypb.Any // XXX always use serialized JSON.
	IntentType     *UserType
	Class          ResourceClass
	Provider       *ResourceProvider
	ResourceInputs []ResourceInstance // Resources passed to the provider.
}

type SealedContext

type SealedContext interface {
	cfg.Context
	SealedPackageLoader
}

func MakeSealedContext

func MakeSealedContext(env cfg.Context, pr SealedPackageLoader) SealedContext

type SealedPackageLoader

type SealedPackageLoader interface {
	PackageLoader
	Modules

	Packages() []*Package
}

type StackEndpoints

type StackEndpoints interface {
	EndpointsBy(schema.PackageName) []*schema.Endpoint
}

type StartupInputs

type StartupInputs struct {
	ServerImage   string // Result of imageID.ImageRef(), not oci.ImageID to avoid cycles.
	Stack         StackEndpoints
	ServerRootAbs string
}

type UserType

type UserType struct {
	Descriptor protoreflect.MessageDescriptor
	Sources    *protos.FileDescriptorSetAndDeps
	Registry   *protoregistry.Files
}

type ValueWithPath

type ValueWithPath struct {
	Need  *schema.Need
	Value any
}

type WorkspaceData

type WorkspaceData interface {
	cfg.Workspace

	AbsPath() string
	DefinitionFile() string
	RawData() []byte

	EditableWorkspaceData
}

Jump to

Keyboard shortcuts

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