pkg

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2019 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains(s []string, e string) bool

Contains check string exist in slice

func CreateDir

func CreateDir(srv *drive.Service, parentId string, folderName string) (*drive.File, error)

createDir create directory under particular Parent ID inside google drive.

func CreateFile

func CreateFile(srv *drive.Service, name string, fileToUpload *os.File, parentId string) (*drive.File, error)

createFile create file(upload) into google drive.

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func Rename

func Rename(oldPath string, path string, f os.FileInfo) error

Rename rename existing file and replace with new path same like move.

func SendMail added in v1.4.0

func SendMail(mail *Mail, f *drive.File) error

SendMail send mail notification along with file's information.

Types

type Config

type Config struct {
	Connection string   `yaml:"connection,omitempty"`
	List       []string `yaml:"list,omitempty"`
}

type Configurations added in v1.3.0

type Configurations interface {
	GetConfig([]byte, *os.File) Configurations
	GetPath(s *Settings) string
}

Configurations defined method should implement by configuration files.

type Connection

type Connection struct {
	Name     string `yaml:"name,omitempty"`
	Driver   string `yaml:"driver,omitempty"`
	Host     string `yaml:"host,omitempty"`
	Port     string `yaml:"port,omitempty"`
	User     string `yaml:"user,omitempty"`
	Password string `yaml:"password,omitempty"`
}

Specifying possible connection to database server later able to pick which connection can be used to export .database

type Database

type Database struct {
	Connections []Connection
	Databases   []Config
}

func (Database) GetConfig added in v1.3.0

func (c Database) GetConfig(buf []byte, reader *os.File) Configurations

GetConfig get the marshalling config of Database configuration.

func (Database) GetPath added in v1.3.0

func (c Database) GetPath(s *Settings) string

GetPath get the database configuration file path.

type DriveItems

type DriveItems struct {
	Folder     string   `yaml:"folder,omitempty"`
	FileSystem bool     `yaml:"filesystem,omitempty"`
	Files      []string `yaml:"files,omitempty"`
	DriveId    string   `yaml:"driveid,omitempty"`
}

Google drive information that need to store into google drive.

type FileSystem

type FileSystem struct {
	Path []string `yaml:"path,omitempty"`
}

func (FileSystem) GetConfig added in v1.3.0

func (c FileSystem) GetConfig(buf []byte, reader *os.File) Configurations

GetConfig get the marshalling config of Filesystem configuration.

func (FileSystem) GetPath added in v1.3.0

func (c FileSystem) GetPath(s *Settings) string

GetPath get the filesystem configuration file path.

type Gdrive

type Gdrive struct {
	Config []DriveItems
}

func (Gdrive) GetConfig added in v1.3.0

func (c Gdrive) GetConfig(buf []byte, reader *os.File) Configurations

GetConfig get the marshalling config of Gdrive configuration.

func (Gdrive) GetPath added in v1.3.0

func (c Gdrive) GetPath(s *Settings) string

GetPath get the gdrive configuration file path.

type GoogleDrive

type GoogleDrive struct {
	drive.Service
	CredentialDirPath string
}

func (*GoogleDrive) GetClient

func (gd *GoogleDrive) GetClient(config *oauth2.Config) *http.Client

Retrieve a token, saves the token, then returns the generated client.

func (*GoogleDrive) GetTokenFromWeb

func (gd *GoogleDrive) GetTokenFromWeb(config *oauth2.Config) *oauth2.Token

Request a token from the web, then returns the retrieved token.

func (*GoogleDrive) New

func (gd *GoogleDrive) New() *drive.Service

New initialize services.

func (*GoogleDrive) SaveToken

func (gd *GoogleDrive) SaveToken(path string, token *oauth2.Token)

Saves a token to a file path.

func (*GoogleDrive) TokenFromFile

func (gd *GoogleDrive) TokenFromFile(file string) (*oauth2.Token, error)

Retrieves a token from a local file.

type Mail added in v1.3.0

type Mail struct {
	From       string `yaml:"from,omitempty"`
	To         string `yaml:"to,omitempty"`
	Host       string `yaml:"host,omitempty"`
	Port       string `yaml:"port,omitempty"`
	Username   string `yaml:"username,omitempty"`
	Password   string `yaml:"password,omitempty"`
	Encryption string `yaml:"encryption,omitempty"`
}

func (Mail) GetConfig added in v1.3.0

func (c Mail) GetConfig(buf []byte, reader *os.File) Configurations

GetConfig get the marshalling config of Mail configuration.

func (Mail) GetPath added in v1.3.0

func (c Mail) GetPath(s *Settings) string

GetPath get the mail configuration file path.

type Settings added in v1.1.0

type Settings struct {
	GdrivePath     string
	DatabasePath   string
	FilesystemPath string
	ConfigPath     string
	MailPath       string
}

Define all configurations path.

func New added in v1.1.0

func New() *Settings

New return default settings.

func (*Settings) ConstructPath added in v1.1.0

func (s *Settings) ConstructPath()

ConstructPath replace user defined path for all existing configurations path

func (*Settings) GetConfig added in v1.3.0

func (s *Settings) GetConfig(c Configurations) (Configurations, error)

GetConfig react as layer to get implemented configurations.

Jump to

Keyboard shortcuts

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