app

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2025 License: Apache-2.0 Imports: 49 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONTAINERFILE = "Containerfile"
	DOCKERFILE    = "Dockerfile"
)
View Source
const (
	DEFAULT_FILE_LIMIT = 10_000
	MAX_FILE_LIMIT     = 100_000
)
View Source
const UNNAMED_VOLUME = "<UNNAMED>"
View Source
const (
	VOL_PREFIX_SECRET = "cl_secret:"
)

Variables

View Source
var (
	REAL_IP_HEADER   = "X-Real-IP"
	FORWARDED_HEADER = "X-Forwarded-For"

	CONTENT_TYPE_JSON = []string{"application/json"}
	CONTENT_TYPE_TEXT = []string{"text/plain"}

	SERVER_NAME       = []string{"OpenRun"}
	VARY_HEADER_VALUE = []string{"HX-Request"}
)

Functions

func AddUserFile

func AddUserFile(ctx context.Context, file *types.UserFile) error

func AppFileOptions added in v0.15.2

func AppFileOptions() *syntax.FileOptions

func ClearCleanup

func ClearCleanup(thread *starlark.Thread, key string)

ClearCleanup clears a defer function from the thread local

func CreatePluginApiName

func CreatePluginApiName(
	f func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error),
	opType PluginFunctionType,
	name string) plugin.PluginFunc

CreatePluginApiName creates a OpenRun plugin function

func CreatePluginConstant

func CreatePluginConstant(name string, value starlark.Value) plugin.PluginFunc

func DeferCleanup

func DeferCleanup(thread *starlark.Thread, key string, deferFunc apptype.DeferFunc, strict bool)

DeferCleanup defers a close function to call when the API handler is done

func DeleteUserFile

func DeleteUserFile(ctx context.Context, id string) error

func FetchPluginState

func FetchPluginState(thread *starlark.Thread, key string) any

FetchPluginState fetches a value from the thread local for the plugin

func GetContext

func GetContext(thread *starlark.Thread) context.Context

func GetUserFile

func GetUserFile(ctx context.Context, id string) (*types.UserFile, error)

func InitFileStore

func InitFileStore(ctx context.Context, connectString string) error

func NewFSPlugin

func NewFSPlugin(pluginContext *types.PluginContext) (any, error)

func RegisterPlugin

func RegisterPlugin(name string, builder plugin.NewPluginFunc, funcs []plugin.PluginFunc)

RegisterPlugin registers a plugin with OpenRun

func SavePluginState

func SavePluginState(thread *starlark.Thread, key string, value any)

SavePluginState saves a value in the thread local for the plugin

Types

type AccessType

type AccessType string
const (
	UserAccess AccessType = "user"
	AppAccess  AccessType = "app"
)

type App

type App struct {
	*types.Logger
	*types.AppEntry
	Name         string
	CustomLayout bool

	// App config that takes default values from toml config, overridden with app level metadata.
	// It is important that this property is used instead of reading from app metadata config, so that toml
	// config defaults are applied.
	AppConfig types.AppConfig

	AppRunPath string // path to the app run directory
	// contains filtered or unexported fields
}

App is the main object that represents a OpenRun app. It is created when the app is loaded

func NewApp

func NewApp(sourceFS *appfs.SourceFs, workFS *appfs.WorkFs, logger *types.Logger,
	appEntry *types.AppEntry, systemConfig *types.SystemConfig,
	plugins map[string]types.PluginSettings, appConfig types.AppConfig, notifyClose chan<- types.AppPathDomain,
	secretEvalFunc func([][]string, string, string) (string, error),
	auditInsert func(*types.AuditEvent) error, serverConfig *types.ServerConfig, authorizer types.AuthorizerFunc) (*App, error)

func (*App) Audit

func (a *App) Audit() (*types.ApproveResult, error)

func (*App) Close

func (a *App) Close() error

func (*App) Initialize

func (a *App) Initialize(dryRun types.DryRun) error

func (*App) Reload

