config

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package config contains helper functions for parsing of configuration files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseConfigFromYamlFile

func ParseConfigFromYamlFile(path string, cfg interface{}) error

ParseConfigFromYamlFile parses a configuration from a file in yaml format. The file's location is specified by the path parameter, and the resulting config is stored nto a structure specified by the cfg parameter..

func SaveConfigToYamlFile

func SaveConfigToYamlFile(cfg interface{}, path string, perm os.FileMode, comment string) error

SaveConfigToYamlFile saves the given configuration to a yaml-formatted file. If not empty, each line in the 'comment' parameter must be proceeded by '#'.

Types

type PluginConfig

type PluginConfig interface {
	// GetValue parse configuration for a plugin a store the results in data.
	// Argument data is a pointer to instance of a go structure.
	GetValue(data interface{}) (found bool, err error)

	// GetConfigName returns usually derived config name from plugin name
	// PluginName + "-config"
	GetConfigName() string
}

PluginConfig is API for plugins to access configuration.

Aim of this API is to let a particular plugin to bind it's configuration without knowing a particular key name. The key name is injected in flavor (Plugin Name).

func ForPlugin

func ForPlugin(pluginName string) PluginConfig

ForPlugin returns API that is injectable to a particular Plugin to read it's configuration.

It tries to lookup `plugin + "-config"` in flags.

Jump to

Keyboard shortcuts

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