client

package
v0.0.0-...-0325488 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2020 License: AGPL-3.0 Imports: 10 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Exec(name string, arg ...string) ([]byte, error)

	Chmod(path string, mode os.FileMode) error
	Chown(path string, uid, gid int) error
	Exists(path string) (bool, error)
	MkdirAll(path string, perm os.FileMode) error
	Write(path string, b []byte) error
	Append(path string, b []byte) error
	ReadFile(path string) ([]byte, error)
	Remove(src string) error
	Copy(src, dst string) error
	Move(src, dst string) error
}

Client is the responsible for executing commands in a OS. It can be the local OS or an OS connected through SSH

type Local

type Local struct{}

Local is the OS where the server is getting executed

func (*Local) Append

func (c *Local) Append(path string, b []byte) error

Append appends content to a file

func (*Local) Chmod

func (c *Local) Chmod(path string, mode os.FileMode) error

Chmod changes the mode of the named file to mode

func (*Local) Chown

func (c *Local) Chown(path string, uid, gid int) error

Chown changes the numeric uid and gid of the named file.

func (*Local) Copy

func (c *Local) Copy(src, dst string) error

Copy copies from a source to a destination. It's recursive, tries to preserve permissions and skips symlinks Copied from: https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func (*Local) Exec

func (c *Local) Exec(name string, arg ...string) ([]byte, error)

Exec executes a command to the server OS

func (*Local) Exists

func (c *Local) Exists(path string) (bool, error)

Exists checks if a file exists or not

func (*Local) MkdirAll

func (c *Local) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a new directory with the specified name and permission bits (before umask)

func (*Local) Move

func (c *Local) Move(src, dst string) error

Move moves a file from a source to a destination

func (*Local) ReadFile

func (c *Local) ReadFile(path string) ([]byte, error)

ReadFile returns the content of a file

func (*Local) Remove

func (c *Local) Remove(path string) error

Remove removes a file or a directory

func (*Local) Write

func (c *Local) Write(path string, b []byte) error

Write writes content to a file

type SSH

type SSH struct {
	Session *ssh.Session
}

SSH is an OS client using SSH

func (*SSH) Append

func (c *SSH) Append(path string, b []byte) error

Append appends content to a file

func (*SSH) Chmod

func (c *SSH) Chmod(path string, mode os.FileMode) error

Chmod changes the mode of the named file to mode

func (*SSH) Chown

func (c *SSH) Chown(path string, uid, gid int) error

Chown changes the numeric uid and gid of the named file.

func (*SSH) Copy

func (c *SSH) Copy(src, dst string) error

Copy copies from a source to a destination. It's recursive, tries to preserve permissions and skips symlinks Copied from: https://gist.github.com/r0l1/92462b38df26839a3ca324697c8cba04

func (*SSH) Exec

func (c *SSH) Exec(name string, arg ...string) ([]byte, error)

Exec executes a command through SSH

func (*SSH) Exists

func (c *SSH) Exists(path string) (bool, error)

Exists checks if a file exists or not TODO: Check that the error returned is os.IsNotExist()

func (*SSH) MkdirAll

func (c *SSH) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a new directory with the specified name and permission bits (before umask)

func (*SSH) Move

func (c *SSH) Move(src, dst string) error

Move moves a file from a source to a destination

func (*SSH) ReadFile

func (c *SSH) ReadFile(path string) ([]byte, error)

ReadFile returns the content of a file

func (*SSH) Remove

func (c *SSH) Remove(path string) error

Remove removes a file or a directory

func (*SSH) Write

func (c *SSH) Write(path string, b []byte) error

Write writes content to a file

Jump to

Keyboard shortcuts

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