fastfood

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2015 License: MIT Imports: 13 Imported by: 0

README

fastfood

Makes Cookbooks faster by pre-templating them

This tool is still under heavy development and tbh for the vast majority of people out there it will be uninteresting and unuseful.

For a template pack test play around with try: https://github.com/the-galley/chef-templatepack

###Hacking This tool uses gpm for dependency management so you need to ensure that it is installed in order to build from source.

https://github.com/pote/gpm

###Known um ... Issues Passing node attributes does work ... however you need to escape the ' chars in order to insure it populates the recipe correctly.

###Notes

Template Notes

If the variable in the template can be either a node attribute
or a string you can ensure the value will be formatted correctly
using the .QString method on the variable.

Example:
template |{ .QString .Name }| do

if .Name is a node attribute such as node['mycookbook']['myname']
then it will be written as such:

template node['mycookbook']['myname'] do

if .Name is a string such as templatename then it will be written
with single quotes around it:

template 'templatename' do

Create an empty cookbookk:

fastfood new mycookbook

Generate a set of recipes, etc where app is the stencil set:

fastfood gen app name:application1 stencil:python repo:git@github.com/cus/app1

Build/modify an existing cookbook from a config:

fastfood build ./mycookbook.json

Uses a json config file to allow for pre-templating cookbooks:

{
  "name": "123456-customer",
  "stencils": [
    {
      "stencil_set": "django_app",
      "name": "application1",
      "stencil": "nginx",
      "repo": "git@github.com:customer/application1",
      "root": "/var/www"
    },
    {
      "name": "application2",
      "stencil": "nodejs",
      "repo": "github.com:customer/application2",
      "docroot": "/var/www/application2"
    }
  ]
}

Documentation

Overview

* This handles everything to do with stencilsets and stencils for fastfood

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name      string              `json:"name,omitempty"`
	Framework string              `json:"framework,omitempty"`
	Stencils  []map[string]string `json:"stencils,omitempty"`
	Target    []string            `json:"target,omitempty"`
}

func NewConfig

func NewConfig(path string) (Config, error)

type Framework

type Framework interface {
	// Initializes the framework
	// gives the framework the opportunity to set things up for later
	Init(FrameworkOptions) error
	// Generate Empty generates a new base directory and files for a framework
	// it returns a slice of files that were modified and an error
	// Takes an array of directories and an array of templates
	GenerateBase() ([]string, error)
	// Generate Stencil generates a stencil and returns a slice of
	// files that were modified and an error
	// Accepts a stencil name, a stencilset and options
	GenerateStencil(string, StencilSet, map[string]string) ([]string, error)
}

type FrameworkOptions

type FrameworkOptions struct {
	Destination string
	BaseFiles   []string
	BaseDirs    []string
	Force       bool
	Name        string
	TemplateDir string
}

type Helpers

type Helpers struct {
}

func (*Helpers) IsChefVar

func (h *Helpers) IsChefVar(str string) bool

func (*Helpers) IsNodeAttr

func (h *Helpers) IsNodeAttr(str string) bool

func (*Helpers) QString

func (h *Helpers) QString(str string) string

type Manifest

type Manifest struct {
	API         int `json:"api"`
	Framework   string
	Path        string
	StencilSets map[string]struct {
		Name     string
		Manifest string
		Help     string `json:"help"`
		// contains filtered or unexported fields
	} `json:"stencil_sets"`

	Base struct {
		Files       []string `json:"files"`
		Directories []string `json:"directories"`
	}
}

func NewManifest

func NewManifest(mpath string) (Manifest, error)

func (*Manifest) Help

func (m *Manifest) Help() string

func (*Manifest) Valid

func (m *Manifest) Valid() (bool, error)

type Option

type Option struct {
	DefaultValue string `json:"default"`
	Help         string `json:"help"`
}

type RawStencilSet

type RawStencilSet struct {
	Stencils map[string]json.RawMessage
}

type StencilSet

type StencilSet struct {
	Name           string `json:"id"`
	APIVersion     int    `json:"api"`
	BasePath       string
	DefaultStencil string `json:"default_stencil"`
	Raw            json.RawMessage
	Opts           map[string]Option `json:"options"`
	Stencils       map[string]struct {
		Raw  json.RawMessage
		Opts map[string]Option `json:"options"`
	} `json:"stencils"`
}

func NewStencilSet

func NewStencilSet(file string) (StencilSet, error)

Return a new stencil set and error

func (*StencilSet) Help

func (s *StencilSet) Help() string

Print stencilset help

func (*StencilSet) MergeOpts

func (s *StencilSet) MergeOpts(stencil string, opts map[string]string) map[string]string

Merge all of the options from a given map with the defaults from the stencil and stencilset

func (*StencilSet) Valid

func (s *StencilSet) Valid() (bool, error)

Return true if the type exists in types

type Template

type Template struct {
	Content string
	Raw     string
}

func NewTemplate

func NewTemplate(name string, values interface{}, content []string) (*Template, error)

Given a name, an interface, and the template content returns a Template

func (*Template) CleanNewlines

func (t *Template) CleanNewlines()

func (*Template) Flush

func (t *Template) Flush(fileName string) error

Flush the template to a file

Directories

Path Synopsis
cmd
common

Jump to

Keyboard shortcuts

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