Documentation ¶
Index ¶
- Constants
- Variables
- func Add(h *Host)
- func CleanRelativePath(path string) (clean string, err error)
- func CopyAll(srcHost *Host, srcDir string, dstHost *Host, dstDir string) (err error)
- func CopyFile(srcHost *Host, srcPath string, dstHost *Host, dstPath string) (err error)
- func Delete(h *Host)
- func Geneos() string
- func Init()
- func ReadConfig()
- func UserHostsFilePath() string
- func WriteConfig() error
- func WriteConfigFile(file string, username string, perms fs.FileMode, conf *config.Config) (err error)
- type FileStat
- type Host
- func (h *Host) Chown(name string, uid, gid int) (err error)
- func (h *Host) Close()
- func (h *Host) CloseSFTP()
- func (h *Host) Create(path string, perms fs.FileMode) (out io.WriteCloser, err error)
- func (h *Host) CreateTempFile(path string, perms fs.FileMode) (f io.WriteCloser, name string, err error)
- func (h *Host) Dial() (s *ssh.Client, err error)
- func (h *Host) DialSFTP() (f *sftp.Client, err error)
- func (h *Host) Exists() bool
- func (h *Host) Failed() bool
- func (h *Host) Filepath(parts ...interface{}) string
- func (h *Host) FullName(name string) string
- func (h *Host) Glob(pattern string) (paths []string, err error)
- func (h *Host) Lchown(name string, uid, gid int) (err error)
- func (h *Host) Lstat(name string) (f fs.FileInfo, err error)
- func (h *Host) MkdirAll(path string, perm os.FileMode) (err error)
- func (h *Host) Open(name string) (f io.ReadSeekCloser, err error)
- func (h *Host) Path(path string) string
- func (h *Host) Range(hosts ...*Host) []*Host
- func (r *Host) ReadCert(path string) (cert *x509.Certificate, err error)
- func (h *Host) ReadDir(name string) (dirs []os.DirEntry, err error)
- func (h *Host) ReadFile(name string) (b []byte, err error)
- func (r *Host) ReadKey(path string) (key *rsa.PrivateKey, err error)
- func (h *Host) Readlink(file string) (link string, err error)
- func (h *Host) Remove(name string) (err error)
- func (h *Host) RemoveAll(name string) (err error)
- func (h *Host) Rename(oldpath, newpath string) (err error)
- func (h *Host) Run(name string, args ...string) (output []byte, err error)
- func (h *Host) SetOSReleaseEnv() (err error)
- func (h *Host) Stat(name string) (f fs.FileInfo, err error)
- func (h *Host) StatX(name string) (s FileStat, err error)
- func (h *Host) String() string
- func (h *Host) Symlink(target, path string) (err error)
- func (r *Host) WriteCert(path string, cert *x509.Certificate) (err error)
- func (r *Host) WriteCerts(path string, certs ...*x509.Certificate) (err error)
- func (h *Host) WriteFile(name string, data []byte, perm os.FileMode) (err error)
- func (r *Host) WriteKey(path string, key *rsa.PrivateKey) (err error)
Constants ¶
const ALLHOSTS = "all"
const ConfigSubdirName = "geneos"
const LOCALHOST = "localhost"
const OldUserHostFile = "geneos-hosts.json"
Variables ¶
var ( ErrInvalidArgs = fmt.Errorf("invalid argument") ErrNotSupported = fmt.Errorf("not supported") )
var UserHostFile = filepath.Join(ConfigSubdirName, "hosts.json")
Functions ¶
func CleanRelativePath ¶
given a path return a cleaned version. If the cleaning results in and absolute path or one that tries to ascend the tree then return an error
func CopyFile ¶
CopyFile copies a file between any combination of local or remote locations. Destination can be a directory or a file. Parent directories will be created. Any existing file will be overwritten.
func ReadConfig ¶ added in v1.4.1
func ReadConfig()
ReadConfig loads configuration entries from the default host configuration file. If that fails, it tries the old location and migrates that file to the new location if found.
func UserHostsFilePath ¶
func UserHostsFilePath() string
func WriteConfig ¶ added in v1.4.1
func WriteConfig() error
Types ¶
type Host ¶
var LOCAL, ALL *Host
func Get ¶
Get returns a pointer to Host value. If passed an empty name, returns nil. If passed the special values LOCALHOST or ALLHOSTS then it will return the respective special values LOCAL or ALL. Otherwise it tries to lookup an existing host with the given name to return or initialises a new value to return. This may not be an existing host.
XXX new needs the top level config and passes back a Sub()
func Match ¶
Match returns a slice of all matching Hosts. Intended for use in range loops where the host could be specific or 'all'. If passed an empty string then returns an empty slice.
func RemoteHosts ¶
func RemoteHosts() (hs []*Host)
RemoteHosts returns a slice of al valid remote hosts
func (*Host) CreateTempFile ¶
func (h *Host) CreateTempFile(path string, perms fs.FileMode) (f io.WriteCloser, name string, err error)
based on os.CreatTemp, but allows for hosts and much simplified given a remote and a full path, create a file with a suffix and return an io.File
func (*Host) Filepath ¶
Filepath returns an absolute path relative to the Geneos installation directory. Each argument is used as a path component and are joined using filepath.Join(). Each part can be a plain string or a type with a String() method - non-string types are rendered using fmt.Sprint() without further error checking.
func (*Host) Lchown ¶ added in v1.3.1
change the symlink ownership on local system, issue chown for remotes
func (*Host) Range ¶
Range will either return just the specific host it is called on, or if that is nil than the list of all hosts passed as args. If no args are passed and h is nil then all hosts are returned.
This is a convenience to avoid a double layer of if and range in callers than want to work on specific component types.
func (*Host) ReadCert ¶
func (r *Host) ReadCert(path string) (cert *x509.Certificate, err error)
read a PEM encoded cert from path, return the first found as a parsed certificate
func (*Host) ReadKey ¶
func (r *Host) ReadKey(path string) (key *rsa.PrivateKey, err error)
read a PEM encoded RSA private key from path. returns the first found as a parsed key
func (*Host) SetOSReleaseEnv ¶ added in v1.4.1
func (*Host) StatX ¶
StatX returns extended Stat info. Needs to be deprecated to support non LInux platforms
func (*Host) Symlink ¶
shim methods that test Host and direct to ssh / sftp / os at some point this should become interface based to allow other remote protocols cleanly
func (*Host) WriteCert ¶
func (r *Host) WriteCert(path string, cert *x509.Certificate) (err error)
write cert as PEM to path
func (*Host) WriteCerts ¶
func (r *Host) WriteCerts(path string, certs ...*x509.Certificate) (err error)
concatenate certs and write to path