config

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(path string, b []byte) (bool, error)

Create checks if a given config file already exists, if not it creates one

func ListTemplateFields

func ListTemplateFields(t *template.Template) []string

ListTemplateFields lists the fields used in a template. Sourced and adapted from: https://stackoverflow.com/a/40584967

Types

type Configuration

type Configuration struct {
	Services map[string]Service
}

Configuration holds a configuration, the key of the map is the name of the configuration. This is a string defined by the user to differentiate the various services started.

func (Configuration) Valid

func (s Configuration) Valid() bool

Valid validates a full configuration. This is mainly aiming at making sure we have unique port configurations.

type Service

type Service struct {
	Command     string `yaml:"command"`
	Environment string `yaml:"environment"`
	Enable      bool   `yaml:"enable"`
	// Variables are string mappings, the key can be used as $KEY in the "Command" string. It will be interpolated when
	// it is used to spawn the proc
	Variables []map[string]string `yaml:"variables"`
}

Service is a single configuration option for a service we want to run

func (Service) InterpolatedCommand

func (s Service) InterpolatedCommand() (string, error)

InterpolatedCommand is replacing the variable placeholders in a string with the variable value

func (Service) Valid

func (s Service) Valid() bool

Valid returns true if a service is enabled and has all the required values set

func (Service) VariableValue

func (s Service) VariableValue(name string) (bool, string)

Jump to

Keyboard shortcuts

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