hosts

package
v1.24.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: Apache-2.0 Imports: 9 Imported by: 50

Documentation

Index

Constants

View Source
const (
	GUARD_BEGIN = "# Begin host entries managed by kops - do not edit"
	GUARD_END   = "# End host entries managed by kops"
)

Variables

This section is empty.

Functions

func UpdateHostsFileWithRecords

func UpdateHostsFileWithRecords(p string, mutator func(guarded []string) (*HostMap, error)) error

UpdateHostsFileWithRecords updates /etc/hosts by applying the given mutation function.

Types

type HostMap added in v1.23.0

type HostMap struct {
	// contains filtered or unexported fields
}

HostMap holds a set of host to address mappings, a simplification of /etc/hosts.

func (*HostMap) Parse added in v1.23.0

func (m *HostMap) Parse(existing []string) []string

ParseHostMap parses lines from /etc/hosts (expected to be our guarded block) into a HostMap structure. It parses as much as it can, and returns invalid lines (which should ideally be empty)

func (*HostMap) ReplaceRecords added in v1.23.0

func (m *HostMap) ReplaceRecords(hostname string, addresses []string)

ReplaceRecords replaces all the addresses for the given hostname.

Jump to

Keyboard shortcuts

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