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 Delete(h *Host)
- func Geneos() string
- func Init()
- func ReadConfigFile()
- func UserHostsFilePath() string
- func WriteConfigFile() 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) FullName(name string) string
- func (h *Host) GeneosJoinPath(paths ...string) string
- func (h *Host) GetOSReleaseEnv() (err error)
- func (h *Host) Glob(pattern string) (paths []string, err error)
- func (h *Host) Lstat(name string) (s FileStat, 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 (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) Stat(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) WriteConfigFile(file string, username string, perms fs.FileMode, config interface{}) (err error)
- func (h *Host) WriteFile(path string, b []byte, perm os.FileMode) (err error)
- func (r *Host) WriteKey(path string, key *rsa.PrivateKey) (err error)
Constants ¶
const ALLHOSTS = "all"
const LOCALHOST = "localhost"
const UserHostFile = "geneos-hosts.json"
Variables ¶
var ( ErrInvalidArgs = fmt.Errorf("invalid argument") ErrNotSupported = fmt.Errorf("not supported") )
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 ReadConfigFile ¶
func ReadConfigFile()
func UserHostsFilePath ¶
func UserHostsFilePath() string
func WriteConfigFile ¶
func WriteConfigFile() error
Types ¶
type Host ¶
type Host struct { // use a viper to store config *viper.Viper // contains filtered or unexported fields }
var LOCAL, ALL *Host
func Match ¶
returns a slice of all matching Hosts. used mainly for range loops where the host could be specific or 'all'
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) GeneosJoinPath ¶
return an absolute path anchored in the root directory of the remote host this can also be LOCAL
func (*Host) GetOSReleaseEnv ¶
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) 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
func (*Host) WriteConfigFile ¶
func (h *Host) WriteConfigFile(file string, username string, perms fs.FileMode, config interface{}) (err error)
try to be atomic, lots of edge cases, UNIX/Linux only we know the size of config structs is typically small, so just marshal in memory