cofu

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2016 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const LUA_APP_KEY = "*__COFU_APP__"

Variables

View Source
var (
	Name       = "cofu"
	Version    = "unknown"
	CommitHash = "unknown"
	Usage      = "Minimum configuration management tool."
)
View Source
var CommonAttributes = []Attribute{
	&StringAttribute{
		Name: "only_if",
	},
	&StringAttribute{
		Name: "not_if",
	},
	&StringAttribute{
		Name: "user",
	},
	&StringAttribute{
		Name: "cwd",
	},
	&NotifiesAttribute{
		Name:    "notifies",
		Default: nil,
	},
	&StringSliceAttribute{
		Name:    "verify",
		Default: nil,
	},
}

Functions

func DefaultShowDifferences

func DefaultShowDifferences(r *Resource) error

Types

type App

type App struct {
	LState               *lua.LState
	LogLevel             string
	DryRun               bool
	ResourceTypes        []*ResourceType
	ResourceTypesMap     map[string]*ResourceType
	Resources            []*Resource
	DelayedNotifications []*Notification
	Infra                *infra.Infra
	Tmpdir               string
	Tmpfiles             []string
	// contains filtered or unexported fields
}

func GetApp

func GetApp(L *lua.LState) *App

func NewApp

func NewApp() *App

func (*App) Close

func (app *App) Close()

func (*App) DequeueDelayeNotification

func (app *App) DequeueDelayeNotification() *Notification

func (*App) EnqueueDelayeNotification

func (app *App) EnqueueDelayeNotification(n *Notification)

func (*App) FindOneResource

func (app *App) FindOneResource(desc string) *Resource

func (*App) Init

func (app *App) Init() error

func (*App) LoadDefinition

func (app *App) LoadDefinition(definition *Definition)

func (*App) LoadRecipe

func (app *App) LoadRecipe(recipeContent string) error

func (*App) LoadRecipeFile

func (app *App) LoadRecipeFile(recipeFile string) error

func (*App) LoadVariableFromJSON

func (app *App) LoadVariableFromJSON(v string) error

func (*App) LoadVariableFromJSONFile

func (app *App) LoadVariableFromJSONFile(jsonFile string) error

func (*App) RegisterResource

func (app *App) RegisterResource(r *Resource)

func (*App) RemoveDuplicateDelayeNotification

func (app *App) RemoveDuplicateDelayeNotification()

func (*App) Run

func (app *App) Run() error

func (*App) SendContentToTempfile

func (app *App) SendContentToTempfile(content []byte) (string, error)

func (*App) SendFileToTempfile

func (app *App) SendFileToTempfile(file string) (string, error)

type Attribute

type Attribute interface {
	GetName() string
	IsRequired() bool
	HasDefault() bool
	GetDefault() interface{}
	ToGoValue(v lua.LValue) interface{}
}

type BoolAttribute

type BoolAttribute struct {
	Name     string
	Required bool
	Default  bool
}

BoolAttribute

func (*BoolAttribute) GetDefault

func (attr *BoolAttribute) GetDefault() interface{}

func (*BoolAttribute) GetName

func (attr *BoolAttribute) GetName() string

func (*BoolAttribute) HasDefault

func (attr *BoolAttribute) HasDefault() bool

func (*BoolAttribute) IsRequired

func (attr *BoolAttribute) IsRequired() bool

func (*BoolAttribute) ToGoValue

func (attr *BoolAttribute) ToGoValue(v lua.LValue) interface{}

type ComparableValue

type ComparableValue interface {
	String() string
	Nil() bool
}

type Definition

type Definition struct {
	Name   string
	Params *lua.LTable
	Func   *lua.LFunction
	// contains filtered or unexported fields
}

func (*Definition) LGFunction

func (definition *Definition) LGFunction() func(L *lua.LState) int

type Integer

type Integer struct {
	V     int
	IsNil bool
}

func (*Integer) Nil

func (i *Integer) Nil() bool

func (*Integer) String

func (i *Integer) String() string

type IntegerAttribute

type IntegerAttribute struct {
	Name     string
	Required bool
	Default  *Integer
}

IntAttribute

func (*IntegerAttribute) GetDefault

func (attr *IntegerAttribute) GetDefault() interface{}

