hostid

package
v0.15.17-hotfix.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: Apache-2.0 Imports: 8 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"`

	// Hostname is the hostname config.
	Hostname *HostnameConfig `yaml:"hostname"`
}

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 HostnameConfig added in v0.15.0

type HostnameConfig struct {
	// Format is a custom format to use, using go templates.
	// i.e. Using the M3DB operator if using no ID based on the disk
	// you can format it how the operator would expect:
	// '{"name":"{{.Hostname}}"}'
	Format string `yaml:"format"`
}

HostnameConfig contains the info needed to construct a HostnameConfig.

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