func (a *App) Reload(force, immediate bool, dryRun types.DryRun) (bool, error)

func (*App) ResetFS

func (a *App) ResetFS()

func (*App) ServeHTTP

func (a *App) ServeHTTP(w http.ResponseWriter, r *http.Request)

type AppPlugins

type AppPlugins struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewAppPlugins

func NewAppPlugins(app *App, pluginConfig map[string]types.PluginSettings, appAccounts []types.AccountLink) *AppPlugins

func (*AppPlugins) GetPlugin

func (p *AppPlugins) GetPlugin(pluginInfo *plugin.PluginInfo, accountName string) (any, error)

type ContainerManager

type ContainerManager struct {
	*types.Logger

	GenImageName container.ImageName // generated image name
	// contains filtered or unexported fields
}

func NewContainerManager

func NewContainerManager(logger *types.Logger, app *App, containerFile string,
	systemConfig *types.SystemConfig, configPort int64, lifetime, scheme, health, buildDir string, sourceFS appfs.ReadableFS,
	paramMap map[string]string, containerConfig types.Container, stripAppPath bool,
	containerVolumes []string, secretsAllowed [][]string, cargs map[string]any) (*ContainerManager, error)

func (*ContainerManager) Close

func (m *ContainerManager) Close() error

func (*ContainerManager) DevReload

func (m *ContainerManager) DevReload(dryRun bool) error

func (*ContainerManager) GetEnvMap

func (m *ContainerManager) GetEnvMap() (map[string]string, string)

func (*ContainerManager) GetHealthUrl

func (m *ContainerManager) GetHealthUrl(appHealthUrl string) string

func (*ContainerManager) GetProxyUrl

func (m *ContainerManager) GetProxyUrl() string

func (*ContainerManager) ProdReload

func (m *ContainerManager) ProdReload(dryRun bool) error

func (*ContainerManager) Run

func (m *ContainerManager) Run(ctx context.Context, path string, cmdArgs []string, env []string) (*exec.Cmd, error)

func (*ContainerManager) WaitForHealth

func (m *ContainerManager) WaitForHealth(attempts int) error

type ContainerState

type ContainerState string
const (
	ContainerStateUnknown       ContainerState = "unknown"
	ContainerStateRunning       ContainerState = "running"
	ContainerStateIdleShutdown  ContainerState = "idle_shutdown"
	ContainerStateHealthFailure ContainerState = "health_failure"
)

type FileInfo

type FileInfo struct {
	Name  string
	Size  int64
	IsDir bool
	Mode  int
}

type PluginFunctionType

type PluginFunctionType int
const (
	READ PluginFunctionType = iota
	WRITE
	READ_WRITE
)

type PluginResponse

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

PluginResponse is a starlark.Value that represents the response to a plugin request

func NewErrorCodeResponse

func NewErrorCodeResponse(errorCode int, err error, value any) *PluginResponse

func NewErrorResponse

func NewErrorResponse(err error, thread *starlark.Thread) *PluginResponse

func NewResponse

func NewResponse(value any) *PluginResponse

func NewStreamResponse

func NewStreamResponse(value any) *PluginResponse

func (*PluginResponse) Attr

func (r *PluginResponse) Attr(name string) (starlark.Value, error)

func (*PluginResponse) AttrNames

func (r *PluginResponse) AttrNames() []string

func (*PluginResponse) Freeze

func (r *PluginResponse) Freeze()

func (*PluginResponse) Hash

func (r *PluginResponse) Hash() (uint32, error)

func (*PluginResponse) String

func (r *PluginResponse) String() string

func (*PluginResponse) Truth

func (r *PluginResponse) Truth() starlark.Bool

func (*PluginResponse) Type

func (r *PluginResponse) Type() string

func (*PluginResponse) UnmarshalStarlarkType

func (r *PluginResponse) UnmarshalStarlarkType() (any, error)

type SSEMessage

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

type StarlarkFunction

type StarlarkFunction func(thread *starlark.Thread, fn *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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