func (*IntegerAttribute) GetName

func (attr *IntegerAttribute) GetName() string

func (*IntegerAttribute) HasDefault

func (attr *IntegerAttribute) HasDefault() bool

func (*IntegerAttribute) IsRequired

func (attr *IntegerAttribute) IsRequired() bool

func (*IntegerAttribute) ToGoValue

func (attr *IntegerAttribute) ToGoValue(lv lua.LValue) interface{}

type LFunctionAttribute

type LFunctionAttribute struct {
	Name     string
	Required bool
	Default  *lua.LFunction
}

LFunctionAttribute

func (*LFunctionAttribute) GetDefault

func (attr *LFunctionAttribute) GetDefault() interface{}

func (*LFunctionAttribute) GetName

func (attr *LFunctionAttribute) GetName() string

func (*LFunctionAttribute) HasDefault

func (attr *LFunctionAttribute) HasDefault() bool

func (*LFunctionAttribute) IsRequired

func (attr *LFunctionAttribute) IsRequired() bool

func (*LFunctionAttribute) ToGoValue

func (attr *LFunctionAttribute) ToGoValue(lv lua.LValue) interface{}

type MapAttribute

type MapAttribute struct {
	Name     string
	Required bool
	Default  map[string]interface{}
}

MapAttribute

func (*MapAttribute) GetDefault

func (attr *MapAttribute) GetDefault() interface{}

func (*MapAttribute) GetName

func (attr *MapAttribute) GetName() string

func (*MapAttribute) HasDefault

func (attr *MapAttribute) HasDefault() bool

func (*MapAttribute) IsRequired

func (attr *MapAttribute) IsRequired() bool

func (*MapAttribute) ToGoValue

func (attr *MapAttribute) ToGoValue(v lua.LValue) interface{}

type Notification

type Notification struct {
	DefinedInResource  *Resource
	Action             string
	TargetResourceDesc string
	Timing             string
}

func (*Notification) Delayed

func (n *Notification) Delayed() bool

func (*Notification) Immediately

func (n *Notification) Immediately() bool

func (*Notification) Run

func (n *Notification) Run() error

func (*Notification) Validate

func (n *Notification) Validate() error

type NotifiesAttribute

type NotifiesAttribute struct {
	Name     string
	Required bool
	Default  []*Notification
}

NotifiesAttribute

func (*NotifiesAttribute) GetDefault

func (attr *NotifiesAttribute) GetDefault() interface{}

func (*NotifiesAttribute) GetName

func (attr *NotifiesAttribute) GetName() string

func (*NotifiesAttribute) HasDefault

func (attr *NotifiesAttribute) HasDefault() bool

func (*NotifiesAttribute) IsRequired

func (attr *NotifiesAttribute) IsRequired() bool

func (*NotifiesAttribute) ToGoValue

func (attr *NotifiesAttribute) ToGoValue(lv lua.LValue) interface{}

type Resource

type Resource struct {
	Name string
	// Basepath is a directory path that includes recipe file defines this resource.
	Basepath          string
	Attributes        map[string]interface{}
	AttributesLValues map[string]lua.LValue
	CurrentAttributes map[string]interface{}
	Notifications     []*Notification
	ResourceType      *ResourceType
	App               *App
	CurrentAction     string
	Values            map[string]interface{}
	// contains filtered or unexported fields
}

func NewResource

func NewResource(name string, resourceType *ResourceType, app *App) *Resource

func (*Resource) CheckCommand

func (r *Resource) CheckCommand(command string) bool

func (*Resource) Desc

func (r *Resource) Desc() string

Desc returns string like 'resource_type[name]'

func (*Resource) GetBoolAttribute

func (r *Resource) GetBoolAttribute(key string) bool

func (*Resource) GetBoolCurrentAttribute

func (r *Resource) GetBoolCurrentAttribute(key string) bool

func (*Resource) GetIntegerAttribute

func (r *Resource) GetIntegerAttribute(key string) *Integer

func (*Resource) GetIntegerCurrentAttribute

func (r *Resource) GetIntegerCurrentAttribute(key string) *Integer

func (*Resource) GetLFunctionAttribute

func (r *Resource) GetLFunctionAttribute(key string) *lua.LFunction

