config

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TypeStatic = "static"

	StaticAppRoutingReact    = "react"
	StaticAppRoutingDisabled = "disabled"

	DefaultStaticAppBuildDir = "build"
)
View Source
const (
	ProjectYAMLName = "project.outblocks"
	AppYAMLName     = "outblocks"
	LockfileName    = "outblocks.lock"
)
View Source
const (
	StateLocal      = "local"
	StateDefaultEnv = "dev"
	StateLocalPath  = ".outblocks.state"
)
View Source
const (
	TypeFunction = "function"
)
View Source
const (
	TypeService = "service"
)

Variables

View Source
var (
	ValidURLRegex  = regexp.MustCompile(`^([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,20}$`)
	ValidAppTypes  = []string{TypeStatic, TypeFunction, TypeService}
)
View Source
var (
	DefaultKnownTypes = map[string][]string{
		TypeFunction: {"functions"},
		TypeStatic:   {"statics"},
		TypeService:  {"services"},
	}
)
View Source
var (
	ErrProjectConfigNotFound = errors.New("cannot find project config file, did you forget to initialize? run:\nok init")
)

Functions

func DetectAppType added in v0.1.7

func DetectAppType(file string) string

func KnownType

func KnownType(typ string) string

Types

type App

type App interface {
	ID() string
	Name() string
	URL() string
	Normalize(cfg *Project) error
	Check(cfg *Project) error
	Type() string
	Path() string
	PluginType() *types.App

	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 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) PluginType

func (n *AppNeed) PluginType() *types.AppNeed

type BasicApp

type BasicApp struct {
	AppName string                 `json:"name"`
	AppURL  string                 `json:"url"`
	AppPath string                 `json:"-"`
	Deploy  string                 `json:"deploy"`
	Needs   map[string]*AppNeed    `json:"needs"`
	Other   map[string]interface{} `yaml:"-,remain"`
	// contains filtered or unexported fields
}

func (*BasicApp) Check

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

func (*BasicApp) DNSPlugin

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

func (*BasicApp) DeployPlugin

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

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) Path

func (a *BasicApp) Path() string

func (*BasicApp) PluginType

func (a *BasicApp) PluginType() *types.App

func (*BasicApp) RunPlugin

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

func (*BasicApp) Type

func (a *BasicApp) Type() string

func (*BasicApp) URL

func (a *BasicApp) URL() string

func (*BasicApp) Validate added in v0.1.7

func (a *BasicApp) Validate() error

type DNS

type DNS struct {
	Domain string `json:"domain"`
	Plugin string `json:"plugin"`
	// contains filtered or unexported fields
}

func (*DNS) Check

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

func (*DNS) Normalize

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

type Dependency

type Dependency struct {
	Name   string                 `json:"-"`
	Type   string                 `json:"type"`
	Deploy string                 `json:"deploy"`
	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) PluginType

func (d *Dependency) PluginType() *types.Dependency

func (*Dependency) RunPlugin

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

func (*Dependency) Validate

func (d *Dependency) Validate() error

type FunctionApp

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

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"`
	State        *State                 `json:"state,omitempty"`
	Dependencies map[string]*Dependency `json:"dependencies,omitempty"`
	Plugins      []*Plugin              `json:"plugins,omitempty"`
	DNS          []*DNS                 `json:"dns,omitempty"`

	Apps   []App          `json:"-"`
	AppMap map[string]App `json:"-"`
	Path   string         `json:"-"`
	// 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) FindDNSPlugin

func (p *Project) FindDNSPlugin(url string) *plugins.Plugin

func (*Project) FindDependency

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

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) 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) 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

type ProjectOptions added in v0.1.5

type ProjectOptions struct {
	Env string
}

type ServiceApp

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

type State

type State struct {
	Type  string                 `json:"type"`
	Env   string                 `json:"env"`
	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) 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

func (*State) Validate added in v0.1.5

func (s *State) Validate() error

type StaticApp

type StaticApp struct {
	BasicApp `json:",inline"`
	Build    *StaticAppBuild `json:"build,omitempty"`
	Routing  string          `json:"routing"`
}

func LoadStaticAppData

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

func (*StaticApp) Normalize

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

func (*StaticApp) PluginType

func (s *StaticApp) PluginType() *types.App

func (*StaticApp) Validate added in v0.1.7

func (s *StaticApp) Validate() error

type StaticAppBuild

type StaticAppBuild struct {
	Command string `json:"command"`
	Dir     string `json:"dir"`
}

type YAMLEvaluator

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

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