manage

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: PostgreSQL Imports: 28 Imported by: 0

Documentation

Overview

Package manage provides the management interface for the backup system.

Package manage provides the management interface for the backup system.

Package manage provides the management interface for the backup system.

Package manage provides the interface for the backup system.

Package manage provides the interface for the backup system.

Package manage provides the management interface for the backup system.

Package manage provides the management interface for the backup system.

Index

Constants

View Source
const AGENT_KEYS = "agent/agent-keys.json.base64"

AGENT_KEYS must match the go:embed directive in agent/agent.go The path is relative to the git root of this repository.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Template lib.AgentTemplate
	// contains filtered or unexported fields
}

Agent starts a new Agent function chain

func NewAgent

func NewAgent() *Agent

NewAgent starts a new request for the backup agent.

func (*Agent) Bytes

func (a *Agent) Bytes() []byte

Bytes will convert the Agent to a []byte slice.

func (*Agent) Error

func (a *Agent) Error() error

Errors returns errors present, or nil otherwise.

func (*Agent) ErrorMessage

func (a *Agent) ErrorMessage() string

ErrorMessage returns the error message.

func (*Agent) HCL

func (a *Agent) HCL() *Agent

HCL will convert the Agent to HCL.

func (*Agent) HasErrors

func (a *Agent) HasErrors() bool

HasErrors returns true if errors are present.

func (*Agent) JSON

func (a *Agent) JSON() *Agent

JSON will convert the Agent to JSON.

func (*Agent) Load

func (a *Agent) Load(filename string) *Agent

Load and parse the Agent HCL file.

func (*Agent) LoadTemplate

func (a *Agent) LoadTemplate() *Agent

LoadTemplate will load the template agent.hcl embedded into the binary.

func (*Agent) Save

func (a *Agent) Save(filename string, format string) *Agent

Save the Agent HCL to a file.

func (*Agent) String

func (a *Agent) String() string

String will convert the Agent to a string.

func (*Agent) YAML

func (a *Agent) YAML() *Agent

YAML will convert the Agent to YAML.

type AgentParams

type AgentParams struct {
	PublicKey  string
	PrivateKey string
}

AgentParams defines the parameters used by the agent, namely the private key. The public key is included to output the hash for comparison purposes. This may help identify the agent.

type Azure

type Azure struct {
	AccountName *string `hcl:"azure_account_name,attr" json:"azure_account_name,omitempty"`
	AccountKey  *string `hcl:"azure_account_key,attr" json:"azure_account_key,omitempty"`
}

Azure config

type Backblaze

type Backblaze struct {
	AccountID  *string `hcl:"b2_account_id,attr" json:"b2_account_id,omitempty"`
	AccountKey *string `hcl:"b2_account_key,attr" json:"b2_account_key,omitempty"`
}

Backblaze config

type Build

type Build struct {
	AgentParams *AgentParams
	GitRoot     string
	// contains filtered or unexported fields
}

Build parameters for a target device.

func NewBuild

func NewBuild(params *BuildParams) *Build

NewBuild starts a new backup request.

func (*Build) BuildAgent

func (b *Build) BuildAgent() *Build

BuildAgent will build the package for deployment to an agent.

func (*Build) GatherInfo

func (b *Build) GatherInfo() *Build

GatherInfo will gather the external info for the build.

func (*Build) SetAgentParams

func (b *Build) SetAgentParams(ap *AgentParams) *Build

SetAgentParams will set the Agent parameters.

func (*Build) SetArch

func (b *Build) SetArch(arch *string) *Build

SetArch will set the Arch for the target build.

func (*Build) SetFilename

func (b *Build) SetFilename() *Build

SetFilename will set the filename according to the build parameters.

func (*Build) SetOS

func (b *Build) SetOS(o *string) *Build

SetOS will set the OS for the target build.

type BuildParams

type BuildParams struct {
	// OS is the output of uname -s for *nix and
	//       Windows            |     *nix
	// "Windows" | "Windows_NT" | `uname -s`
	OS string
	// Arch is the output of uname -m for *nix and
	// "amd64" | "386" | "arm" | "arm64" | `uname -m`
	Arch      string
	Filename  string
	Version   string
	BuildTime string
	BuildEnv  string
	GitCommit string
	GitTag    string
	GitBranch string
	URL       string
	Authors   string
	License   string
	Copyright string
}

