Documentation
¶
Index ¶
- Constants
- Variables
- func Compress(stringHosts string) (string, error)
- func Count(stringHosts string) (int, error)
- func Expand(stringHosts string) (string, error)
- type HostGroups
- type HostList
- func (hl *HostList) Count() int
- func (hl *HostList) Delete(stringHosts string) (int, error)
- func (hl *HostList) DeleteHost(stringHost string) error
- func (hl *HostList) DeleteNth(n int) error
- func (hl *HostList) DerangedString() string
- func (hl *HostList) Find(stringHost string) (int, bool)
- func (hl *HostList) Intersects(stringHosts string) (*HostList, error)
- func (hl *HostList) IsEmpty() bool
- func (hl *HostList) Nth(n int) (string, error)
- func (hl *HostList) Pop() (hostName string, err error)
- func (hl *HostList) PopRange() (hostRange string, err error)
- func (hl *HostList) Push(stringHosts string) error
- func (hl *HostList) PushHost(stringHost string) error
- func (hl *HostList) PushList(other *HostList)
- func (hl *HostList) RangedString() string
- func (hl *HostList) ReplaceList(other *HostList)
- func (hl *HostList) Shift() (hostName string, err error)
- func (hl *HostList) ShiftRange() (hostRange string, err error)
- func (hl *HostList) Slice() []string
- func (hl *HostList) String() string
- func (hl *HostList) Uniq()
- func (hl *HostList) Within(stringHosts string) (bool, error)
- type HostSet
- func (hs *HostSet) Count() int
- func (hs *HostSet) Delete(stringHosts string) (int, error)
- func (hs *HostSet) DerangedString() string
- func (hs *HostSet) Insert(stringHosts string) (int, error)
- func (hs *HostSet) Intersects(stringHosts string) (*HostSet, error)
- func (hs *HostSet) MarshalJSON() ([]byte, error)
- func (hs *HostSet) Merge(other *HostSet) error
- func (hs *HostSet) Pop() (string, error)
- func (hs *HostSet) PopRange() (string, error)
- func (hs *HostSet) RangedString() string
- func (hs *HostSet) Replace(other *HostSet)
- func (hs *HostSet) Shift() (string, error)
- func (hs *HostSet) ShiftRange() (string, error)
- func (hs *HostSet) Slice() []string
- func (hs *HostSet) String() string
- func (hs *HostSet) Within(stringHosts string) (bool, error)
- type NumericList
- func (nl *NumericList) Add(i uint)
- func (nl *NumericList) Count() int
- func (nl *NumericList) Delete(i uint)
- func (nl *NumericList) Merge(other *NumericList)
- func (nl *NumericList) RangedString() string
- func (nl *NumericList) Replace(other *NumericList)
- func (nl *NumericList) Slice() (out []uint)
- func (nl *NumericList) String() string
- func (nl *NumericList) Uniq()
- type NumericSet
Constants ¶
const (
// MaxRange is the largest host range (hi - lo) supported
MaxRange = 16384
)
Variables ¶
var ( // ErrEmpty indicates empty host list ErrEmpty = errors.New("hostlist is empty") // ErrNotFound indicates valid hostname could not be found ErrNotFound = errors.New("hostname not found") )
Functions ¶
Types ¶
type HostGroups ¶
HostGroups maps a set of hosts to a string key value.
func (HostGroups) AddHost ¶
func (hg HostGroups) AddHost(key, host string) error
func (HostGroups) Keys ¶
func (hg HostGroups) Keys() []string
func (HostGroups) String ¶
func (hg HostGroups) String() string
type HostList ¶
HostList is a list of hostnames optimized for a "prefixXXXX" naming convention, where XXXX is a decimal, numeric suffix.
func MustCreate ¶
MustCreate is like Create but will panic on error.
func (*HostList) Delete ¶
Delete removes all hosts in the supplied string representation of a HostList. Returns the number of hosts successfully deleted.
func (*HostList) DeleteHost ¶
DeleteHost removes the first host that matches the supplied hostname. Returns an error if the HostList is empty or the hostname is not found.
func (*HostList) DeleteNth ¶
DeleteNth removes the host at position N in the HostList. Returns an error if the HostList is empty or the index is incorrect.
func (*HostList) DerangedString ¶
DerangedString returns a string containing the hostnames of every host in the HostList, without any bracketing.
func (*HostList) Find ¶
Find searches the HostList for the given hostname. Returns the index of the host and true if found; -1 and false if not.
func (*HostList) Intersects ¶
Intersects returns a *HostList containing hosts which are in both this HostList and the supplied hosts string.
func (*HostList) Nth ¶
Nth returns the string representation of the n-th host in the HostList. Returns an error if the index is invalid.
func (*HostList) Pop ¶
Pop returns the string representation of the last host pushed onto the HostList and then removes it from the HostList. Returns an error if the HostList is empty.
func (*HostList) PopRange ¶
PopRange returns the string representation of the last bracketed list of hosts. All hosts in the returned list are removed from the HostList. Returns an error if the HostList is empty.
func (*HostList) RangedString ¶
RangedString returns a string containing a bracketed HostList representation.
func (*HostList) ReplaceList ¶
ReplaceList replaces this HostList's contents with the supplied HostList.
func (*HostList) Shift ¶
Shift returns the string representation of the first host pushed onto the HostList and then removes it from the HostList. Returns an error if the HostList is empty.
func (*HostList) ShiftRange ¶
ShiftRange returns the string representation of the first bracketed list of hosts. All hosts in the returned list are removed from the HostList. Returns an error if the HostList is empty.
func (*HostList) Slice ¶
Slice returns a string slice containing the hostnames of every host in the HostList.
type HostSet ¶
HostSet is a special case of HostList which never contains duplicates and is always sorted alphanumerically based on prefix.
func MustCreateSet ¶
MustCreateSet is like CreateSet but will panic on error.
func (*HostSet) Delete ¶
Delete removes a host or list of hosts from the HostSet. Returns the number of hosts successfully removed.
func (*HostSet) DerangedString ¶
DerangedString returns a string containing the hostnames of every host in the HostSet, without any bracketing.
func (*HostSet) Insert ¶
Insert adds a host or list of hosts to the HostSet. Returns the number of non-duplicate hosts successfully added.
func (*HostSet) Intersects ¶
Intersects returns a *HostSet containing hosts which are in both this HostSet and the supplied hosts string.
func (*HostSet) MarshalJSON ¶
MarshalJSON outputs JSON representation of HostSet.
func (*HostSet) Pop ¶
Pop returns the string representation of the last host pushed onto the HostSet and then removes it from the HostSet. Returns an error if the HostSet is empty
func (*HostSet) PopRange ¶
PopRange returns the string representation of the last bracketed list of hosts. All hosts in the returned list are removed from the HostSet. Returns an error if the HostSet is empty.
func (*HostSet) RangedString ¶
RangedString returns a string containing a bracketed HostSet representation.
func (*HostSet) Shift ¶
Shift returns the string representation of the first host pushed onto the HostSet and then removes it from the HostSet. Returns an error if the HostSet is empty
func (*HostSet) ShiftRange ¶
ShiftRange returns the string representation of the first bracketed list of hosts. All hosts in the returned list are removed from the HostSet. Returns an error if the HostSet is empty.
type NumericList ¶
type NumericList struct {
// contains filtered or unexported fields
}
NumericList implements a subset of the HostList interface and is designed for use with lists of numbers.
func CreateNumericList ¶
func CreateNumericList(stringRanges string) (*NumericList, error)
CreateNumericList creates a NumericList that contains numeric entries and ranges from the supplied string representation.
func NewNumericList ¶
func NewNumericList(values ...uint) *NumericList
NewNumericList creates an initialized NumericList with optional starting values.
func (*NumericList) Add ¶
func (nl *NumericList) Add(i uint)
Add adds the supplied numeric entry to the NumericList.
func (*NumericList) Count ¶
func (nl *NumericList) Count() int
Count returns the number of numeric entries in the NumericList.
func (*NumericList) Delete ¶
func (nl *NumericList) Delete(i uint)
Delete removes the supplied numeric entry from the NumericList. No-op if the entry is not present.
func (*NumericList) Merge ¶
func (nl *NumericList) Merge(other *NumericList)
Merge merges the contents of this NumericList with those of the other NumericList.
func (*NumericList) RangedString ¶
func (nl *NumericList) RangedString() string
func (*NumericList) Replace ¶
func (nl *NumericList) Replace(other *NumericList)
Replace replaces the contents of this NumericList with those from the other NumericList.
func (*NumericList) Slice ¶
func (nl *NumericList) Slice() (out []uint)
Slice returns a slice of the numeric entries in the NumericList.
func (*NumericList) String ¶
func (nl *NumericList) String() string
func (*NumericList) Uniq ¶
func (nl *NumericList) Uniq()
Uniq sorts and removes duplicate entries from the NumericList.
type NumericSet ¶
type NumericSet struct {
NumericList
}
NumericSet is a special case of a NumericList that contains unique numeric entries.
func CreateNumericSet ¶
func CreateNumericSet(stringRanges string) (*NumericSet, error)
CreateNumericSet creates a NumericSet containing unique numeric entries and ranges from the supplied string representation.
func NewNumericSet ¶
func NewNumericSet(values ...uint) *NumericSet
NewNumericSet creates an initialized NumericSet with optional starting values.
func (*NumericSet) Add ¶
func (ns *NumericSet) Add(i uint)
Add adds the supplied numeric entry to the NumericSet.
func (*NumericSet) Delete ¶
func (ns *NumericSet) Delete(i uint)
Delete removes the supplied numeric entry from the NumericSet. No-op if the entry is not present.
func (*NumericSet) Merge ¶
func (ns *NumericSet) Merge(other *NumericSet)
Merge merges the contents of this NumericSet with those of the other NumericSet.
func (*NumericSet) Replace ¶
func (ns *NumericSet) Replace(other *NumericSet)
Replace replaces the contents of this NumericSet with those from the other NumericSet.