config

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package config implements the playbook config format

Package config implements the playbook config format

Package config implements the playbook config format

Package config implements the playbook config format

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConfig

type BaseConfig struct {
	Plays []*BasePlay `json:"plays"`
}

BaseConfig holds a list of plays but only the Name and Groups field are decoded

func NewBaseConfigFromFile

func NewBaseConfigFromFile(path string) (*BaseConfig, error)

NewBaseConfigFromFile loads a playbook base config from the given file path. The file must contain yaml data.

func NewBaseConfigFromReader

func NewBaseConfigFromReader(reader io.Reader) (*BaseConfig, error)

NewBaseConfigFromReader loads a playbook base config from the given bufio.Reader. The reader must point to yaml data.

func (*BaseConfig) Applicable

func (bc *BaseConfig) Applicable(groups []string) (*BaseConfig, error)

Applicable returns a BaseConfig that contains only the plays where the groups value of the play matches the groups given as parameter

func (*BaseConfig) ApplicableMap

func (bc *BaseConfig) ApplicableMap(groups []string) (*map[string]interface{}, error)

ApplicableMap returns a map of the BaseConfig that contains only the plays where the groups value of the play matches the groups given as parameter

type BasePlay

type BasePlay struct {
	Name   string           `json:"name"`
	Groups []string         `json:"groups"`
	Charts *json.RawMessage `json:"charts,omitempty"`
	Repos  *json.RawMessage `json:"repos,omitempty"`
}

BasePlay holds the same information as a play, but only the Name and the Groups are decoded Used to select the plays relevant for a given target and to delay decoding of the remaining play data

type Chart

type Chart struct {
	Name      string                 `json:"name"`
	Repo      string                 `json:"repo"`
	Chart     string                 `json:"chart"`
	Version   string                 `json:"version"`
	Namespace string                 `json:"namespace"`
	Values    map[string]interface{} `json:"values"`
}

Chart holds all information to deploy a helm chart

type Config

type Config struct {
	Plays []*Play `json:"plays"`
}

Config holds a list of plays

func NewConfig

func NewConfig() *Config

NewConfig returns an empty playbook config

func NewConfigFromMap

func NewConfigFromMap(data *map[string]interface{}) (*Config, error)

NewConfigFromMap takes raw config data and parses it into an inventory config

func (*Config) JSON

func (c *Config) JSON() ([]byte, error)

func (*Config) YAML

func (c *Config) YAML() ([]byte, error)

type Pattern

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

A Pattern is based on the idea of patterns in Ansible: https://docs.ansible.com/ansible/latest/user_guide/intro_patterns.html Each pattern is regexp that is implicitely enclosed in ^$ and has an optional modifier prefix.

func NewPattern

func NewPattern(expr string, groups []string) (*Pattern, error)

NewPattern returns a new pattern based on the given expression string and a list of groups. If the first charactor of the expression is either ! or &, it will be treated as modifier and the rest is treated as a regexp that will be wrapped in ^$. If no modifier is present, the whole expression will be treated as a ^$ wrapped regexp. The regexp is then matched against the list of groups and all matching groups will be stored in its internal groups field wich will be used by the Matches() method to determinee if the pattern matches the given groups.

func (*Pattern) Groups

func (p *Pattern) Groups() []string

Groups returns the list of groups matched by the regexp of this pattern

func (*Pattern) Matches

func (p *Pattern) Matches() bool

Matches returns true if the modifier is ! and it has no matching groups associated. In all other cases Matches is true if the list of matching groups is non-empty.

type Play

type Play struct {
	Name   string   `json:"name"`
	Groups []string `json:"groups"`
	Charts []*Chart `json:"charts"`
	Repos  []*Repo  `json:"repos"`
}

Play defines which charts are deployed from which repositories to which targets

type Repo

type Repo struct {
	Name string `json:"name"`
	URL  string `json:"url"`
}

Repo represents a helm chart repository

type Validator

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

Validator is used to determin if a list of Patterns added via the Add() method is valid.

func (*Validator) Add

func (v *Validator) Add(pattern *Pattern)

Add adds a given pattern either to the internal "all" or "any" list, based on the pattern modifier. Patterns with "!" and "&" modifier are added to the "all" list and all other Patterns will be added to the "any" list. Refer to the Valid() method for details.

func (*Validator) Valid

func (v *Validator) Valid() bool

Valid returns true if all Patterns in the "all" list match and at least one of the "any" list

Jump to

Keyboard shortcuts

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