BuildParams defines the parameters used during building. Some of these options will not be set when using "go build" to build the 'backup' cli tool. Most of these should be set when building the 'a8n-backup' agent that is run on the endpoints.

type CustomFields

type CustomFields struct {
	BackupSettings string `hcl:"a8n_backup_backup_settings,attr" json:"encrypted"`
	TRMMPublicKey  string `hcl:"a8n_backup_trmm_public_key,attr" json:"public_key"`
}

type File

type File struct {
	// contains filtered or unexported fields
}

File contains the information about the file.

type FileOptions

type FileOptions struct {
	Action string
}

FileOptions contains options for the FileRepo

type FileRepo

type FileRepo struct {
	// contains filtered or unexported fields
}

FileRepo is the main structure for a file repository.

func NewFileRepo

func NewFileRepo(options *FileOptions) *FileRepo

NewFileRepo starts a new FileRepo request.

func (*FileRepo) Download

func (fr *FileRepo) Download(src string, dst string) *FileRepo

Download will download a file.

func (*FileRepo) Error

func (fr *FileRepo) Error() error

Errors returns errors present, or nil otherwise.

func (*FileRepo) ErrorMessage

func (fr *FileRepo) ErrorMessage() string

ErrorMessage returns the error message.

func (*FileRepo) HasErrors

func (fr *FileRepo) HasErrors() bool

HasErrors returns true if errors are present.

func (*FileRepo) Search

func (fr *FileRepo) Search(term string) *FileRepo

Search will search for files.

func (*FileRepo) SetOptions

func (fr *FileRepo) SetOptions(options *ServerOptions) *FileRepo

SetOptions will set the parameters for the server, like domain, path, and authentication. Environmental variables are checked first, then options provided.

func (*FileRepo) ToString

func (fr *FileRepo) ToString() string

ToString will convert the response to a string.

func (*FileRepo) Upload

func (fr *FileRepo) Upload(src string) *FileRepo

Upload will upload a file. TODO: Add a check to see if the file exists in the repository.

type FileServer

type FileServer struct {
	Options  *ServerOptions
	Request  *http.Request
	Response []byte
	// contains filtered or unexported fields
}

FileServer contains information about the file server.

type GHSAccessConf

type GHSAccessConf struct {
	Upload       bool             `yaml:"upload" json:"upload"`
	Delete       bool             `yaml:"delete" json:"delete"`
	Users        []GHSUserControl `yaml:"users" json:"users"`
	AccessTables []GHSAccessTable `yaml:"accessTables" json:"AccessTables"`
}

GHSAccessConf is the access configuration for GoHttpServer https://github.com/codeskyblue/gohttpserver/blob/26545513de66f0cf6975bfad48358586dc413779/httpstaticserver.go#L490

type GHSAccessTable

type GHSAccessTable struct {
	Regex string `json:"Regex"`
	Allow bool   `json:"Allow"`
}

GHSAccessTable is the access permissions for GoHttpServer https://github.com/codeskyblue/gohttpserver/blob/26545513de66f0cf6975bfad48358586dc413779/httpstaticserver.go#L469

type GHSHTTPFileInfo

type GHSHTTPFileInfo struct {
	Name    string `json:"name"`
	Path    string `json:"path"`
	Type    string `json:"type"`
	Size    int64  `json:"size"`
	ModTime int64  `json:"mtime"`
}

GHSHTTPFileInfo is the file information for GoHttpServer https://github.com/codeskyblue/gohttpserver/blob/26545513de66f0cf6975bfad48358586dc413779/httpstaticserver.go#L469

type GHSResponse

type GHSResponse struct {
	Auth  GHSAccessConf     `json:"auth"`
	Files []GHSHTTPFileInfo `json:"files"`
}

GHSResponse is the response object from GoHttpServer

type GHSUserControl

type GHSUserControl struct {
	Email  string `json:"Email"`
	Upload bool   `json:"Upload"`
	Delete bool   `json:"Delete"`
	Token  string `json:"Token"`
}

