paths

package
v5.4.1+incompatible Latest Latest
Warning

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

Go to latest
Published: May 29, 2017 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package paths provides a common way to handle paths configuration for all Beats.

Currently the following paths are defined:

path.home - It’s the default folder for everything that doesn't fit in the categories below

path.data - Contains things that are expected to change often during normal operations (“registry” files, UUID file, etc.)

path.config - Configuration files and Elasticsearch template default location

These settings can be set via the configuration file or via command line flags. The CLI flags overwrite the configuration file options.

Use the Resolve function to resolve files to their absolute paths. For example, to look for a file in the config path:

cfgfilePath := paths.Resolve(paths.Config, "beat.yml"

Index

Constants

This section is empty.

Variables

View Source
var Paths = New()

Paths is the Path singleton on which the top level functions from this package operate.

Functions

func InitPaths

func InitPaths(cfg *Path) error

InitPaths sets the default paths in the configuration based on CLI flags, configuration file and default values. It also tries to create the data path with mode 0750 and returns an error on failure.

func Resolve

func Resolve(fileType FileType, path string) string

Resolve resolves a path to a location in one of the default folders. For example, Resolve(Home, "test") returns an absolute path for "test" in the home path.

Types

type FileType

type FileType string

FileType is an enumeration type representing the file types. Currently existing file types are: Home, Config, Data

const (
	Home   FileType = "home"
	Config FileType = "config"
	Data   FileType = "data"
	Logs   FileType = "logs"
)

type Path

type Path struct {
	Home   string
	Config string
	Data   string
	Logs   string
}

func New

func New() *Path

New creates a new Paths object with all values set to empty values.

func (*Path) InitPaths

func (paths *Path) InitPaths(cfg *Path) error

InitPaths sets the default paths in the configuration based on CLI flags, configuration file and default values. It also tries to create the data path with mode 0750 and returns an error on failure.

func (*Path) Resolve

func (paths *Path) Resolve(fileType FileType, path string) string

Resolve resolves a path to a location in one of the default folders. For example, Resolve(Home, "test") returns an absolute path for "test" in the home path.

func (*Path) String

func (paths *Path) String() string

String returns a textual representation

Jump to

Keyboard shortcuts

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