func (*Resource) GetLFunctionCurrentAttribute

func (r *Resource) GetLFunctionCurrentAttribute(key string) *lua.LFunction

func (*Resource) GetMapAttribute

func (r *Resource) GetMapAttribute(key string) map[string]interface{}

func (*Resource) GetMapCurrentAttribute

func (r *Resource) GetMapCurrentAttribute(key string) map[string]interface{}

func (*Resource) GetRawAttribute

func (r *Resource) GetRawAttribute(key string) interface{}

func (*Resource) GetRawCurrentAttribute

func (r *Resource) GetRawCurrentAttribute(key string) interface{}

func (*Resource) GetStringAttribute

func (r *Resource) GetStringAttribute(key string) string

func (*Resource) GetStringCurrentAttribute

func (r *Resource) GetStringCurrentAttribute(key string) string

func (*Resource) GetStringSliceAttribute

func (r *Resource) GetStringSliceAttribute(key string) []string

func (*Resource) GetStringSliceCurrentAttribute

func (r *Resource) GetStringSliceCurrentAttribute(key string) []string

func (*Resource) Infra

func (r *Resource) Infra() *infra.Infra

func (*Resource) IsDifferentFiles

func (r *Resource) IsDifferentFiles(from, to string) bool

func (Resource) IsUpdated

func (r Resource) IsUpdated() bool

func (*Resource) MustRunCommand

func (r *Resource) MustRunCommand(command string) *backend.CommandResult

func (*Resource) Run

func (r *Resource) Run(specificAction string) error

func (*Resource) RunCommand

func (r *Resource) RunCommand(command string) *backend.CommandResult

func (*Resource) SendContentToTempfile

func (r *Resource) SendContentToTempfile(content []byte) (string, error)

func (*Resource) SendFileToTempfile

func (r *Resource) SendFileToTempfile(file string) (string, error)

func (*Resource) ShowContentDiff

func (r *Resource) ShowContentDiff(from, to string)

func (*Resource) Update

func (r *Resource) Update()

type ResourceAction

type ResourceAction func(*Resource) error

type ResourceType

type ResourceType struct {
	Name                     string
	Attributes               []Attribute
	PreAction                ResourceAction
	SetCurrentAttributesFunc ResourceAction
	Actions                  map[string]ResourceAction
	ShowDifferences          ResourceAction
	// contains filtered or unexported fields
}

func (*ResourceType) LGFunction

func (resourceType *ResourceType) LGFunction() func(L *lua.LState) int

type StringAttribute

type StringAttribute struct {
	Name     string
	Required bool
	Default  string
	// If DefaultName is true, it uses name as default value.
	DefaultName bool
}

StringAttribute

func (*StringAttribute) GetDefault

func (attr *StringAttribute) GetDefault() interface{}

func (*StringAttribute) GetName

func (attr *StringAttribute) GetName() string

func (*StringAttribute) HasDefault

func (attr *StringAttribute) HasDefault() bool

func (*StringAttribute) IsDefaultName

func (attr *StringAttribute) IsDefaultName() bool

func (*StringAttribute) IsRequired

func (attr *StringAttribute) IsRequired() bool

func (*StringAttribute) ToGoValue

func (attr *StringAttribute) ToGoValue(lv lua.LValue) interface{}

type StringSliceAttribute

type StringSliceAttribute struct {
	Name     string
	Required bool
	Default  []string
	// If DefaultName is true, it uses name as default value.
	DefaultName bool
}

StringSliceAttribute

func (*StringSliceAttribute) GetDefault

func (attr *StringSliceAttribute) GetDefault() interface{}

func (*StringSliceAttribute) GetName

func (attr *StringSliceAttribute) GetName() string

func (*StringSliceAttribute) HasDefault

func (attr *StringSliceAttribute) HasDefault() bool

func (*StringSliceAttribute) IsDefaultName

func (attr *StringSliceAttribute) IsDefaultName() bool

func (*StringSliceAttribute) IsRequired

func (attr *StringSliceAttribute) IsRequired() bool

func (*StringSliceAttribute) ToGoValue

func (attr *StringSliceAttribute) ToGoValue(v lua.LValue) interface{}

Jump to

Keyboard shortcuts

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