output

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTemplate = `` /* 362-byte string literal not displayed */

DefaultTemplate defines the standard hosts config.

Functions

func Helpers

func Helpers() map[string]govaluate.ExpressionFunction

Helpers defines a list of helpers for Govaluate.

Types

type Client

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

Client defines an output client.

func New

func New(opts ...Option) (*Client, error)

New initializes a new output client.

func (*Client) FilterExpression

func (c *Client) FilterExpression(attrs map[string]interface{}) (bool, error)

FilterExpression evaluates the filter expression.

func (*Client) Generate

func (c *Client) Generate() error

Generate builds the hosts config and writes it to the file.

func (*Client) GroupExpression

func (c *Client) GroupExpression(attrs map[string]interface{}) (string, error)

GroupExpression evaluates the group expression.

func (*Client) HostExpression

func (c *Client) HostExpression(attrs map[string]interface{}) (string, error)

HostExpression evaluates the host expression.

func (*Client) NameExpression

func (c *Client) NameExpression(attrs map[string]interface{}) (string, error)

NameExpression evaluates the name expression.

func (*Client) PortExpression

func (c *Client) PortExpression(attrs map[string]interface{}) (string, error)

PortExpression evaluates the port expression.

func (*Client) Template

func (c *Client) Template(groups Groups) (string, error)

Template renders the template content.

func (*Client) UserExpression

func (c *Client) UserExpression(attrs map[string]interface{}) (string, error)

UserExpression evaluates the user expression.

func (*Client) Writer

func (c *Client) Writer(content string) error

Writer writes the generated content into a file.

type Group

type Group struct {
	Name  string
	Hosts Hosts
}

Group defines a single group record.

type Groups

type Groups []*Group

Groups is a collection of groups.

func (*Groups) Append

func (g *Groups) Append(val Group) *Group

Append simply appends a Group if it doesn't exist.

func (Groups) Len

func (g Groups) Len() int

Len implements sort.Interface

func (Groups) Less

func (g Groups) Less(i, j int) bool

Less implements sort.Interface

func (Groups) Swap

func (g Groups) Swap(i, j int)

Swap implements sort.Interface

type Host

type Host struct {
	Name    string
	User    string
	Address string
	Port    string
}

Host defines a single host record.

type Hosts

type Hosts []*Host

Hosts is a collection of hosts.

func (*Hosts) Append

func (h *Hosts) Append(val Host) *Host

Append simply appends a Host if it doesn't exist.

func (Hosts) Len

func (h Hosts) Len() int

Len implements sort.Interface

func (Hosts) Less

func (h Hosts) Less(i, j int) bool

Less implements sort.Interface

func (Hosts) Swap

func (h Hosts) Swap(i, j int)

Swap implements sort.Interface

type Option

type Option func(*Client)

Option configures a client option.

func WithFile

func WithFile(val string) Option

WithFile returns an option to set file.

func WithFilter

func WithFilter(val string) Option

WithFilter returns an option to set filter.

func WithGroup

func WithGroup(val string) Option

WithGroup returns an option to set group.

func WithHost

func WithHost(val string) Option

WithHost returns an option to set host.

func WithName

func WithName(val string) Option

WithName returns an option to set name.

func WithPort

func WithPort(val string) Option

WithPort returns an option to set port.

func WithTargets

func WithTargets(val []map[string]interface{}) Option

WithTargets returns an option to set targets.

func WithTemplate

func WithTemplate(val string) Option

WithTemplate returns an option to set template.

func WithUser

func WithUser(val string) Option

WithUser returns an option to set user.

Jump to

Keyboard shortcuts

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