Documentation ¶
Index ¶
- Constants
- Variables
- func CheckForProjectFile(result *CompilationResult, unit *ExecutionUnit, filename string) string
- func ContainsCapability(a *SourceFile, capName string) bool
- func FileExecUnitName(f *SourceFile) string
- func FilePathMatchesGlob(patterns ...string) predicate.Predicate[File]
- func GetFirstResource[T CloudResource](result *CompilationResult) (res T)
- func GetResourcesOfType[T CloudResource](result *CompilationResult) (filtered []T)
- func InSameExecutionUnit(a, b *SourceFile) bool
- func LowerCaseFilePathMatchesGlob(patterns ...string) predicate.Predicate[File]
- type Annotation
- type AnnotationKey
- type AnnotationMap
- type CapabilityFinder
- type CloudResource
- type Commenter
- type CompilationResult
- func (result *CompilationResult) Add(resource CloudResource)
- func (result *CompilationResult) AddAll(ress []CloudResource)
- func (result *CompilationResult) Get(key ResourceKey) CloudResource
- func (result *CompilationResult) GetExecUnitForPath(fp string) (*ExecutionUnit, File)
- func (result *CompilationResult) GetFirstResource(rType string) (res CloudResource)
- func (result *CompilationResult) GetResourcesOfType(rType string) (filtered []CloudResource)
- func (result *CompilationResult) Keys() []ResourceKey
- func (result *CompilationResult) Len() int
- func (result *CompilationResult) Resources() []CloudResource
- type CompileError
- type Compiler
- type ConcurrentMap
- func (cf *ConcurrentMap[K, V]) AddAll(entries map[K]V)
- func (cf *ConcurrentMap[K, V]) Compute(k K, computeFunc func(k K, v V) (val V, ok bool))
- func (cf *ConcurrentMap[K, V]) Delete(k K) (v V, existed bool)
- func (cf *ConcurrentMap[K, V]) Each(f func(k K, v V) (stop bool))
- func (cf *ConcurrentMap[K, V]) Entries() []MapEntry[K, V]
- func (cf *ConcurrentMap[K, V]) Get(k K) (v V, ok bool)
- func (cf *ConcurrentMap[K, V]) Keys() []K
- func (cf *ConcurrentMap[K, V]) Len() int
- func (cf *ConcurrentMap[K, V]) Set(k K, v V)
- func (cf *ConcurrentMap[K, V]) Values() []V
- type Config
- type CountingWriter
- type Dependencies
- func (d *Dependencies) Add(source ResourceKey, target ResourceKey)
- func (d *Dependencies) Clone() *Dependencies
- func (d *Dependencies) Contains(dep Dependency) bool
- func (d *Dependencies) Downstream(source ResourceKey) (targets []ResourceKey)
- func (d *Dependencies) Remove(source ResourceKey, target ResourceKey) bool
- func (d *Dependencies) RemoveSource(source ResourceKey) (changed bool)
- func (d *Dependencies) RemoveTarget(target ResourceKey) (changed bool)
- func (d *Dependencies) String() string
- func (d *Dependencies) ToArray() []Dependency
- func (d *Dependencies) Upstream(target ResourceKey) (sources []ResourceKey)
- type Dependency
- type EnvironmentVariable
- type EnvironmentVariableValue
- type EnvironmentVariables
- type Event
- type EventReference
- type Executable
- type ExecutableType
- type ExecutionUnit
- func (unit *ExecutionUnit) Add(f File)
- func (unit *ExecutionUnit) AddEntrypoint(f File)
- func (unit *ExecutionUnit) AddResource(f File)
- func (unit *ExecutionUnit) AddSourceFile(f File)
- func (unit *ExecutionUnit) AddStaticAsset(f File)
- func (unit *ExecutionUnit) Files() map[string]File
- func (unit *ExecutionUnit) FilesOfLang(lang LanguageId) []*SourceFile
- func (unit *ExecutionUnit) Get(path string) File
- func (unit *ExecutionUnit) GetDeclaringFiles() []*SourceFile
- func (unit *ExecutionUnit) HasSourceFilesFor(language LanguageId) bool
- func (unit *ExecutionUnit) Key() ResourceKey
- func (unit *ExecutionUnit) OutputTo(dest string) error
- func (unit *ExecutionUnit) Remove(path string)
- type File
- type FileRef
- type Gateway
- type HasLocalOutput
- type InfraFiles
- type InputFiles
- type InternalResource
- type LanguageId
- type MapEntry
- type NodeContent
- type NodeEndpoints
- type NonOverwritable
- type Persist
- type PersistKind
- type Plugin
- type PluginError
- type PubSub
- type RawFile
- type ResourceKey
- type ResourcesOrErr
- type Route
- type Secrets
- type SourceFile
- func (f *SourceFile) Annotations() AnnotationMap
- func (f *SourceFile) Clone() File
- func (f *SourceFile) CloneSourceFile() *SourceFile
- func (f *SourceFile) IsAnnotatedWith(capability string) bool
- func (f *SourceFile) Path() string
- func (f *SourceFile) Program() []byte
- func (f *SourceFile) Reparse(newProgram []byte) (err error)
- func (f *SourceFile) ReplaceNodeContent(node *sitter.Node, content string) error
- func (f *SourceFile) Tree() *sitter.Tree
- func (f *SourceFile) WriteTo(out io.Writer) (int64, error)
- type SourceLanguage
- type StaticUnit
- func (unit *StaticUnit) AddSharedFile(f File)
- func (unit *StaticUnit) AddStaticFile(f File)
- func (unit *StaticUnit) Files() map[string]File
- func (unit *StaticUnit) GetSharedFile(path string) File
- func (unit *StaticUnit) GetStaticFile(path string) File
- func (unit *StaticUnit) Key() ResourceKey
- func (unit *StaticUnit) OutputTo(dest string) error
- func (unit *StaticUnit) RemoveSharedFile(path string)
- func (unit *StaticUnit) RemoveStaticFile(path string)
- type TopoKey
- type TopoMap
- type Topology
- type TopologyData
- type TopologyEdgeData
- type TopologyIconData
- type Verb
- type WrappedError
Constants ¶
const ( EnvironmentVariableDirective = "environment_variables" ORM_ENV_VAR_NAME_SUFFIX = "_PERSIST_ORM_CONNECTION" REDIS_PORT_ENV_VAR_NAME_SUFFIX = "_PERSIST_REDIS_PORT" REDIS_HOST_ENV_VAR_NAME_SUFFIX = "_PERSIST_REDIS_HOST" KLOTHO_PROXY_ENV_VAR_NAME = "KLOTHO_PROXY_RESOURCE_NAME" )
const ( VerbAny = Verb("ANY") VerbGet = Verb("GET") VerbPost = Verb("POST") VerbPut = Verb("PUT") VerbDelete = Verb("DELETE") VerbPatch = Verb("PATCH") VerbOptions = Verb("OPTIONS") VerbHead = Verb("HEAD") )
const ( ProviderGCP = "gcp" ProviderAWS = "aws" ProviderAzure = "azure" )
const ConfigKind = "config"
const InternalKind = "internal"
const KlothoPayloadName = "InternalKlothoPayloads"
const PubSubKind = "pubsub"
Variables ¶
var ( ExecutableTypeNodeJS = ExecutableType("NodeJS") ExecutableTypePython = ExecutableType("Python") ExecutableTypeGolang = ExecutableType("Golang") ExecutableTypeCSharp = ExecutableType("CSharp") )
var ( GatewayKind = "gateway" NetworkLoadBalancerKind = "nlb" Verbs = map[Verb]struct{}{ VerbAny: {}, VerbGet: {}, VerbPost: {}, VerbPut: {}, VerbDelete: {}, VerbPatch: {}, VerbOptions: {}, VerbHead: {}, } )
var DiagramEntityToCode = TopoMap{ {}: "", {Kind: GatewayKind}: `generic_network.Subnet("%s")`, {Kind: ExecutionUnitKind}: `generic_compute.Rack("%s")`, {Kind: string(PersistKVKind)}: `generic_storage.Storage("%s")`, {Kind: string(PersistFileKind)}: `generic_storage.Storage("%s")`, {Kind: string(PersistSecretKind)}: `generic_storage.Storage("%s")`, {Kind: string(PersistORMKind)}: `generic_database.Sql("%s")`, {Kind: string(PersistRedisNodeKind)}: `generic_storage.Storage("%s")`, {Kind: string(PersistRedisClusterKind)}: `generic_storage.Storage("%s")`, {Kind: PubSubKind}: `generic_blank.Blank("%s")`, {Kind: GatewayKind, Provider: ProviderAWS, Type: "apigateway"}: `aws_network.APIGateway("%s")`, {Kind: GatewayKind, Provider: ProviderAWS, Type: "alb"}: `aws_network.ElbNetworkLoadBalancer("%s")`, {Kind: ExecutionUnitKind, Provider: ProviderAWS}: `aws_compute.Lambda("%s")`, {Kind: string(PersistKVKind), Provider: ProviderAWS}: `aws_database.Dynamodb("%s")`, {Kind: string(PersistFileKind), Provider: ProviderAWS}: `aws_storage.S3("%s")`, {Kind: string(PersistSecretKind), Provider: ProviderAWS}: `aws_security.SecretsManager("%s")`, {Kind: string(PersistORMKind), Provider: ProviderAWS}: `aws_database.RDS("%s")`, {Kind: string(PersistRedisNodeKind), Provider: ProviderAWS}: `aws_database.ElasticacheForRedis("%s")`, {Kind: string(PersistRedisClusterKind), Provider: ProviderAWS}: `aws_database.ElasticacheForRedis("%s")`, {Kind: string(PubSubKind), Provider: ProviderAWS}: `aws_integration.SNS("%s")`, {Kind: ConfigKind, Type: "secrets_manager", Provider: ProviderAWS}: `aws_security.SecretsManager("%s")`, {Kind: ConfigKind, Type: "s3", Provider: ProviderAWS}: `aws_storage.S3("%s")`, {Kind: ExecutionUnitKind, Type: "ecs", Provider: ProviderAWS}: `aws_compute.Fargate("%s")`, {Kind: ExecutionUnitKind, Type: "eks", Provider: ProviderAWS}: `aws_compute.EKS("%s")`, {Kind: ExecutionUnitKind, Type: "apprunner", Provider: ProviderAWS}: `generic_compute.Rack("AR: %s")`, {Kind: NetworkLoadBalancerKind, Provider: ProviderAWS}: `aws_network.ElbNetworkLoadBalancer("%s")`, {Kind: GatewayKind, Provider: ProviderGCP}: `custom.Custom("%s", "./images/gcp-api-gateway.png")`, {Kind: string(PersistKVKind), Provider: ProviderGCP}: `gcp_database.Firestore("%s")`, {Kind: ExecutionUnitKind, Provider: ProviderGCP}: `gcp_compute.Run("%s")`, {Kind: string(PersistFileKind), Provider: ProviderGCP}: `gcp_storage.Filestore("%s")`, {Kind: string(PersistSecretKind), Provider: ProviderGCP}: `gcp_security.ResourceManager("%s")`, {Kind: string(PersistORMKind), Provider: ProviderGCP}: `gcp_database.SQL("%s")`, {Kind: PubSubKind, Provider: ProviderGCP}: `gcp_analytics.Pubsub("%s")`, {Kind: GatewayKind, Provider: ProviderAzure}: `azure_network.ApplicationGateway("%s")`, {Kind: string(PersistKVKind), Provider: ProviderAzure}: `azure_database.CosmosDb("%s")`, {Kind: ExecutionUnitKind, Provider: ProviderAzure}: `azure_compute.FunctionApps("%s")`, {Kind: string(PersistFileKind), Provider: ProviderAzure}: `azure_storage.BlobStorage("%s")`, {Kind: string(PersistSecretKind), Provider: ProviderAzure}: `azure_security.KeyVaults("%s")`, {Kind: string(PersistORMKind), Provider: ProviderAzure}: `azure_database.SQLDatabases("%s")`, {Kind: PubSubKind, Provider: ProviderAzure}: `azure_analytics.EventHubs("%s")`, }
DiagramEntityToCode values are modules from https://github.com/CloudCompilers/topology-visualizer/blob/main/app/app.py and the class from https://github.com/mingrammer/diagrams/tree/master/diagrams
var DiagramEntityToImgPath = TopoMap{ {}: "generic/blank/blank.png", {Kind: GatewayKind}: "generic/network/subnet.png", {Kind: ExecutionUnitKind}: "generic/compute/rack.png", {Kind: string(PersistKVKind)}: "generic/storage/storage.png", {Kind: string(PersistFileKind)}: "generic/storage/storage.png", {Kind: string(PersistSecretKind)}: "generic/storage/storage.png", {Kind: string(PersistORMKind)}: "generic/database/sql.png", {Kind: string(PersistRedisNodeKind)}: "generic/storage/storage.png", {Kind: string(PersistRedisClusterKind)}: "generic/storage/storage.png", {Kind: PubSubKind}: "generic/blank/blank.png", {Kind: ConfigKind}: "generic/storage/storage.png", {Kind: GatewayKind, Provider: ProviderAWS, Type: "apigateway"}: "aws/network/api-gateway.png", {Kind: GatewayKind, Provider: ProviderAWS, Type: "alb"}: "aws/network/elb-application-load-balancer.png", {Kind: ExecutionUnitKind, Provider: ProviderAWS}: "aws/compute/lambda.png", {Kind: string(PersistKVKind), Provider: ProviderAWS}: "aws/database/dynamodb.png", {Kind: string(PersistFileKind), Provider: ProviderAWS}: "aws/compute/simple-storage-service-s3.png", {Kind: string(PersistSecretKind), Provider: ProviderAWS}: "aws/security/secrets-manager.png", {Kind: string(PersistORMKind), Provider: ProviderAWS}: "aws/database/rds.png", {Kind: string(PersistRedisNodeKind), Provider: ProviderAWS}: "aws/database/elasticache-for-redis.png", {Kind: string(PersistRedisClusterKind), Provider: ProviderAWS}: "aws/database/elasticache-for-redis.png", {Kind: PubSubKind, Provider: ProviderAWS}: "aws/integration/simple-notification-service-sns.png", {Kind: NetworkLoadBalancerKind, Provider: ProviderAWS}: "aws/network/elb-network-load-balancer.png", {Kind: ExecutionUnitKind, Type: "ecs", Provider: ProviderAWS}: "aws/compute/fargate.png", {Kind: ExecutionUnitKind, Type: "eks", Provider: ProviderAWS}: "aws/compute/elastic-kubernetes-service.png", {Kind: ExecutionUnitKind, Type: "apprunner", Provider: ProviderAWS}: "aws/compute/app-runner.png", {Kind: ConfigKind, Type: "secret_manager", Provider: ProviderAWS}: "aws/security/secrets-manager.png", {Kind: ConfigKind, Type: "s3", Provider: ProviderAWS}: "aws/compute/simple-storage-service-s3.png", {Kind: GatewayKind, Provider: ProviderGCP}: "gcp/network/api-gateway.png", {Kind: ExecutionUnitKind, Provider: ProviderGCP}: "gcp/compute/run.png", {Kind: string(PersistKVKind), Provider: ProviderGCP}: "gcp/database/firestore.png", {Kind: string(PersistFileKind), Provider: ProviderGCP}: "gcp/storage/filestore.png", {Kind: string(PersistSecretKind), Provider: ProviderGCP}: "gcp/security/resource-manager.png", {Kind: string(PersistORMKind), Provider: ProviderGCP}: "gcp/database/sql.png", {Kind: PubSubKind, Provider: ProviderGCP}: "gcp/analytics/pubsub.png", {Kind: GatewayKind, Provider: ProviderAzure}: "azure/network/application-gateway.png", {Kind: ExecutionUnitKind, Provider: ProviderAzure}: "azure/compute/function-apps.png", {Kind: string(PersistKVKind), Provider: ProviderAzure}: "azure/database/cosmos-db.png", {Kind: string(PersistFileKind), Provider: ProviderAzure}: "azure/storage/blob-storage.png", {Kind: string(PersistSecretKind), Provider: ProviderAzure}: "azure/security/key-vaults.png", {Kind: string(PersistORMKind), Provider: ProviderAzure}: "azure/database/sql-databases.png", {Kind: PubSubKind, Provider: ProviderAzure}: "azure/analytics/event-hubs.png", }
DiagramEntityToImgPath values are relative to the base URL: https://github.com/mingrammer/diagrams/tree/master/resources
var ExecutionUnitKind = "exec_unit"
var InfraAsCodeKind = "infra_as_code"
var InputFilesKind = "input_files"
var InternalStorageVariable = EnvironmentVariable{ Name: KLOTHO_PROXY_ENV_VAR_NAME, Kind: InternalKind, ResourceID: KlothoPayloadName, Value: string(BUCKET_NAME), }
var StaticUnitKind = "static_unit"
var TopologyKind = "topology"
Functions ¶
func CheckForProjectFile ¶
func CheckForProjectFile(result *CompilationResult, unit *ExecutionUnit, filename string) string
CheckForProjectFile will find an existing inputFile, corresponding to the filename param,that best matches the path where the execution unit annotation lives and returns the path to the corresponding project file
func ContainsCapability ¶
func ContainsCapability(a *SourceFile, capName string) bool
ContainsCapability returns whether 'a' is annotated with a capability of the supplied capability name
func FileExecUnitName ¶
func FileExecUnitName(f *SourceFile) string
func GetFirstResource ¶
func GetFirstResource[T CloudResource](result *CompilationResult) (res T)
func GetResourcesOfType ¶
func GetResourcesOfType[T CloudResource](result *CompilationResult) (filtered []T)
func InSameExecutionUnit ¶
func InSameExecutionUnit(a, b *SourceFile) bool
Types ¶
type Annotation ¶
type Annotation struct { Capability *annotation.Capability // Node is the node that has been annotated; not the comment node representing the annotation itself. Node *sitter.Node }
func (Annotation) Key ¶
func (a Annotation) Key() AnnotationKey
func (*Annotation) MarshalJSON ¶
func (a *Annotation) MarshalJSON() ([]byte, error)
type AnnotationKey ¶
type AnnotationMap ¶
type AnnotationMap map[AnnotationKey]*Annotation
func (AnnotationMap) Add ¶
func (m AnnotationMap) Add(a *Annotation)
func (AnnotationMap) InSourceOrder ¶
func (m AnnotationMap) InSourceOrder() []*Annotation
InSourceOrder returns a list of annotations in the order they are defined.
func (AnnotationMap) Update ¶
func (m AnnotationMap) Update(other AnnotationMap)
type CapabilityFinder ¶
type CapabilityFinder interface {
FindAllCapabilities(*SourceFile) (AnnotationMap, error)
}
type CloudResource ¶
type CloudResource interface { // Key returns the unique identifier for the resource. Key() ResourceKey }
type CompilationResult ¶
type CompilationResult ConcurrentMap[ResourceKey, CloudResource]
func (*CompilationResult) Add ¶
func (result *CompilationResult) Add(resource CloudResource)
func (*CompilationResult) AddAll ¶
func (result *CompilationResult) AddAll(ress []CloudResource)
func (*CompilationResult) Get ¶
func (result *CompilationResult) Get(key ResourceKey) CloudResource
func (*CompilationResult) GetExecUnitForPath ¶
func (result *CompilationResult) GetExecUnitForPath(fp string) (*ExecutionUnit, File)
func (*CompilationResult) GetFirstResource ¶
func (result *CompilationResult) GetFirstResource(rType string) (res CloudResource)
GetFirstResource returns the first resource found of type `rType` or nil if not found.
func (*CompilationResult) GetResourcesOfType ¶
func (result *CompilationResult) GetResourcesOfType(rType string) (filtered []CloudResource)
func (*CompilationResult) Keys ¶
func (result *CompilationResult) Keys() []ResourceKey
func (*CompilationResult) Len ¶
func (result *CompilationResult) Len() int
func (*CompilationResult) Resources ¶
func (result *CompilationResult) Resources() []CloudResource
type CompileError ¶
type CompileError struct { File *SourceFile Annotation *Annotation Cause error }
func NewCompilerError ¶
func NewCompilerError(f *SourceFile, annotation *Annotation, cause error) *CompileError
func (*CompileError) Error ¶
func (err *CompileError) Error() string
func (*CompileError) Unwrap ¶
func (err *CompileError) Unwrap() error
type Compiler ¶
type Compiler struct {
Plugins []Plugin
}
func (*Compiler) Compile ¶
func (c *Compiler) Compile(main *InputFiles) (*CompilationResult, error)
type ConcurrentMap ¶
type ConcurrentMap[K comparable, V any] struct { // contains filtered or unexported fields }
func (*ConcurrentMap[K, V]) AddAll ¶
func (cf *ConcurrentMap[K, V]) AddAll(entries map[K]V)
func (*ConcurrentMap[K, V]) Compute ¶
func (cf *ConcurrentMap[K, V]) Compute(k K, computeFunc func(k K, v V) (val V, ok bool))
Compute sets the value of key 'k' to the result of the supplied computeFunc. If the value of 'ok' is 'false', the entry for key 'k' will be removed from the ConcurrentMap.
func (*ConcurrentMap[K, V]) Delete ¶
func (cf *ConcurrentMap[K, V]) Delete(k K) (v V, existed bool)
func (*ConcurrentMap[K, V]) Each ¶
func (cf *ConcurrentMap[K, V]) Each(f func(k K, v V) (stop bool))
Each executes `f` for each key-value pair in the map, while holding the lock. ! Avoid doing expensive operations in `f`, instead create a copy (eg via `Entries()`).
func (*ConcurrentMap[K, V]) Entries ¶
func (cf *ConcurrentMap[K, V]) Entries() []MapEntry[K, V]
func (*ConcurrentMap[K, V]) Get ¶
func (cf *ConcurrentMap[K, V]) Get(k K) (v V, ok bool)
func (*ConcurrentMap[K, V]) Keys ¶
func (cf *ConcurrentMap[K, V]) Keys() []K
func (*ConcurrentMap[K, V]) Len ¶
func (cf *ConcurrentMap[K, V]) Len() int
func (*ConcurrentMap[K, V]) Set ¶
func (cf *ConcurrentMap[K, V]) Set(k K, v V)
func (*ConcurrentMap[K, V]) Values ¶
func (cf *ConcurrentMap[K, V]) Values() []V
type Config ¶ added in v0.6.3
func (*Config) Key ¶ added in v0.6.3
func (p *Config) Key() ResourceKey
type CountingWriter ¶
type Dependencies ¶
type Dependencies ConcurrentMap[Dependency, struct{}]
func (*Dependencies) Add ¶
func (d *Dependencies) Add(source ResourceKey, target ResourceKey)
func (*Dependencies) Clone ¶
func (d *Dependencies) Clone() *Dependencies
func (*Dependencies) Contains ¶
func (d *Dependencies) Contains(dep Dependency) bool
func (*Dependencies) Downstream ¶
func (d *Dependencies) Downstream(source ResourceKey) (targets []ResourceKey)
func (*Dependencies) Remove ¶
func (d *Dependencies) Remove(source ResourceKey, target ResourceKey) bool
func (*Dependencies) RemoveSource ¶
func (d *Dependencies) RemoveSource(source ResourceKey) (changed bool)
func (*Dependencies) RemoveTarget ¶
func (d *Dependencies) RemoveTarget(target ResourceKey) (changed bool)
func (*Dependencies) String ¶
func (d *Dependencies) String() string
func (*Dependencies) ToArray ¶
func (d *Dependencies) ToArray() []Dependency
func (*Dependencies) Upstream ¶
func (d *Dependencies) Upstream(target ResourceKey) (sources []ResourceKey)
type Dependency ¶
type Dependency struct { Source ResourceKey Target ResourceKey }
type EnvironmentVariable ¶
func GenerateOrmConnStringEnvVar ¶
func GenerateOrmConnStringEnvVar(id string, kind string) EnvironmentVariable
func GenerateRedisHostEnvVar ¶
func GenerateRedisHostEnvVar(id string, kind string) EnvironmentVariable
func GenerateRedisPortEnvVar ¶
func GenerateRedisPortEnvVar(id string, kind string) EnvironmentVariable
type EnvironmentVariableValue ¶
type EnvironmentVariableValue string
var ( HOST EnvironmentVariableValue = "host" PORT EnvironmentVariableValue = "port" CONNECTION_STRING EnvironmentVariableValue = "connection_string" BUCKET_NAME EnvironmentVariableValue = "bucket_name" )
type EnvironmentVariables ¶ added in v0.6.3
type EnvironmentVariables []EnvironmentVariable
func (*EnvironmentVariables) Add ¶ added in v0.6.3
func (vars *EnvironmentVariables) Add(v EnvironmentVariable)
Add the given environment variable to the list. If a variable of the same name already exists, replace it.
func (*EnvironmentVariables) AddAll ¶ added in v0.6.3
func (vars *EnvironmentVariables) AddAll(vs EnvironmentVariables)
AddAll is a convenience over `Add` to add many variables.
type Event ¶
type Event struct { Name string Publishers []ResourceKey Subscribers []ResourceKey }
type EventReference ¶
type EventReference struct { ResourceKey FilePath string }
type Executable ¶
type Executable struct { Type ExecutableType // Entrypoints is a set of paths to source files that act as entrypoints to the Executable // These entrypoints are used by execunit.SourceFilesResolver as root nodes in the Executable's // dependency tree when resolving its set of SourceFiles. Entrypoints map[string]struct{} // Resources is a set of paths to files in the Executable's owning ExecutionUnit that represent // non source files required by the Executable (e.g. NodeJS's package.json file). Resources map[string]struct{} // SourceFiles is a set of paths to files in the Executable's owning ExecutionUnit that represent // source files that compose the Executable's application code SourceFiles map[string]struct{} // SourceFiles is a set of paths to files in the Executable's owning ExecutionUnit that represent // files that have been statically included for runtime use rather than active processing by the compiler. StaticAssets map[string]struct{} }
Executable represents the slice of a project that is deployed to and executed on an ExecutionUnit
func NewExecutable ¶
func NewExecutable() Executable
func (*Executable) RemoveFile ¶
func (e *Executable) RemoveFile(path string)
type ExecutableType ¶
type ExecutableType string
type ExecutionUnit ¶
type ExecutionUnit struct { Name string Executable Executable EnvironmentVariables EnvironmentVariables DockerfilePath string // contains filtered or unexported fields }
func (*ExecutionUnit) Add ¶
func (unit *ExecutionUnit) Add(f File)
func (*ExecutionUnit) AddEntrypoint ¶
func (unit *ExecutionUnit) AddEntrypoint(f File)
func (*ExecutionUnit) AddResource ¶
func (unit *ExecutionUnit) AddResource(f File)
func (*ExecutionUnit) AddSourceFile ¶
func (unit *ExecutionUnit) AddSourceFile(f File)
func (*ExecutionUnit) AddStaticAsset ¶
func (unit *ExecutionUnit) AddStaticAsset(f File)
func (*ExecutionUnit) Files ¶
func (unit *ExecutionUnit) Files() map[string]File
func (*ExecutionUnit) FilesOfLang ¶
func (unit *ExecutionUnit) FilesOfLang(lang LanguageId) []*SourceFile
func (*ExecutionUnit) Get ¶
func (unit *ExecutionUnit) Get(path string) File
func (*ExecutionUnit) GetDeclaringFiles ¶
func (unit *ExecutionUnit) GetDeclaringFiles() []*SourceFile
GetDeclaringFiles returns a slice of files containing capability declarations for this ExecutionUnit
func (*ExecutionUnit) HasSourceFilesFor ¶
func (unit *ExecutionUnit) HasSourceFilesFor(language LanguageId) bool
func (*ExecutionUnit) Key ¶
func (unit *ExecutionUnit) Key() ResourceKey
func (*ExecutionUnit) OutputTo ¶
func (unit *ExecutionUnit) OutputTo(dest string) error
func (*ExecutionUnit) Remove ¶
func (unit *ExecutionUnit) Remove(path string)
type FileRef ¶
FileRef is a lightweight representation of a file, deferring reading its contents until `WriteTo` is called.
type Gateway ¶
type Gateway struct { Name string Routes []Route // Map of gateway targets with the exec unit name as the key DefinedIn string ExportVarName string }
func FindUpstreamGateways ¶
func FindUpstreamGateways(unit *ExecutionUnit, result *CompilationResult, deps *Dependencies) []*Gateway
func NewGateway ¶
func (*Gateway) Key ¶
func (gw *Gateway) Key() ResourceKey
type HasLocalOutput ¶
type InfraFiles ¶
type InfraFiles struct { Name string Files ConcurrentMap[string, File] }
func (*InfraFiles) Add ¶
func (unit *InfraFiles) Add(f File)
func (*InfraFiles) Key ¶
func (iac *InfraFiles) Key() ResourceKey
func (*InfraFiles) OutputTo ¶
func (iac *InfraFiles) OutputTo(dest string) error
type InputFiles ¶
type InputFiles ConcurrentMap[string, File]
func (*InputFiles) Add ¶
func (input *InputFiles) Add(f File)
func (*InputFiles) Files ¶
func (input *InputFiles) Files() map[string]File
func (*InputFiles) FilesOfLang ¶
func (input *InputFiles) FilesOfLang(lang LanguageId) []*SourceFile
func (*InputFiles) Key ¶
func (*InputFiles) Key() ResourceKey
type InternalResource ¶ added in v0.6.3
type InternalResource struct {
Name string
}
func (*InternalResource) Key ¶ added in v0.6.3
func (p *InternalResource) Key() ResourceKey
type LanguageId ¶
type LanguageId string
func (LanguageId) CastFile ¶
func (lid LanguageId) CastFile(f File) (*SourceFile, bool)
type MapEntry ¶
type MapEntry[K comparable, V any] struct { Key K Value V }
type NodeContent ¶
type NodeContent struct { Endpoints NodeEndpoints Content string }
type NodeEndpoints ¶
type NonOverwritable ¶
type Persist ¶
type Persist struct { Name string Kind PersistKind }
func (*Persist) Key ¶
func (p *Persist) Key() ResourceKey
type PersistKind ¶
type PersistKind string
const ( PersistKVKind PersistKind = "persist_kv" PersistFileKind PersistKind = "persist_fs" PersistSecretKind PersistKind = "persist_secret" PersistORMKind PersistKind = "persist_orm" PersistRedisNodeKind PersistKind = "persist_redis_node" PersistRedisClusterKind PersistKind = "persist_redis_cluster" )
type Plugin ¶
type Plugin interface { Name() string // Transform is expected to mutate the result and any dependencies Transform(*CompilationResult, *Dependencies) error }
type PluginError ¶
func NewPluginError ¶
func NewPluginError(name string, cause error) *PluginError
func (*PluginError) Error ¶
func (err *PluginError) Error() string
func (*PluginError) Unwrap ¶
func (err *PluginError) Unwrap() error
type PubSub ¶
func (*PubSub) AddPublisher ¶
func (p *PubSub) AddPublisher(event string, key ResourceKey)
func (*PubSub) AddSubscriber ¶
func (p *PubSub) AddSubscriber(event string, key ResourceKey)
func (*PubSub) EventNames ¶
func (PubSub) Key ¶
func (p PubSub) Key() ResourceKey
type RawFile ¶
RawFile represents a file with its included `Content` in case the compiler needs to read/manipulate it. If the content is not needed except to `WriteTo`, then try using FileRef instead.
type ResourceKey ¶
type ResourceKey struct { // Kind is the kind of resource it is such as `exec_unit`, `persist_kv`, etc Kind string // Name must be unique to the compilation for the `Kind` of resource. Name string }
func (ResourceKey) String ¶
func (k ResourceKey) String() string
type ResourcesOrErr ¶
type ResourcesOrErr struct { Resources []CloudResource Err error }
ResourcesOrErr provided as commonly used in async operations for the result channel.
type Route ¶
type Route struct { // Path should be expressed using Express's route path syntax or a subset thereof // (see: http://expressjs.com/en/4x/api.html#path-examples) Path string ExecUnitName string Verb Verb // HandledInFile is the path to the file which this route is defined/handled in HandledInFile string }
type SourceFile ¶
type SourceFile struct { Language SourceLanguage // contains filtered or unexported fields }
func NewSourceFile ¶
func NewSourceFile(path string, content io.Reader, language SourceLanguage) (f *SourceFile, err error)
func (*SourceFile) Annotations ¶
func (f *SourceFile) Annotations() AnnotationMap
func (*SourceFile) Clone ¶
func (f *SourceFile) Clone() File
func (*SourceFile) CloneSourceFile ¶
func (f *SourceFile) CloneSourceFile() *SourceFile
CloneSourceFile implements the same behavior as `Clone()` (from the `File` interface), but returns the result as a `*SourceFile` so that you don't need to cast it.
func (*SourceFile) IsAnnotatedWith ¶
func (f *SourceFile) IsAnnotatedWith(capability string) bool
func (*SourceFile) Path ¶
func (f *SourceFile) Path() string
func (*SourceFile) Program ¶
func (f *SourceFile) Program() []byte
func (*SourceFile) Reparse ¶
func (f *SourceFile) Reparse(newProgram []byte) (err error)
func (*SourceFile) ReplaceNodeContent ¶
func (f *SourceFile) ReplaceNodeContent(node *sitter.Node, content string) error
func (*SourceFile) Tree ¶
func (f *SourceFile) Tree() *sitter.Tree
type SourceLanguage ¶
type SourceLanguage struct { ID LanguageId Sitter *sitter.Language CapabilityFinder CapabilityFinder TurnIntoComment Commenter }
type StaticUnit ¶
type StaticUnit struct { Name string IndexDocument string StaticFiles ConcurrentMap[string, File] }
func (*StaticUnit) AddSharedFile ¶
func (unit *StaticUnit) AddSharedFile(f File)
func (*StaticUnit) AddStaticFile ¶
func (unit *StaticUnit) AddStaticFile(f File)
func (*StaticUnit) Files ¶
func (unit *StaticUnit) Files() map[string]File
func (*StaticUnit) GetSharedFile ¶
func (unit *StaticUnit) GetSharedFile(path string) File
func (*StaticUnit) GetStaticFile ¶
func (unit *StaticUnit) GetStaticFile(path string) File
func (*StaticUnit) Key ¶
func (unit *StaticUnit) Key() ResourceKey
func (*StaticUnit) OutputTo ¶
func (unit *StaticUnit) OutputTo(dest string) error
func (*StaticUnit) RemoveSharedFile ¶
func (unit *StaticUnit) RemoveSharedFile(path string)
func (*StaticUnit) RemoveStaticFile ¶
func (unit *StaticUnit) RemoveStaticFile(path string)
type TopoMap ¶
type Topology ¶
type Topology struct { Name string // contains filtered or unexported fields }
func NewTopology ¶
func NewTopology(name string, data TopologyData, image []byte) *Topology
func (*Topology) GetTopologyData ¶
func (t *Topology) GetTopologyData() TopologyData
func (*Topology) Key ¶
func (t *Topology) Key() ResourceKey
type TopologyData ¶
type TopologyData struct { IconData []TopologyIconData `json:"topologyIconData"` EdgeData []TopologyEdgeData `json:"topologyEdgeData"` }
type TopologyEdgeData ¶
type TopologyIconData ¶
type Verb ¶
type Verb string
Verb is the HTTP verb used in the route. May be upper or lower case, users are expected to convert to their needs.
type WrappedError ¶
type WrappedError struct { Message string Cause error Stack errors.StackTrace }
func WrapErrf ¶
func WrapErrf(err error, msg string, args ...interface{}) *WrappedError
func (*WrappedError) Error ¶
func (err *WrappedError) Error() string
func (*WrappedError) Unwrap ¶
func (err *WrappedError) Unwrap() error