runtime

package
v1.3.3-beta Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SPACE    = " "
	NEGATION = '!'

	PythonSkipPattern = `(.*\.pyc)|(.*\.rst)|(__pycache__)|(.*~$)|(.*\.deta)|(^.*env$)|(^.*venv$)`

	NodeSkipPattern = `(node_modules)|(.*~$)|(.*\.deta)`

	Python = "python"
	Node   = "node"

	// DefaultProject default project slug
	DefaultProject = "default"
)

Variables

View Source
var (

	// DepCommands maps runtimes to the dependency managers
	DepCommands = map[string]string{
		Python: "pip",
		Node:   "npm",
	}

	// ErrNoEntrypoint noe entrypoint file present
	ErrNoEntrypoint = errors.New("no entrypoint file present")
	// ErrEntrypointConflict conflicting entrypoint files
	ErrEntrypointConflict = errors.New("conflicting entrypoint files present")
)

Functions

func GetDefaultRuntimeVersion

func GetDefaultRuntimeVersion(name string) string

GetDefaultRuntimeVersion returns default runtime version

Types

type DepChanges

type DepChanges struct {
	Added   []string
	Removed []string
}

DepChanges changes in dependencies

type EnvChanges

type EnvChanges struct {
	Vars    map[string]string
	Removed []string
}

EnvChanges changes in env vars keys

type Manager

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

Manager runtime manager handles files management and other services

func NewManager

func NewManager(root *string, initDirs bool) (*Manager, error)

NewManager returns a new runtime manager for the root dir of the program if initDirs is true, it creates dirs under root

func (*Manager) Clean

func (m *Manager) Clean() error

Clean removes `.deta` folder created by the runtime manager if it's empty

func (*Manager) GetChanges

func (m *Manager) GetChanges() (*StateChanges, error)

GetChanges checks if the state has changed in the root directory

func (*Manager) GetDepChanges

func (m *Manager) GetDepChanges() (*DepChanges, error)

GetDepChanges gets dependencies from program

func (*Manager) GetEnvChanges

func (m *Manager) GetEnvChanges(envFile string) (*EnvChanges, error)

GetEnvChanges gets changes in stored env keys and keys of the envFile

func (*Manager) GetProgInfo

func (m *Manager) GetProgInfo() (*ProgInfo, error)

GetProgInfo gets the program info stored

func (*Manager) GetRuntime

func (m *Manager) GetRuntime() (*Runtime, error)

GetRuntime gets runtime from proginfo or figures out the runtime of the program from entrypoint file if present in the root dir

func (*Manager) GetUserInfo

func (m *Manager) GetUserInfo() (*UserInfo, error)

GetUserInfo gets the user info

func (*Manager) IsInitialized

func (m *Manager) IsInitialized() (bool, error)

IsInitialized checks if the root directory is initialized as a deta program

func (*Manager) IsProgDirEmpty

func (m *Manager) IsProgDirEmpty() (bool, error)

IsProgDirEmpty checks if dir contains any files/folders which are not hidden if dir is nil, it sets the root dir

func (*Manager) StoreProgInfo

func (m *Manager) StoreProgInfo(p *ProgInfo) error

StoreProgInfo stores program info to disk

func (*Manager) StoreState

func (m *Manager) StoreState() error

StoreState stores hashes of the current state of all files(not hidden) in the root program directory

func (*Manager) StoreUserInfo

func (m *Manager) StoreUserInfo(u *UserInfo) error

StoreUserInfo stores the user info

func (*Manager) WriteProgramFiles

func (m *Manager) WriteProgramFiles(zipFile []byte, targetDir *string, relative bool, runtimeVersion string) error

WriteProgramFiles writes program files to target dir, target dir is relative to root dir if relative is true

type Pattern

type Pattern struct {
	Value *regexp.Regexp
	Skip  bool
}

type ProgInfo

type ProgInfo struct {
	ID          string   `json:"id"`
	Space       int64    `json:"space"`
	Runtime     string   `json:"runtime"` // runtime version eg: nodejs12.x
	RuntimeName string   `json:"-"`
	Name        string   `json:"name"`
	Path        string   `json:"path"`
	Project     string   `json:"project"`
	Account     string   `json:"account"`
	Region      string   `json:"region"`
	Deps        []string `json:"deps"`
	Envs        []string `json:"envs"`
	Public      bool     `json:"public"`
	Visor       string   `json:"log_level"`
	Cron        string   `json:"cron"`
}

ProgInfo program info

type Runtime

type Runtime struct {
	Name    string
	Version string
}

Runtime holds name and version of current runtime used

func CheckRuntime

func CheckRuntime(runtime string) (*Runtime, error)

CheckRuntime checks if given runtime is supported

type StateChanges

type StateChanges struct {
	Changes     map[string]string // map of files to content
	Deletions   []string
	BinaryFiles map[string]string
}

StateChanges changes in state of files of the root directory

type UserInfo

type UserInfo struct {
	DefaultSpace     int64  `json:"default_space"`
	DefaultSpaceName string `json:"default_space_name"`
	DefaultProject   string `json:"default_project"`
}

UserInfo user info

Jump to

Keyboard shortcuts

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