pkg

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: LGPL-3.0 Imports: 7 Imported by: 0

README

Backpack Format

This Go Package contains all the logic related to Backpack files, format, type and various encoding used.

TL;DR: In a Backpack "unpacked" you can find these files:

TL;DR: The Backpack "packed" is formatted in msgpack and contains the metadata, the default values, and all the templates encoded in base64.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnpackInDirectory added in v0.2.0

func UnpackInDirectory(b *Pack, dirPath string) (err error)

UnpackInDirectory will extract files of a pack into a directory.

func WritePackToFile added in v0.2.0

func WritePackToFile(b Pack, path string) (err error)

WritePackToFile will write a Pack to file

Types

type FilesMapType

type FilesMapType map[string][]byte

FilesMapType is useful type to specify what kind of Mapping we are using to store files in the pack.

type Pack added in v0.2.0

type Pack struct {
	Name         string            `yaml:"name"`
	Version      string            `yaml:"version"`    // Please use semver
	Dependencies map[string]string `yaml:",omitempty"` // URLs for dependencies? TBD

	// Templates are the .nomad files that with DefaultValues to be replaced
	Templates FilesMapType `yaml:"-"`

	// JobsEvalIDs are used to store the Jobs IDs once the templates are applied
	JobsEvalIDs map[string]string `yaml:"-"`

	// DefaultValues are the specified as a yaml file. It is a []byte instead of
	// ValuesType (map[string]interface{}) because in this way we will preserve
	// comments and inline documentation. This can help a lot to getting the right
	// configuration before deploying a backpack, without having to deal with
	// online documentation versioning.
	DefaultValues []byte `yaml:"-"`

	// Documentation contains the Markdown files (.md) files. This is used to
	// provide additional information when the values.yaml inline doc is not good
	// enough due to yaml limits.
	Documentation map[string][]byte `yaml:"-"`

	// BackpackVersion will help in case the Struct changes over time (as semver)
	BackpackVersion string `yaml:"backpack_version,omitempty"`
}

Pack is the structure of the package/file that will use to export, share exchange templates, docs and configuration

func GetPackFromDirectory added in v0.2.0

func GetPackFromDirectory(dirPath string) (b *Pack, err error)

GetPackFromDirectory will look in a given path for backpack.yaml and .nomad files to pack them together in a Pack struct.

func GetPackFromFile added in v0.2.0

func GetPackFromFile(path string) (b Pack, err error)

GetPackFromFile will read and get a Pack from a file path and return as a Pack struct

func (*Pack) SortTemplates added in v0.2.0

func (b *Pack) SortTemplates()

SortTemplates is used to ensure that files names sorting is respected. This is useful to define an "order" to follow when applying resources if that is needed.

type ValuesType

type ValuesType map[string]interface{}

ValuesType is the Type for our Values

func ValuesFromFile

func ValuesFromFile(p string) (v ValuesType, err error)

ValuesFromFile reads a path and returns a ValuesType Use this function to allow different formats (yaml, json, msgpack)

Jump to

Keyboard shortcuts

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