GHSUserControl is the user information for GoHttpServer https://github.com/codeskyblue/gohttpserver/blob/26545513de66f0cf6975bfad48358586dc413779/httpstaticserver.go#L469

type Google

type Google struct {
	ProjectID              *string `hcl:"google_project_id,attr" json:"google_project_id,omitempty"`
	ApplicationCredentials *string `hcl:"google_application_credentials,attr" json:"google_application_credentials,omitempty"`
}

Google config

type KeyPair

type KeyPair struct {
	Public  string `hcl:"public_key" json:"public_key"`
	Private string `hcl:"private_key" json:"private_key"`
}

KeyPair represents the public/private key pair in the HCL template.

type Manage

type Manage struct {
	Agent   *Agent
	Secrets *Secrets
	TRMM    *TRMM
	Message *crypto.Message
	// contains filtered or unexported fields
}

Manage will start a Manage function chain.

func NewManage

func NewManage(options Options) *Manage

NewManage starts a new Manage request

func (*Manage) Error

func (m *Manage) Error() error

Errors returns errors present, or nil otherwise.

func (*Manage) ErrorMessage

func (m *Manage) ErrorMessage() string

ErrorMessage returns the error message.

func (*Manage) HasErrors

func (m *Manage) HasErrors() bool

HasErrors returns true if errors are present.

func (*Manage) LoadTemplates

func (m *Manage) LoadTemplates() *Manage

LoadTemplates will load a blank config for the Agent, Secrets and TRMM configs. HCL _can_ preserve the original file structure if hclwrite is used. Currently, that is not the case. https://pkg.go.dev/github.com/hashicorp/hcl2/gohcl#EncodeIntoBody https://pkg.go.dev/github.com/hashicorp/hcl2/hclwrite#example-package-GenerateFromScratch

func (*Manage) RemoveEmbedFile

func (m *Manage) RemoveEmbedFile(gitRoot string) *Manage

RemoveEmbedFile will save the private key to the embedded file for the agent module.

func (*Manage) RunManage

func (m *Manage) RunManage() *Manage

RunManage will run the management command (`backup manage ...`).

func (*Manage) SaveEmbedFile

func (m *Manage) SaveEmbedFile(gitRoot string) *Manage

SaveEmbedFile will save the private key to the embedded file for the agent module.

type Options

type Options struct {
	ConfigDir     string
	AgentConfig   string
	Secrets       string
	SecretsAction string // "load" or "save"
	TRMM          string
	BuildParams   *BuildParams
	AgentParams   *AgentParams
}

Options for the manage command. This is more like a config than options.

type Rest

type Rest struct {
	Host     *string `hcl:"host,attr" json:"host,omitempty"`
	Port     *string `hcl:"port,attr" json:"port,omitempty" default:"443"`
	Username *string `hcl:"username,attr" json:"username,omitempty"`
	Password *string `hcl:"password,attr" json:"password,omitempty"`
	Path     *string `hcl:"path,attr" json:"path,omitempty" default:""`
}

Rest config for a rest-server

type Restic

type Restic struct {
	Repository                   *string `hcl:"repository,attr" json:"repository"`
	Password                     *string `hcl:"password,attr" json:"password,omitempty"` // Encryption password
	KeyHint                      *string `hcl:"key_hint,attr" json:"key_hint,omitempty"`
	OSStorageUrl                 *string `hcl:"os_storage_url,attr" json:"os_storage_url,omitempty"`
	OSAuthToken                  *string `hcl:"os_auth_token,attr" json:"os_auth_token,omitempty"`
	B2AccountID                  *string `hcl:"b2_account_id,attr" json:"b2_account_id,omitempty"`
	B2AccountKey                 *string `hcl:"b2_account_key,attr" json:"b2_account_key,omitempty"`
	AzureAccountName             *string `hcl:"azure_account_name,attr" json:"azure_account_name,omitempty"`
	AzureAccountKey              *string `hcl:"azure_account_key,attr" json:"azure_account_key,omitempty"`
	GoogleProjectID              *string `hcl:"google_project_id,attr" json:"google_project_id,omitempty"`
	GoogleApplicationCredentials *string `hcl:"google_application_credentials,attr" json:"google_application_credentials,omitempty"`
	BWLimit                      *string `hcl:"bw_limit,attr" json:"bw_limit,omitempty"`
}

