appfile

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2016 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CompileVersion is the current version that we're on for
	// compilation formats. This can be used in the future to change
	// the directory structure and on-disk format of compiled appfiles.
	CompileVersion = 1

	CompileFilename        = "Appfile.compiled"
	CompileDepsFolder      = "deps"
	CompileImportsFolder   = "deps"
	CompileVersionFilename = "version"
)
View Source
const (
	IDFile = ".ottoid"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application struct {
	Name         string
	Type         string
	Detect       bool
	Dependencies []*Dependency `mapstructure:"dependency"`
}

Application is the structure of an application definition.

func (*Application) GoString

func (v *Application) GoString() string

func (*Application) HCL added in v0.2.0

func (f *Application) HCL() *ast.ObjectItem

func (*Application) Merge added in v0.1.2

func (app *Application) Merge(other *Application)

type CompileEvent

type CompileEvent interface{}

CompileEvent is a potential event that a Callback can receive during Compilation.

type CompileEventDep

type CompileEventDep struct {
	Source string
}

CompileEventDep is the event that is called when a dependency is being loaded.

type CompileEventImport

type CompileEventImport struct {
	Source string
}

CompileEventImport is the event that is called when an import statement is being loaded and merged.

type CompileOpts

type CompileOpts struct {
	// Dir is the directory where all the compiled data will be stored.
	// For use of Otto with a compiled Appfile, this directory must not
	// be deleted.
	Dir string

	// Loader is called to load an Appfile in the given directory.
	// This can return the file as-is, but this point gives the caller
	// an opportunity to modify the Appfile prior to full compilation.
	//
	// The File given will already have all the imports merged.
	Loader func(f *File, dir string) (*File, error)

	// Callback is an optional way to receive notifications of events
	// during the compilation process. The CompileEvent argument should be
	// type switched to determine what it is.
	Callback func(CompileEvent)
}

CompileOpts are the options for compilation.

type Compiled

type Compiled struct {
	// File is the raw Appfile
	File *File

	// Graph is the DAG that has all the dependencies. This is already
	// verified to have no cycles. Each vertex is a *CompiledGraphVertex.
	Graph *dag.AcyclicGraph
}

Compiled represents a "Compiled" Appfile. A compiled Appfile is one that has loaded all of its dependency Appfiles, completed its imports, verified it is valid, etc.

Appfile compilation is a process that requires network activity and has to occur once. The idea is that after compilation, a fully compiled Appfile can then be loaded in the future without network connectivity. Additionally, since we can assume it is valid, we can load it very quickly.

func LoadCompiled

func LoadCompiled(dir string) (*Compiled, error)

LoadCompiled loads and verifies a compiled Appfile (*Compiled) from disk.

func (*Compiled) MarshalJSON

func (c *Compiled) MarshalJSON() ([]byte, error)

func (*Compiled) String

func (c *Compiled) String() string

func (*Compiled) UnmarshalJSON

func (c *Compiled) UnmarshalJSON(data []byte) error

func (*Compiled) Validate

func (c *Compiled) Validate() error

type CompiledGraphVertex

type CompiledGraphVertex struct {
	// File is the raw Appfile that this represents
	File *File

	// Dir is the directory of the data root for this dependency. This
	// is only non-empty for dependencies (the root vertex does not have
	// this value).
	Dir string

	// Don't use this outside of this package.
	NameValue string
}

CompiledGraphVertex is the type of the vertex within the Graph of Compiled.

func (*CompiledGraphVertex) Name

func (v *CompiledGraphVertex) Name() string

type Compiler added in v0.2.0

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

Compiler is responsible for compiling Appfiles. For each instance of the compiler, the directory where Appfile data is stored is cleared and reloaded.

Multiple calls to Compile can be made with a single Appfile and the dependencies won't be reloaded.

func NewCompiler added in v0.2.0

func NewCompiler(opts *CompileOpts) (*Compiler, error)

NewCompiler initializes a compiler with the given options.

func (*Compiler) Compile added in v0.2.0

func (c *Compiler) Compile(f *File) (*Compiled, error)

Compile compiles an Appfile.

This may require network connectivity if there are imports or non-local dependencies. The repositories that dependencies point to will be fully loaded into the given directory, and the compiled Appfile will be saved there.

LoadCompiled can be used to load a pre-compiled Appfile.

If you have no interest in reloading a compiled Appfile, you can recursively delete the compilation directory after this is completed. Note that certain functions of Otto such as development environments will depend on those directories existing, however.

func (*Compiler) MinCompile added in v0.2.0

func (c *Compiler) MinCompile(f *File) (*Compiled, error)

MinCompile does a minimal compilation of the given Appfile.

This will load and merge any imports. This is used for a very basic Compiled Appfile that can be used with Otto core.

This does not fetch dependencies.

type Customization

type Customization struct {
	Type   string
	Config map[string]interface{}
}

Customization is the structure of customization stanzas within the Appfile.

func (*Customization) GoString

func (v *Customization) GoString() string

func (*Customization) HCL added in v0.2.0

func (f *Customization) HCL() *ast.ObjectItem

type CustomizationSet

type CustomizationSet struct {
	// Raw is the raw list of customizations.
	Raw []*Customization
}

CustomizationSet is a struct that maintains a set of customizations from an Appfile and provides helper functions for retrieving and filtering them.

Note: While "set" is in the name, this is not a set in the formal sense of the word, since customizations can be duplicated.

func (*CustomizationSet) Filter

func (s *CustomizationSet) Filter(t string) []*Customization

Filter filters the customizations by the given type and returns only the matching list of customizations.

func (*CustomizationSet) HCL added in v0.2.0

func (f *CustomizationSet) HCL() []*ast.ObjectItem

type Dependency

type Dependency struct {
	Source string
}

Dependency is another Appfile that an App depends on

func (*Dependency) HCL added in v0.2.0

func (f *Dependency) HCL() *ast.ObjectItem

type File

type File struct {
	// ID is a unique UUID that represents this file. It is generated the
	// first time on compile. This will be blank until the Appfile is
	// compiled with Compile.
	ID string

	// Path is the path to the root file that was loaded. This might be
	// empty if the appfile was parsed from an io.Reader.
	Path string

	// Source is non-empty for dependencies and will be the raw source
	// value. This can be used for debugging.
	Source string

	Application    *Application
	Project        *Project
	Infrastructure []*Infrastructure
	Customization  *CustomizationSet

	// Imports is the list of imports that this File made. The imports
	// are realized during compilation, but this list won't be cleared
	// in case it wants to be inspected later.
	Imports []*Import
}

File is the structure of a single Appfile.

func Default

func Default(dir string, det *detect.Config) (*File, error)

Default will generate a default Appfile for the given directory.

The path to the directory must be absolute, since the path is used as a way to determine the name of the application.

func Parse

func Parse(r io.Reader) (*File, error)

Parse parses the Appfile from the given io.Reader.

Due to current internal limitations, the entire contents of the io.Reader will be copied into memory first before parsing.

func ParseFile

func ParseFile(path string) (*File, error)

ParseFile parses the given path as an Appfile.

func (*File) ActiveInfrastructure

func (f *File) ActiveInfrastructure() *Infrastructure

ActiveInfrastructure returns the Infrastructure that is being used for this Appfile.

func (*File) HCL added in v0.2.0

func (f *File) HCL() *ast.File

HCL converts the Appfile to an HCL AST, allowing printing of the Appfile back to HCL.

Note that if you parsed the File from HCL, this will not convert it back to the same HCL. Comments, in particular, won't be preserved.

func (*File) Merge

func (f *File) Merge(other *File) error

Merge will merge the other File onto this one, modifying this File with the merged contents.

func (*File) Validate

func (f *File) Validate() error

Validate validates the Appfile

type Foundation

type Foundation struct {
	Name   string
	Config map[string]interface{}
}

Foundation is the configuration for the fundamental building blocks of the infrastructure.

func (*Foundation) GoString

func (v *Foundation) GoString() string

type Import

type Import struct {
	Source string
}

Import is an import request of another Appfile into this one

func (*Import) HCL added in v0.2.0

func (f *Import) HCL() *ast.ObjectItem

type Infrastructure

type Infrastructure struct {
	Name   string
	Type   string
	Flavor string

	Foundations []*Foundation
}

Infrastructure is the structure of defining the infrastructure that an application must run on.

func (*Infrastructure) GoString

func (v *Infrastructure) GoString() string

func (*Infrastructure) HCL added in v0.2.0

func (f *Infrastructure) HCL() *ast.ObjectItem

type Project

type Project struct {
	Name           string
	Infrastructure string
}

Project is the structure of a project that many applications can belong to.

func (*Project) GoString

func (v *Project) GoString() string

func (*Project) HCL added in v0.2.0

func (f *Project) HCL() *ast.ObjectItem

type Tree

type Tree struct {
}

Tree is a tree of Appfiles representing the full dependencies.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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