config

package
v0.1.67 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppTypeStatic = "static"

	StaticAppRoutingReact    = "react"
	StaticAppRoutingGatsby   = "gatsby"
	StaticAppRoutingDisabled = "disabled"

	DefaultStaticAppBuildDir = "build"
)
View Source
const (
	ProjectYAMLName = "project.outblocks"
	LockfileName    = "outblocks.lock"
	AppYAMLName     = "app.outblocks"
)
View Source
const (
	StateLocal     = "local"
	StateLocalPath = ".outblocks.state"
)
View Source
const (
	AppTypeFunction = "function"
)
View Source
const (
	AppTypeService = "service"
)

Variables

View Source
var (
	ValidURLRegex   = regexp.MustCompile(`^(https?://)?([a-zA-Z][a-zA-Z0-9-]*)((\.)([a-zA-Z][a-zA-Z0-9-]*)){1,}(/[a-zA-Z0-9-_]+)*(/)?$`)
	ValidNameRegex  = regexp.MustCompile(`^[a-zA-Z][a-zA-Z0-9_-]{0,30}$`)
	ValidAppTypes   = []string{AppTypeStatic, AppTypeFunction, AppTypeService}
	RunPluginDirect = "direct"
)
View Source
var (
	AppYAMLNames      = []string{AppYAMLName, "outblocks"}
	DefaultKnownTypes = map[string][]string{
		AppTypeFunction: {"functions"},
		AppTypeStatic:   {"statics"},
		AppTypeService:  {"services"},
	}
)
View Source
var (
	ErrProjectConfigNotFound = errors.New("cannot find project config file, did you forget to initialize? run:\nok init")
)

Functions

func ComputeAppID added in v0.1.29

func ComputeAppID(typ, name string) string

func ComputeDependencyID added in v0.1.35

func ComputeDependencyID(name string) string

func DetectAppType added in v0.1.7

func DetectAppType(data []byte) (string, error)

func KnownType

func KnownType(typ string) string

func ParseAppURL added in v0.1.67

func ParseAppURL(u string) (*url.URL, error)

Types

type App

type App interface {
	ID() string
	Name() string
	Dir() string
	URL() *url.URL
	Env() map[string]string
	PathRedirect() string
	Normalize(cfg *Project) error
	Check(cfg *Project) error
	Type() string
	Proto() *apiv1.App
	BuildProto() *apiv1.AppBuild
	RunInfo() *AppRunInfo
	DeployInfo() *AppDeployInfo
	SupportsLocal() bool
	YAMLError(path, msg string) error

	DeployPlugin() *plugins.Plugin
	RunPlugin() *plugins.Plugin
	DNSPlugin() *plugins.Plugin
}

func LoadFunctionAppData

func LoadFunctionAppData(path string, data []byte) (App, error)

func LoadServiceAppData

func LoadServiceAppData(path string, data []byte) (App, error)

type AppDeployInfo added in v0.1.47

type AppDeployInfo struct {
	Plugin string                 `json:"plugin,omitempty"`
	Env    map[string]string      `json:"env,omitempty"`
	Other  map[string]interface{} `yaml:",remain"`
}

func (*AppDeployInfo) Proto added in v0.1.47

func (i *AppDeployInfo) Proto() *apiv1.AppDeployInfo

type AppNeed

