hostlist

package
v0.0.0-...-a197711 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const SplitString = "\\s+|;|,"

SplitString is used for split Hostlist

Variables

This section is empty.

Functions

func Available

func Available() []string

Available returns all Hostlist's Name

func RegisterHostlist

func RegisterHostlist(builder constructor)

RegisterHostlist used in each realization's init function

Types

type FromCmd

type FromCmd struct {
	Args          []string
	LineProcessor func(string) []string
}

FromCmd is an abstract struct Other Hostlist that get hostlist from Command may want to inherit from it.

func (*FromCmd) Get

func (hc *FromCmd) Get() (list HostInfoList, err error)

Get is part of Hostlist Interface. It executes cmd from @Args, and translate each line to hostname by @LineProcessor

func (*FromCmd) ShouldBreak

func (hc *FromCmd) ShouldBreak() bool

ShouldBreak makes default disicion: fallthrough

type HostInfo

type HostInfo struct {
	User  string
	Cmd   string
	Index int
	Host  string
	Port  string
	Alias string
}

HostInfo describes a host more precisely

type HostInfoList

type HostInfoList []*HostInfo

HostInfoList is updated version for Hostlist

func GetHostList

func GetHostList(str, prefer string) (list HostInfoList, err error)

GetHostList returns the final host list. It'll use cache if possible.

func GetHostListNoCache

func GetHostListNoCache(str, prefer string) (list HostInfoList, err error)

GetHostListNoCache returns the final host list.

func MakeHostInfoListFromStringList

func MakeHostInfoListFromStringList(list []string) HostInfoList

MakeHostInfoListFromStringList helps migrate old implementation.

type Hostlist

type Hostlist interface {
	Name() string
	Priority() int // `0` has a higher Priority over `1`
	// Get() ([]string, error)
	Get() (HostInfoList, error)
	// if you're definitely sure that user want to use this Hostlist, return true.
	// for example, if user gives `-f ./xxx`, then obviously that he wants use this file: ./xxx.
	// in this case, no matter Get() method succeed or not, break.
	ShouldBreak() bool
}

Hostlist should be able to give a hostname list by a single string.

type WithFilter

type WithFilter interface {
	Hostlist
	Filter(HostInfoList) HostInfoList
}

WithFilter has a Filter over Hostlist Implementation then has the ability to filter hosts

Jump to

Keyboard shortcuts

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