app

package
v0.15.20 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2025 License: Apache-2.0 Imports: 53 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 (
	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,
	rbacApi rbac.RBACAPI) (*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(ctx context.Context, dryRun types.DryRun) error

func (*App) Reload

func (a *App) Reload(ctx context.Context, force, immediate bool, dryRun types.DryRun, reloadContainer bool) (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 ByteWindow added in v0.15.5

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

func NewByteWindow added in v0.15.5

func NewByteWindow(windowSeconds int) *ByteWindow

func (*ByteWindow) Totals added in v0.15.5

func (bw *ByteWindow) Totals() (sent, recv uint64)

type ContainerHandler added in v0.15.20

type ContainerHandler struct {
	*types.Logger

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

func NewContainerHandler added in v0.15.20

func NewContainerHandler(logger *types.Logger, app *App, containerFile string,
	serverConfig *types.ServerConfig, 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) (*ContainerHandler, error)

func (*ContainerHandler) Close added in v0.15.20

func (h *ContainerHandler) Close() error

func (*ContainerHandler) DevReload added in v0.15.20

func (h *ContainerHandler) DevReload(ctx context.Context, dryRun bool) error

func (*ContainerHandler) GetEnvMap added in v0.15.20

func (h *ContainerHandler) GetEnvMap() (map[string]string, string)

func (*ContainerHandler) GetHealthUrl added in v0.15.20

func (h *ContainerHandler) GetHealthUrl(appHealthUrl string) string

func (*ContainerHandler) GetProxyUrl added in v0.15.20

func (h *ContainerHandler) GetProxyUrl() string

func (*ContainerHandler) ProdReload added in v0.15.20

func (h *ContainerHandler) ProdReload(ctx context.Context, dryRun bool) error

func (*ContainerHandler) Run added in v0.15.20

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

func (*ContainerHandler) WaitForHealth added in v0.15.20

func (h *ContainerHandler) WaitForHealth(attempts int, containerName container.ContainerName) 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)

type Tracker added in v0.15.5

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

Tracker is a reverse proxy with byte count tracking

func NewTracker added in v0.15.5

func NewTracker(proxy *httputil.ReverseProxy, windowSeconds int) *Tracker

func (*Tracker) GetRollingTotals added in v0.15.5

func (t *Tracker) GetRollingTotals() (sent, recv uint64)

Accessor to read the rolling totals.

func (*Tracker) ServeHTTP added in v0.15.5

func (t *Tracker) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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