hostid

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2019 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Overview

Package hostid provides a configuration struct for resolving a host ID from YAML.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	// Resolver is the resolver for the host ID.
	Resolver Resolver `yaml:"resolver"`

	// Value is the config specified host ID if using config host ID resolver.
	Value *string `yaml:"value"`

	// EnvVarName is the environment specified host ID if using environment host ID resolver.
	EnvVarName *string `yaml:"envVarName"`

	// File is the file config.
	File *FileConfig `yaml:"file"`
}

Configuration is the configuration for resolving a host ID.

func (Configuration) Resolve

func (c Configuration) Resolve() (string, error)

Resolve returns the resolved host ID given the configuration.

type FileConfig

type FileConfig struct {
	// Path of the file containing the host ID.
	Path string `yaml:"path"`

	// Timeout to wait for the file to be non-empty.
	Timeout *time.Duration `yaml:"timeout"`
}

FileConfig contains the info needed to construct a FileResolver.

type IDResolver

type IDResolver interface {
	ID() (string, error)
}

IDResolver represents a method of resolving host identity.

type Resolver

type Resolver string

Resolver is a type of host ID resolver

const (
	// HostnameResolver resolves host using the hostname returned by OS
	HostnameResolver Resolver = "hostname"
	// ConfigResolver resolves host using a value provided in config
	ConfigResolver Resolver = "config"
	// EnvironmentResolver resolves host using an environment variable
	// of which the name is provided in config
	EnvironmentResolver Resolver = "environment"
	// FileResolver reads its identity from a non-empty file.
	FileResolver Resolver = "file"
)

Jump to

Keyboard shortcuts

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