Restic config See https://restic.readthedocs.io/en/latest/040_backup.html#environment-variables

type Secrets

type Secrets struct {
	Agent    *crypto.KeyPair
	TRMM     *crypto.KeyPair
	Template SecretsTemplate
	// contains filtered or unexported fields
}

Secrets starts a new Secrets function chain

func NewSecrets

func NewSecrets() *Secrets

NewSecrets starts a new encryption request

func (*Secrets) Error

func (s *Secrets) Error() error

Errors returns errors present, or nil otherwise.

func (*Secrets) ErrorMessage

func (s *Secrets) ErrorMessage() string

ErrorMessage returns the error message.

func (*Secrets) GenerateKeys

func (s *Secrets) GenerateKeys() *Secrets

GenerateKeys will generate public/private encryption keys and store them in the struct.

func (*Secrets) HCL

func (s *Secrets) HCL() string

HCL will marshal the secrets structure to HCL.

func (*Secrets) HasErrors

func (s *Secrets) HasErrors() bool

HasErrors returns true if errors are present.

func (*Secrets) JSON

func (s *Secrets) JSON() string

JSON will marshal the secrets structure to JSON.

func (*Secrets) Load

func (s *Secrets) Load(filename string) *Secrets

Load and parse the Secrets HCL file.

func (*Secrets) LoadTemplate

func (s *Secrets) LoadTemplate() *Secrets

LoadTemplate will load the template secrets.hcl.

func (*Secrets) Save

func (s *Secrets) Save(filename string, format string) *Secrets

Save the Secrets HCL to a file.

func (*Secrets) String

func (s *Secrets) String() string

String will convert the secrets structure to a JSON string.

type SecretsTemplate

type SecretsTemplate struct {
	Agent KeyPair `hcl:"agent,block" json:"agent"`
	TRMM  KeyPair `hcl:"trmm,block" json:"trmm"`
}

SecretsTemplate represents the template for loading/saving to HCL.

type ServerOptions

type ServerOptions struct {
	Domain   string
	Path     string
	FilePath string
	AuthType string // "basic" | "none"
	Username string
	Password string
}

ServerOptions will set the options for the server.

type TRMM

type TRMM struct {
	Template Template
	// contains filtered or unexported fields
}

TRMM starts a new TRMM function chain

func NewTRMM

func NewTRMM() *TRMM

NewTRMM starts a new TRMM request

func (*TRMM) Bytes

func (t *TRMM) Bytes() []byte

Bytes will convert the TRMM structure to a []byte slice.

func (*TRMM) Error

func (t *TRMM) Error() error

Errors returns errors present, or nil otherwise.

func (*TRMM) ErrorMessage

func (t *TRMM) ErrorMessage() string

ErrorMessage returns the error message.

func (*TRMM) HCL

func (t *TRMM) HCL() *TRMM

HCL will convert the TRMM structure to HCL.

func (*TRMM) HasErrors

func (t *TRMM) HasErrors() bool

HasErrors returns true if errors are present.

func (*TRMM) JSON

func (t *TRMM) JSON() *TRMM

JSON will convert the TRMM structure to JSON.

func (*TRMM) Load

func (t *TRMM) Load(filename string) *TRMM

Load and parse the TRMM HCL file.

func (*TRMM) LoadTemplate

func (t *TRMM) LoadTemplate() *TRMM

LoadTemplate will load the template trmm.hcl embedded into the binary.

func (*TRMM) Save

func (t *TRMM) Save(filename string, format string) *TRMM

Save the TRMM HCL to a file.

func (*TRMM) String

func (t *TRMM) String() string

String will convert the TRMM structure to a string.

func (*TRMM) YAML

func (t *TRMM) YAML() *TRMM

YAML will convert the TRMM structure to YAML.

type Template

type Template struct {
	CustomFields CustomFields `hcl:"custom_fields,block" json:"custom_fields"`
	Hosting      lib.Hosting  `hcl:"hosting,block" json:"hosting"`
}

Template manages the config for the Tactical RMM integration.

Jump to

Keyboard shortcuts

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