type AppNeed struct {
	Other map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func (*AppNeed) Dependency

func (n *AppNeed) Dependency() *Dependency

func (*AppNeed) Normalize

func (n *AppNeed) Normalize(name string, cfg *Project, data []byte) error

func (*AppNeed) Proto added in v0.1.47

func (n *AppNeed) Proto() *apiv1.AppNeed

type AppRunInfo added in v0.1.47

type AppRunInfo struct {
	Plugin  string                 `json:"plugin,omitempty"`
	Command string                 `json:"command,omitempty"`
	Port    int                    `json:"port,omitempty"`
	Env     map[string]string      `json:"env,omitempty"`
	Other   map[string]interface{} `yaml:",remain"`
}

func (*AppRunInfo) Proto added in v0.1.47

func (i *AppRunInfo) Proto() *apiv1.AppRunInfo

type BasicApp

type BasicApp struct {
	AppName         string                 `json:"name"`
	AppType         string                 `json:"type"`
	AppURL          string                 `json:"url"`
	AppPathRedirect string                 `json:"path_redirect"`
	AppEnv          map[string]string      `json:"env"`
	AppDir          string                 `json:"dir"`
	AppRun          *AppRunInfo            `json:"run"`
	AppDeploy       *AppDeployInfo         `json:"deploy"`
	Needs           map[string]*AppNeed    `json:"needs"`
	Other           map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func NewBasicApp added in v0.1.46

func NewBasicApp() *BasicApp

func (*BasicApp) Check

func (a *BasicApp) Check(cfg *Project) error

func (*BasicApp) DNSPlugin

func (a *BasicApp) DNSPlugin() *plugins.Plugin

func (*BasicApp) DeployInfo added in v0.1.12

func (a *BasicApp) DeployInfo() *AppDeployInfo

func (*BasicApp) DeployPlugin

func (a *BasicApp) DeployPlugin() *plugins.Plugin

func (*BasicApp) Dir added in v0.1.17

func (a *BasicApp) Dir() string

func (*BasicApp) Env added in v0.1.27

func (a *BasicApp) Env() map[string]string

func (*BasicApp) ID

func (a *BasicApp) ID() string

func (*BasicApp) Name

func (a *BasicApp) Name() string

func (*BasicApp) Normalize

func (a *BasicApp) Normalize(cfg *Project) error

func (*BasicApp) PathRedirect added in v0.1.12

func (a *BasicApp) PathRedirect() string

func (*BasicApp) Proto added in v0.1.47

func (a *BasicApp) Proto() *apiv1.App

func (*BasicApp) RunInfo added in v0.1.12

func (a *BasicApp) RunInfo() *AppRunInfo

func (*BasicApp) RunPlugin

func (a *BasicApp) RunPlugin() *plugins.Plugin

func (*BasicApp) SupportsLocal added in v0.1.12

func (a *BasicApp) SupportsLocal() bool

func (*BasicApp) Type

func (a *BasicApp) Type() string

func (*BasicApp) URL

func (a *BasicApp) URL() *url.URL

func (*BasicApp) Validate added in v0.1.7

func (a *BasicApp) Validate() error

func (*BasicApp) YAMLError added in v0.1.12

func (a *BasicApp) YAMLError(path, msg string) error

type DNS

type DNS struct {
	Domain  string   `json:"domain,omitempty"`
	Domains []string `json:"domains,omitempty"`
	Plugin  string   `json:"plugin,omitempty"`
	SSLInfo *SSLInfo `json:"ssl,omitempty"`
	// contains filtered or unexported fields
}

func (*DNS) Check

func (s *DNS) Check(i int, cfg *Project) error

func (*DNS) IsUsed added in v0.1.67

func (s *DNS) IsUsed() bool

func (*DNS) MarkAsUsed added in v0.1.67

func (s *DNS) MarkAsUsed()

func (*DNS) Match added in v0.1.49

func (s *DNS) Match(d string) bool

func (*DNS) Normalize

func (s *DNS) Normalize(i int, cfg *Project) error

type Defaults added in v0.1.23

type Defaults struct {
	Run    DefaultsRun    `json:"run,omitempty"`
	Deploy DefaultsDeploy `json:"deploy,omitempty"`
	DNS    DefaultsDNS    `json:"dns,omitempty"`
}

type DefaultsDNS added in v0.1.49

type DefaultsDNS struct {
	Plugin string                 `json:"plugin,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
}

type DefaultsDeploy added in v0.1.23

type DefaultsDeploy struct {
	Plugin string                 `json:"plugin,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
}

type DefaultsRun added in v0.1.23

type DefaultsRun struct {
	Plugin string                 `json:"plugin,omitempty"`
	Env    map[string]string      `json:"env,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
}

type Dependency

type Dependency struct {
	Name   string                 `json:"-"`
	Type   string                 `json:"type"`
	Deploy *DependencyDeploy      `json:"deploy,omitempty"`
	Run    *DependencyRun         `json:"run,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func (*Dependency) Check

func (d *Dependency) Check(key string, cfg *Project) error

func (*Dependency) DeployPlugin

func (d *Dependency) DeployPlugin() *plugins.Plugin

func (*Dependency) ID

func (d *Dependency) ID() string

func (*Dependency) Normalize

func (d *Dependency) Normalize(key string, cfg *Project) error

func (*Dependency) Proto added in v0.1.47

func (d *Dependency) Proto() *apiv1.Dependency

func (*Dependency) RunPlugin

func (d *Dependency) RunPlugin() *plugins.Plugin

func (*Dependency) SupportsLocal added in v0.1.12

func (d *Dependency) SupportsLocal() bool

func (*Dependency) Validate

func (d *Dependency) Validate() error

func (*Dependency) YAMLError added in v0.1.51

func (d *Dependency) YAMLError(subPath, err string) error

type DependencyDeploy added in v0.1.12

type DependencyDeploy struct {
	Plugin string                 `json:"plugin,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
}

type DependencyRun added in v0.1.12

type DependencyRun struct {
	Plugin string                 `json:"plugin,omitempty"`
	Port   int                    `json:"port,omitempty"`
	Other  map[string]interface{} `yaml:"-,remain"`
}

type FunctionApp

type FunctionApp struct {
	BasicApp `json:",inline"`
}

func (*FunctionApp) BuildProto added in v0.1.60

func (s *FunctionApp) BuildProto() *apiv1.AppBuild

func (*FunctionApp) SupportsLocal added in v0.1.12

func (s *FunctionApp) SupportsLocal() bool

type Plugin

type Plugin struct {
	Name    string                 `json:"name"`
	Version string                 `json:"version"`
	Source  string                 `json:"source,omitempty"`
	Other   map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func (*Plugin) Loaded added in v0.1.2

func (p *Plugin) Loaded() *plugins.Plugin

func (*Plugin) Normalize

func (p *Plugin) Normalize(i int, cfg *Project) error

func (*Plugin) Order

func (p *Plugin) Order() uint

func (*Plugin) SetLoaded added in v0.1.2

func (p *Plugin) SetLoaded(plug *plugins.Plugin)

func (*Plugin) VerConstr added in v0.1.5

func (p *Plugin) VerConstr() *semver.Constraints

type Project

type Project struct {
	Name         string                 `json:"name,omitempty"`
	Dir          string                 `json:"-"`
	State        *State                 `json:"state,omitempty"`
	Apps         []App                  `json:"-"`
	Dependencies map[string]*Dependency `json:"dependencies,omitempty"`
	Plugins      []*Plugin              `json:"plugins,omitempty"`
	DNS          []*DNS                 `json:"dns,omitempty"`
	Defaults     *Defaults              `json:"defaults,omitempty"`
	// contains filtered or unexported fields
}

func LoadProjectConfig

func LoadProjectConfig(cfgPath string, vars map[string]interface{}, opts *ProjectOptions) (*Project, error)

func LoadProjectConfigData

func LoadProjectConfigData(path string, data []byte, vars map[string]interface{}, opts *ProjectOptions, lock *lockfile.Lockfile) (*Project, error)

func (*Project) AppByID added in v0.1.35

func (p *Project) AppByID(n string) App

func (*Project) DependencyByID added in v0.1.35

func (p *Project) DependencyByID(n string) *Dependency

func (*Project) DependencyByName added in v0.1.35

func (p *Project) DependencyByName(n string) *Dependency

func (*Project) DomainInfoProto added in v0.1.49

func (p *Project) DomainInfoProto() []*apiv1.DomainInfo

func (*Project) Env added in v0.1.50

func (p *Project) Env() string

func (*Project) FindDNSPlugin

func (p *Project) FindDNSPlugin(u *url.URL) *plugins.Plugin

func (*Project) FindLoadedPlugin

func (p *Project) FindLoadedPlugin(name string) *plugins.Plugin

func (*Project) FullCheck

func (p *Project) FullCheck() error

Logic validation after everything is loaded, e.g. check for supported types.

func (*Project) ID added in v0.1.20

func (p *Project) ID() string

func (*Project) LoadApps

func (p *Project) LoadApps() error

func (*Project) LoadFile

func (p *Project) LoadFile(file string) error

func (*Project) LoadFiles

func (p *Project) LoadFiles(files []string) error

func (*Project) LoadPlugins added in v0.1.5

func (p *Project) LoadPlugins(ctx context.Context, log logger.Logger, loader *plugins.Loader, hostAddr string) error

func (*Project) LoadedPlugins

func (p *Project) LoadedPlugins() []*plugins.Plugin

func (*Project) Lockfile

func (p *Project) Lockfile() *lockfile.Lockfile

func (*Project) Normalize

func (p *Project) Normalize() error

Initial first pass validation.

func (*Project) PluginLock

func (p *Project) PluginLock(plug *Plugin) *lockfile.Plugin

func (*Project) RegisterApp

func (p *Project) RegisterApp(app App) bool

func (*Project) SetLoadedPlugins added in v0.1.2

func (p *Project) SetLoadedPlugins(plugs []*plugins.Plugin)

func (*Project) Validate

func (p *Project) Validate() error

func (*Project) YAMLData

func (p *Project) YAMLData() []byte

func (*Project) YAMLPath added in v0.1.67

func (p *Project) YAMLPath() string

type ProjectOptions added in v0.1.5

type ProjectOptions struct {
	Env string
}

type SSLInfo added in v0.1.49

type SSLInfo struct {
	Cert     string `json:"cert,omitempty"`
	Key      string `json:"key,omitempty"`
	CertFile string `json:"cert_file,omitempty"`
	KeyFile  string `json:"key_file,omitempty"`
	// contains filtered or unexported fields
}

type ServiceApp

type ServiceApp struct {
	BasicApp                   `json:",inline"`
	types.ServiceAppProperties `json:",inline"`

	AppBuild *apiv1.AppBuild `json:"-"`
}

func (*ServiceApp) BuildProto added in v0.1.60

func (s *ServiceApp) BuildProto() *apiv1.AppBuild

func (*ServiceApp) Proto added in v0.1.47

func (s *ServiceApp) Proto() *apiv1.App

func (*ServiceApp) SupportsLocal added in v0.1.12

func (s *ServiceApp) SupportsLocal() bool

func (*ServiceApp) Validate added in v0.1.18

func (s *ServiceApp) Validate() error

type State

type State struct {
	Type  string                 `json:"type"`
	Path  string                 `json:"path"`
	Other map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func (*State) Check

func (s *State) Check(cfg *Project) error

func (*State) Env

func (s *State) Env() string

func (*State) IsLocal

func (s *State) IsLocal() bool

func (*State) LoadLocal

func (s *State) LoadLocal() (*types.StateData, error)

func (*State) LocalPath

func (s *State) LocalPath() string

func (*State) Normalize

func (s *State) Normalize(cfg *Project) error

func (*State) Plugin

func (s *State) Plugin() *plugins.Plugin

func (*State) SaveLocal

func (s *State) SaveLocal(d *types.StateData) error

type StaticApp

type StaticApp struct {
	BasicApp                  `json:",inline"`
	types.StaticAppProperties `json:",inline"`
}

func LoadStaticAppData

func LoadStaticAppData(path string, data []byte) (*StaticApp, error)

func (*StaticApp) BuildProto added in v0.1.60

func (s *StaticApp) BuildProto() *apiv1.AppBuild

func (*StaticApp) Normalize

func (s *StaticApp) Normalize(cfg *Project) error

func (*StaticApp) Proto added in v0.1.47

func (s *StaticApp) Proto() *apiv1.App

func (*StaticApp) SupportsLocal added in v0.1.12

func (s *StaticApp) SupportsLocal() bool

func (*StaticApp) Validate added in v0.1.7

func (s *StaticApp) Validate() error

type YAMLEvaluator

type YAMLEvaluator struct {
	*plugin_util.BaseVarEvaluator
}

func NewYAMLEvaluator

func NewYAMLEvaluator(vars map[string]interface{}) *YAMLEvaluator

func (*YAMLEvaluator) Expand

func (e *YAMLEvaluator) Expand(input []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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