Compare commits
36 Commits
82fe80dd0b
...
v0.0.2
Author | SHA1 | Date | |
---|---|---|---|
1c7515a633 | |||
8079030752 | |||
15019fbd61 | |||
3960d5ec75 | |||
9f615b0750 | |||
8e9d563d1f | |||
e2f4553303 | |||
15a7ca6c3d | |||
ae87ccb4b5 | |||
6b85913316 | |||
9d07298eb0 | |||
9648fe8ab9 | |||
14650c4db1 | |||
3863f34fc0 | |||
abec574b76 | |||
198d0ca4b9 | |||
b25c7ea5ea | |||
59c2c028c8 | |||
2f73df73b1 | |||
34af511a95 | |||
c45b537b3f | |||
dabbf6d795 | |||
a5f4ba3c2a | |||
42034a7c15 | |||
d701d26938 | |||
0a1dbb61a1 | |||
52d49e70f2 | |||
2daae5cf9e | |||
ab12b02dc9 | |||
e937259b0f | |||
0ee7267a18 | |||
6304866953 | |||
62be691fea | |||
efbc7619f1 | |||
c39330f3a0 | |||
0203cb4286 |
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
dist/
|
43
.goreleaser.yaml
Normal file
43
.goreleaser.yaml
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||||
|
# Make sure to check the documentation at https://goreleaser.com
|
||||||
|
before:
|
||||||
|
hooks:
|
||||||
|
# You may remove this if you don't use go modules.
|
||||||
|
- go mod tidy
|
||||||
|
builds:
|
||||||
|
- env:
|
||||||
|
- CGO_ENABLED=0
|
||||||
|
goos:
|
||||||
|
- linux
|
||||||
|
|
||||||
|
archives:
|
||||||
|
- format: tar.gz
|
||||||
|
# this name template makes the OS and Arch compatible with the results of uname.
|
||||||
|
name_template: >-
|
||||||
|
{{ .ProjectName }}_
|
||||||
|
{{- title .Os }}_
|
||||||
|
{{- if eq .Arch "amd64" }}x86_64
|
||||||
|
{{- else if eq .Arch "386" }}i386
|
||||||
|
{{- else }}{{ .Arch }}{{ end }}
|
||||||
|
{{- if .Arm }}v{{ .Arm }}{{ end }}
|
||||||
|
# use zip for windows archives
|
||||||
|
format_overrides:
|
||||||
|
- goos: windows
|
||||||
|
format: zip
|
||||||
|
checksum:
|
||||||
|
name_template: 'checksums.txt'
|
||||||
|
snapshot:
|
||||||
|
name_template: "{{ incpatch .Version }}-next"
|
||||||
|
changelog:
|
||||||
|
sort: asc
|
||||||
|
filters:
|
||||||
|
exclude:
|
||||||
|
- '^docs:'
|
||||||
|
- '^test:'
|
||||||
|
|
||||||
|
gitea_urls:
|
||||||
|
api: https://git.andrewnw.xyz/api/v1
|
||||||
|
download: https://git.andrewnw.xyz
|
||||||
|
# The lines beneath this are called `modelines`. See `:help modeline`
|
||||||
|
# Feel free to remove those if you don't want/use them.
|
||||||
|
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
13
License
Normal file
13
License
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
Copyright 2023 Andrew Woodlee
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
5
Makefile
Normal file
5
Makefile
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
build:
|
||||||
|
go build
|
||||||
|
|
||||||
|
gorealeaser-build:
|
||||||
|
goreleaser release --snapshot --rm-dist
|
100
README.md
Normal file
100
README.md
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
# Backy - an application to manage backups
|
||||||
|
|
||||||
|
This app is in development, and is currently not stable. Expect core functionality to possiblly break.
|
||||||
|
|
||||||
|
## Installing
|
||||||
|
|
||||||
|
To install:
|
||||||
|
|
||||||
|
`go install git.andrewnw.xyz/CyberShell/backy@master`
|
||||||
|
|
||||||
|
This assumes you already have a working Go environment, if not please see [this page](https://golang.org/doc/install) first.
|
||||||
|
|
||||||
|
To run a config:
|
||||||
|
|
||||||
|
`backy backup`
|
||||||
|
|
||||||
|
Or to use a specific file:
|
||||||
|
```backy backup -c /path/to/file```
|
||||||
|
|
||||||
|
If you leave the config path blank, the following paths will be searched in order:
|
||||||
|
|
||||||
|
- `./backy.yaml`
|
||||||
|
- `~/.config/backy.yaml`
|
||||||
|
|
||||||
|
Create a file at `~/.config/backy.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
commands:
|
||||||
|
stop-docker-container:
|
||||||
|
cmd: docker
|
||||||
|
cmdArgs:
|
||||||
|
- compose
|
||||||
|
- -f /some/path/to/docker-compose.yaml
|
||||||
|
- down
|
||||||
|
# if host is not defined,
|
||||||
|
host: some-host
|
||||||
|
env: ~/path/to/env/file
|
||||||
|
backup-docker-container-script:
|
||||||
|
cmd: /path/to/script
|
||||||
|
host: some-host
|
||||||
|
env: ~/path/to/env/file
|
||||||
|
shell-cmd:
|
||||||
|
cmd: rsync
|
||||||
|
shell: bash
|
||||||
|
cmdArgs:
|
||||||
|
- -av some-host:/path/to/data ~/Docker/Backups/docker-data
|
||||||
|
hostname:
|
||||||
|
cmd: hostname
|
||||||
|
|
||||||
|
cmd-configs:
|
||||||
|
# this can be any name you want
|
||||||
|
cmds-to-run:
|
||||||
|
# all commands have to be defined
|
||||||
|
order:
|
||||||
|
- stop-docker-container
|
||||||
|
- backup-docker-container-script
|
||||||
|
- shell-cmd
|
||||||
|
- hostname
|
||||||
|
notifications:
|
||||||
|
- matrix
|
||||||
|
hostname:
|
||||||
|
order:
|
||||||
|
- hostname
|
||||||
|
notifications:
|
||||||
|
- prod-email
|
||||||
|
|
||||||
|
hosts:
|
||||||
|
some-host:
|
||||||
|
config:
|
||||||
|
usefile: true
|
||||||
|
user: root
|
||||||
|
private-key-path:
|
||||||
|
|
||||||
|
logging:
|
||||||
|
verbose: true
|
||||||
|
file: /path/to/logs/commands.log
|
||||||
|
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
prod-email:
|
||||||
|
id: prod-email
|
||||||
|
type: mail
|
||||||
|
host: yourhost.tld
|
||||||
|
port: 587
|
||||||
|
senderAddress: email@domain.tld
|
||||||
|
to:
|
||||||
|
- admin@domain.tld
|
||||||
|
username: smtp-username@domain.tld
|
||||||
|
password: your-password-here
|
||||||
|
matrix:
|
||||||
|
id: matrix
|
||||||
|
type: matrix
|
||||||
|
homeserver: your-home-server.tld
|
||||||
|
room-id: room-id
|
||||||
|
access-token: your-access-token
|
||||||
|
user-id: your-user-id
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Note, let me know if a path lookup fails due to using Go's STDLib `os`
|
32
backup.go
32
backup.go
@ -1,32 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
)
|
|
||||||
|
|
||||||
type commandBackup struct {
|
|
||||||
cmd string
|
|
||||||
args []string
|
|
||||||
}
|
|
||||||
|
|
||||||
type directory struct {
|
|
||||||
dst string
|
|
||||||
src string
|
|
||||||
}
|
|
||||||
|
|
||||||
type backup struct {
|
|
||||||
backupType string
|
|
||||||
local bool
|
|
||||||
commandToRunBefore commandBackup
|
|
||||||
commandToRunAfter commandBackup
|
|
||||||
directories directory
|
|
||||||
name string
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
|
|
||||||
viper.AddConfigPath(".")
|
|
||||||
viper.SetConfigName("config") // name of config file (without extension)
|
|
||||||
viper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name
|
|
||||||
|
|
||||||
}
|
|
9
backy.go
Normal file
9
backy.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.andrewnw.xyz/CyberShell/backy/cmd"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
cmd.Execute()
|
||||||
|
}
|
1
cmd/.gitignore
vendored
Normal file
1
cmd/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.yaml
|
32
cmd/backup.go
Normal file
32
cmd/backup.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||||
|
"git.andrewnw.xyz/CyberShell/backy/pkg/notifications"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
backupCmd = &cobra.Command{
|
||||||
|
Use: "backup [--commands==list1,list2]",
|
||||||
|
Short: "Runs commands defined in config file.",
|
||||||
|
Long: `Backup executes commands defined in config file,
|
||||||
|
use the -cmds flag to execute the specified commands.`,
|
||||||
|
Run: Backup,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
var CmdList []string
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// cobra.OnInitialize(initConfig)
|
||||||
|
|
||||||
|
backupCmd.Flags().StringSliceVar(&CmdList, "cmds", nil, "Accepts a comma-separated list of command lists to execute.")
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func Backup(cmd *cobra.Command, args []string) {
|
||||||
|
config := backy.ReadAndParseConfigFile(cfgFile)
|
||||||
|
notifications.SetupNotify(*config)
|
||||||
|
config.RunBackyConfig()
|
||||||
|
}
|
@ -1,223 +0,0 @@
|
|||||||
package backy
|
|
||||||
|
|
||||||
import (
|
|
||||||
"os/exec"
|
|
||||||
|
|
||||||
"github.com/melbahja/goph"
|
|
||||||
|
|
||||||
"github.com/spf13/viper"
|
|
||||||
)
|
|
||||||
|
|
||||||
type logging struct {
|
|
||||||
err error
|
|
||||||
output string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Host struct {
|
|
||||||
Empty bool
|
|
||||||
Host string
|
|
||||||
Port uint16
|
|
||||||
PrivateKeyPath string
|
|
||||||
PrivateKeyPassword string
|
|
||||||
User string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Command struct {
|
|
||||||
Empty bool
|
|
||||||
Remote bool
|
|
||||||
RemoteHost Host
|
|
||||||
Cmd string
|
|
||||||
Args []string
|
|
||||||
}
|
|
||||||
type Commands struct {
|
|
||||||
Before Command
|
|
||||||
Backup Command
|
|
||||||
After Command
|
|
||||||
}
|
|
||||||
|
|
||||||
type BackupConfig struct {
|
|
||||||
Name string
|
|
||||||
BackupType string
|
|
||||||
ConfigPath string
|
|
||||||
|
|
||||||
Cmds Commands
|
|
||||||
|
|
||||||
dstDir string
|
|
||||||
srcDir string
|
|
||||||
}
|
|
||||||
|
|
||||||
func ReadConfig(backup string, config viper.Viper) (*viper.Viper, error) {
|
|
||||||
err := viper.ReadInConfig()
|
|
||||||
if err != nil {
|
|
||||||
return &viper.Viper{}, err
|
|
||||||
}
|
|
||||||
|
|
||||||
conf := config.Sub("backup." + backup)
|
|
||||||
|
|
||||||
backupConfig := config.Unmarshal(&conf)
|
|
||||||
if backupConfig == nil {
|
|
||||||
return &viper.Viper{}, backupConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
return conf, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// pass Name-level (i.e. "backups."+configName) to function
|
|
||||||
func CreateConfig(backup BackupConfig) BackupConfig {
|
|
||||||
newBackupConfig := BackupConfig{
|
|
||||||
Name: backup.Name,
|
|
||||||
BackupType: backup.BackupType,
|
|
||||||
|
|
||||||
dstDir: backup.dstDir,
|
|
||||||
srcDir: backup.srcDir,
|
|
||||||
|
|
||||||
ConfigPath: backup.ConfigPath,
|
|
||||||
}
|
|
||||||
|
|
||||||
if !backup.Cmds.Before.Empty {
|
|
||||||
newBackupConfig.Cmds.Before.Cmd = backup.Cmds.Before.Cmd
|
|
||||||
newBackupConfig.Cmds.After.Args = backup.Cmds.Before.Args
|
|
||||||
if backup.Cmds.Before.Remote {
|
|
||||||
newBackupConfig.Cmds.Before.RemoteHost.Host = backup.Cmds.Before.RemoteHost.Host
|
|
||||||
newBackupConfig.Cmds.Before.RemoteHost.Port = backup.Cmds.Before.RemoteHost.Port
|
|
||||||
newBackupConfig.Cmds.Before.RemoteHost.PrivateKeyPath = backup.Cmds.Before.RemoteHost.PrivateKeyPath
|
|
||||||
} else {
|
|
||||||
newBackupConfig.Cmds.Before.RemoteHost.Empty = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !backup.Cmds.Backup.Empty {
|
|
||||||
newBackupConfig.Cmds.Backup.Cmd = backup.Cmds.Backup.Cmd
|
|
||||||
newBackupConfig.Cmds.Backup.Args = backup.Cmds.Backup.Args
|
|
||||||
if backup.Cmds.Backup.Remote {
|
|
||||||
newBackupConfig.Cmds.Backup.RemoteHost.Host = backup.Cmds.Backup.RemoteHost.Host
|
|
||||||
newBackupConfig.Cmds.Backup.RemoteHost.Port = backup.Cmds.Backup.RemoteHost.Port
|
|
||||||
newBackupConfig.Cmds.Backup.RemoteHost.PrivateKeyPath = backup.Cmds.Backup.RemoteHost.PrivateKeyPath
|
|
||||||
} else {
|
|
||||||
newBackupConfig.Cmds.Backup.RemoteHost.Empty = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !backup.Cmds.After.Empty {
|
|
||||||
newBackupConfig.Cmds.After.Cmd = backup.Cmds.After.Cmd
|
|
||||||
newBackupConfig.Cmds.After.Args = backup.Cmds.After.Args
|
|
||||||
if backup.Cmds.After.Remote {
|
|
||||||
newBackupConfig.Cmds.After.RemoteHost.Host = backup.Cmds.After.RemoteHost.Host
|
|
||||||
newBackupConfig.Cmds.After.RemoteHost.Port = backup.Cmds.After.RemoteHost.Port
|
|
||||||
newBackupConfig.Cmds.After.RemoteHost.PrivateKeyPath = backup.Cmds.After.RemoteHost.PrivateKeyPath
|
|
||||||
} else {
|
|
||||||
newBackupConfig.Cmds.Before.RemoteHost.Empty = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return backup
|
|
||||||
}
|
|
||||||
|
|
||||||
// writes config to file
|
|
||||||
func WriteConfig(config viper.Viper, backup BackupConfig) error {
|
|
||||||
configName := "backup." + backup.Name
|
|
||||||
config.Set(configName+".BackupType", backup.BackupType)
|
|
||||||
if !backup.Cmds.After.Empty {
|
|
||||||
config.Set(configName+".Cmds.After.Cmd", backup.Cmds.After.Cmd)
|
|
||||||
config.Set(configName+".Cmds.After.Args", backup.Cmds.After.Args)
|
|
||||||
if backup.Cmds.Before.Remote {
|
|
||||||
config.Set(configName+".Cmds.After.RemoteHost.Host", backup.Cmds.After.RemoteHost.Host)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
config.Set(configName+"..Cmds.backup.Cmd", backup.Cmds.Backup.Cmd)
|
|
||||||
if !backup.Cmds.Before.Empty {
|
|
||||||
config.Set(configName+"Cmds.Before.Cmd", backup.Cmds.Before.Cmd)
|
|
||||||
config.Set(configName+"Cmds.Before.Args", backup.Cmds.Before.Args)
|
|
||||||
}
|
|
||||||
err := config.WriteConfig()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Runs a backup configuration
|
|
||||||
*/
|
|
||||||
func Run(backup BackupConfig) logging {
|
|
||||||
|
|
||||||
beforeConfig := backup.Cmds.Before
|
|
||||||
beforeOutput := runCmd(beforeConfig)
|
|
||||||
if beforeOutput.err != nil {
|
|
||||||
return logging{
|
|
||||||
output: beforeOutput.output,
|
|
||||||
err: beforeOutput.err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
backupConfig := backup.Cmds.Backup
|
|
||||||
backupOutput := runCmd(backupConfig)
|
|
||||||
if backupOutput.err != nil {
|
|
||||||
return logging{
|
|
||||||
output: backupOutput.output,
|
|
||||||
err: beforeOutput.err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
afterConfig := backup.Cmds.After
|
|
||||||
afterOutput := runCmd(afterConfig)
|
|
||||||
if afterOutput.err != nil {
|
|
||||||
return logging{
|
|
||||||
output: afterOutput.output,
|
|
||||||
err: afterOutput.err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logging{
|
|
||||||
output: afterOutput.output,
|
|
||||||
err: nil,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func runCmd(cmd Command) logging {
|
|
||||||
if !cmd.Empty {
|
|
||||||
if cmd.Remote {
|
|
||||||
// Start new ssh connection with private key.
|
|
||||||
auth, err := goph.Key(cmd.RemoteHost.PrivateKeyPath, cmd.RemoteHost.PrivateKeyPassword)
|
|
||||||
if err != nil {
|
|
||||||
return logging{
|
|
||||||
output: err.Error(),
|
|
||||||
err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := goph.New(cmd.RemoteHost.User, cmd.RemoteHost.Host, auth)
|
|
||||||
if err != nil {
|
|
||||||
return logging{
|
|
||||||
output: err.Error(),
|
|
||||||
err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Defer closing the network connection.
|
|
||||||
defer client.Close()
|
|
||||||
|
|
||||||
command := cmd.Cmd
|
|
||||||
for _, v := range cmd.Args {
|
|
||||||
command += v
|
|
||||||
}
|
|
||||||
|
|
||||||
// Execute your command.
|
|
||||||
out, err := client.Run(command)
|
|
||||||
if err != nil {
|
|
||||||
return logging{
|
|
||||||
output: string(out),
|
|
||||||
err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cmdOut := exec.Command(cmd.Cmd, cmd.Args...)
|
|
||||||
output, err := cmdOut.Output()
|
|
||||||
if err != nil {
|
|
||||||
return logging{
|
|
||||||
output: string(output),
|
|
||||||
err: err,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return logging{
|
|
||||||
output: "",
|
|
||||||
err: nil,
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package logging
|
|
||||||
|
|
||||||
type logging struct {
|
|
||||||
err error
|
|
||||||
output string
|
|
||||||
}
|
|
68
cmd/root.go
Normal file
68
cmd/root.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
// root.go
|
||||||
|
// Copyright (C) Andrew Woodlee 2023
|
||||||
|
// License: Apache-2.0
|
||||||
|
|
||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// Used for flags.
|
||||||
|
cfgFile string
|
||||||
|
verbose bool
|
||||||
|
|
||||||
|
rootCmd = &cobra.Command{
|
||||||
|
Use: "backy",
|
||||||
|
Short: "An easy-to-configure backup tool.",
|
||||||
|
Long: `Backy is a command-line application useful for configuring backups, or any commands run in sequence.`,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Execute executes the root command.
|
||||||
|
func Execute() {
|
||||||
|
if err := rootCmd.Execute(); err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
cobra.OnInitialize(initConfig)
|
||||||
|
|
||||||
|
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file to read from")
|
||||||
|
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Sets verbose level")
|
||||||
|
|
||||||
|
rootCmd.AddCommand(backupCmd)
|
||||||
|
}
|
||||||
|
|
||||||
|
func initConfig() {
|
||||||
|
backyConfig := viper.New()
|
||||||
|
if cfgFile != strings.TrimSpace("") {
|
||||||
|
// Use config file from the flag.
|
||||||
|
backyConfig.SetConfigFile(cfgFile)
|
||||||
|
} else {
|
||||||
|
// Find home directory.
|
||||||
|
home, err := os.UserHomeDir()
|
||||||
|
cobra.CheckErr(err)
|
||||||
|
|
||||||
|
configPath := path.Join(home, ".config", "backy")
|
||||||
|
// Search config in config directory with name "backy" (without extension).
|
||||||
|
backyConfig.AddConfigPath(configPath)
|
||||||
|
backyConfig.SetConfigType("yaml")
|
||||||
|
backyConfig.SetConfigName("backy")
|
||||||
|
}
|
||||||
|
|
||||||
|
backyConfig.AutomaticEnv()
|
||||||
|
|
||||||
|
if err := backyConfig.ReadInConfig(); err == nil {
|
||||||
|
// fmt.Println("Using config file:", backyConfig.ConfigFileUsed())
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
backup:
|
|
||||||
mail-svr:
|
|
||||||
backuptype: restic
|
|
||||||
remote: email-svr
|
|
68
examples/backy.yaml
Normal file
68
examples/backy.yaml
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
commands:
|
||||||
|
stop-docker-container:
|
||||||
|
cmd: docker
|
||||||
|
cmdArgs:
|
||||||
|
- compose
|
||||||
|
- -f /some/path/to/docker-compose.yaml
|
||||||
|
- down
|
||||||
|
# if host is not defined,
|
||||||
|
host: some-host
|
||||||
|
env: ~/path/to/env/file
|
||||||
|
backup-docker-container-script:
|
||||||
|
cmd: /path/to/script
|
||||||
|
host: some-host
|
||||||
|
env: ~/path/to/env/file
|
||||||
|
shell-cmd:
|
||||||
|
cmd: rsync
|
||||||
|
shell: bash
|
||||||
|
cmdArgs:
|
||||||
|
- -av some-host:/path/to/data ~/Docker/Backups/docker-data
|
||||||
|
hostname:
|
||||||
|
cmd: hostname
|
||||||
|
|
||||||
|
cmd-configs:
|
||||||
|
# this can be any name you want
|
||||||
|
cmds-to-run:
|
||||||
|
# all commands have to be defined
|
||||||
|
order:
|
||||||
|
- stop-docker-container
|
||||||
|
- backup-docker-container-script
|
||||||
|
- shell-cmd
|
||||||
|
- hostname
|
||||||
|
notifications:
|
||||||
|
- matrix
|
||||||
|
hostname:
|
||||||
|
order:
|
||||||
|
- hostname
|
||||||
|
notifications:
|
||||||
|
- prod-email
|
||||||
|
|
||||||
|
hosts:
|
||||||
|
some-host:
|
||||||
|
config:
|
||||||
|
usefile: true
|
||||||
|
user: root
|
||||||
|
private-key-path:
|
||||||
|
|
||||||
|
logging:
|
||||||
|
verbose: true
|
||||||
|
file: /path/to/logs/commands.log
|
||||||
|
|
||||||
|
|
||||||
|
notifications:
|
||||||
|
prod-email:
|
||||||
|
id: prod-email
|
||||||
|
type: mail
|
||||||
|
host: yourhost.tld:port
|
||||||
|
senderAddress: email@domain.tld
|
||||||
|
to:
|
||||||
|
- admin@domain.tld
|
||||||
|
username: smtp-username@domain.tld
|
||||||
|
password: your-password-here
|
||||||
|
matrix:
|
||||||
|
id: matrix
|
||||||
|
type: matrix
|
||||||
|
home-server: your-home-server.tld
|
||||||
|
room-id: room-id
|
||||||
|
access-token: your-access-token
|
||||||
|
user-id: your-user-id
|
48
go.mod
48
go.mod
@ -1,35 +1,47 @@
|
|||||||
module git.andrewnw.xyz/CyberShell/backy
|
module git.andrewnw.xyz/CyberShell/backy
|
||||||
|
|
||||||
// module git.andrewnw.xyz/CyberShell/command
|
|
||||||
|
|
||||||
go 1.19
|
go 1.19
|
||||||
|
|
||||||
require github.com/spf13/viper v1.13.0
|
require (
|
||||||
|
github.com/kevinburke/ssh_config v1.2.0
|
||||||
|
github.com/nikoksr/notify v0.36.0
|
||||||
|
github.com/rs/zerolog v1.28.0
|
||||||
|
github.com/spf13/cobra v1.6.1
|
||||||
|
github.com/spf13/viper v1.14.0
|
||||||
|
golang.org/x/crypto v0.5.0
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0
|
||||||
|
maunium.net/go/mautrix v0.13.0
|
||||||
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
|
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||||
github.com/helloyi/go-sshclient v1.1.1 // indirect
|
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||||
github.com/inconshreveable/mousetrap v1.0.1 // indirect
|
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible // indirect
|
||||||
github.com/kr/fs v0.1.0 // indirect
|
github.com/magiconair/properties v1.8.7 // indirect
|
||||||
github.com/magiconair/properties v1.8.6 // indirect
|
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||||
github.com/melbahja/goph v1.3.0 // indirect
|
github.com/mattn/go-isatty v0.0.17 // indirect
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd // indirect
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
|
||||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 // indirect
|
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pkg/sftp v1.13.4 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/spf13/afero v1.9.2 // indirect
|
github.com/spf13/afero v1.9.3 // indirect
|
||||||
github.com/spf13/cast v1.5.0 // indirect
|
github.com/spf13/cast v1.5.0 // indirect
|
||||||
github.com/spf13/cobra v1.5.0 // indirect
|
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/spf13/pflag v1.0.5 // indirect
|
||||||
|
github.com/stretchr/objx v0.5.0 // indirect
|
||||||
|
github.com/stretchr/testify v1.8.1 // indirect
|
||||||
github.com/subosito/gotenv v1.4.1 // indirect
|
github.com/subosito/gotenv v1.4.1 // indirect
|
||||||
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a // indirect
|
github.com/tidwall/gjson v1.14.4 // indirect
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
golang.org/x/text v0.3.7 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
|
github.com/tidwall/sjson v1.2.5 // indirect
|
||||||
|
golang.org/x/net v0.5.0 // indirect
|
||||||
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
|
golang.org/x/sys v0.4.0 // indirect
|
||||||
|
golang.org/x/text v0.6.0 // indirect
|
||||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
111
go.sum
111
go.sum
@ -36,6 +36,7 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
|
|||||||
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
|
||||||
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo=
|
||||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||||
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
@ -46,6 +47,7 @@ github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDk
|
|||||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||||
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
|
github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
@ -57,11 +59,12 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
|
|||||||
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
github.com/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||||
github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
|
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8=
|
||||||
|
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
@ -98,7 +101,7 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
|||||||
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
||||||
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0=
|
||||||
@ -121,71 +124,88 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
|
|||||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||||
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
|
||||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||||
github.com/helloyi/go-sshclient v1.1.1 h1:yRcrc/Q1nJ2hYbtVFfBBTyneQLqr2vy/jD3/GneyirI=
|
|
||||||
github.com/helloyi/go-sshclient v1.1.1/go.mod h1:NrhRWsYJDjoQXTDWZ4YtVk84wZ4LK3NSM9jD2TZDAm8=
|
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.1 h1:U3uMjPSQEBMNp1lFxmllqCPM6P5u/Xq7Pgzkat/bFNc=
|
|
||||||
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
github.com/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||||
|
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||||
|
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
|
||||||
|
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
|
||||||
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
||||||
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
|
||||||
|
github.com/kevinburke/ssh_config v1.2.0 h1:x584FjTGwHzMwvHx18PXxbBVzfnxogHaAReU4gf13a4=
|
||||||
|
github.com/kevinburke/ssh_config v1.2.0/go.mod h1:CT57kijsi8u/K/BOFA39wgDQJ9CxiF4nAY/ojJ6r6mM=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/kr/fs v0.1.0 h1:Jskdu9ieNAYnjxsi0LbQp1ulIKZV1LAFgK1tWhpZgl8=
|
|
||||||
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
github.com/magiconair/properties v1.8.6 h1:5ibWZ6iY0NctNGWo87LalDlEZ6R41TqbbDamhfG/Qzo=
|
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||||
github.com/magiconair/properties v1.8.6/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60=
|
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||||
github.com/melbahja/goph v1.3.0 h1:RAIS7eL2tew/UrNmBpY2NZMxw6fWtOxki9nkrzw8mZY=
|
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||||
github.com/melbahja/goph v1.3.0/go.mod h1:04M6J+mKmwzAOWhO0ABTweHGU3cizOp90WdCoxrn9gQ=
|
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd h1:HoDa3tI6njhpyhu7aIcIfib8QugB66ILgYRLc5IuP6s=
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
github.com/metrue/go-ssh-client v0.0.0-20200317072149-19d54050aefd/go.mod h1:mgU+XR/ItF6PaQGpx0MthaaMP2dgGuck0IiXcrF3zMw=
|
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=
|
||||||
|
github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
|
||||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||||
|
github.com/nikoksr/notify v0.36.0 h1:OeO/COtxZYLjtFuxBhpeVLfCFdGt48KKgOHKu43w8H0=
|
||||||
|
github.com/nikoksr/notify v0.36.0/go.mod h1:U5h6rVleLTcAJASy7kRdD4vtsFBBxirWQKYX8NJ4jcw=
|
||||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
||||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg=
|
github.com/pelletier/go-toml/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||||
github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas=
|
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
|
github.com/pkg/sftp v1.13.1/go.mod h1:3HaPG6Dq1ILlpPZRO0HVMrsydcdLt6HRDccSgb87qRg=
|
||||||
github.com/pkg/sftp v1.13.4 h1:Lb0RYJCmgUcBgZosfoi9Y9sbl6+LJgOIgk/2Y4YjMFg=
|
|
||||||
github.com/pkg/sftp v1.13.4/go.mod h1:LzqnAvaD5TWeNBsZpfKxSYn1MbjWwOsCIAFFJbpIsK8=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
github.com/rogpeppe/go-internal v1.6.1 h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=
|
||||||
|
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||||
|
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
|
||||||
|
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||||
github.com/spf13/afero v1.9.2 h1:j49Hj62F0n+DaZ1dDCvhABaPNSGNkt32oRFxI33IEMw=
|
github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk=
|
||||||
github.com/spf13/afero v1.9.2/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
|
github.com/spf13/afero v1.9.3/go.mod h1:iUV7ddyEEZPO5gA3zD4fJt6iStLlL+Lg4m2cihcDf8Y=
|
||||||
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
github.com/spf13/cast v1.5.0 h1:rj3WzYc11XZaIZMPKmwP96zkFEnnAmV8s6XbB2aY32w=
|
||||||
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
github.com/spf13/cast v1.5.0/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||||
github.com/spf13/cobra v1.5.0 h1:X+jTBEBqF0bHN+9cSMgmfuvv2VHJ9ezmFNf9Y/XstYU=
|
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||||
github.com/spf13/cobra v1.5.0/go.mod h1:dWXEIy2H428czQCjInthrTRUg7yKbok+2Qi/yBIJoUM=
|
github.com/spf13/cobra v1.6.1/go.mod h1:IOw/AERYS7UzyrGinqmz6HLUo219MORXGxhbaJUqzrY=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk=
|
||||||
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||||
github.com/spf13/viper v1.13.0 h1:BWSJ/M+f+3nmdz9bxB+bWX28kkALN2ok11D0rSo8EJU=
|
github.com/spf13/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU=
|
||||||
github.com/spf13/viper v1.13.0/go.mod h1:Icm2xNL3/8uyh/wFuB1jI7TiTNKp8632Nwegu+zgdYw=
|
github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c=
|
||||||
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
||||||
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
|
github.com/subosito/gotenv v1.4.1 h1:jyEFiXpy21Wm81FBN71l9VoMMV8H8jG+qIK3GCpY6Qs=
|
||||||
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
github.com/subosito/gotenv v1.4.1/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||||
|
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||||
|
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||||
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||||
|
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
@ -199,17 +219,12 @@ go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
|||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
|
||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
|
||||||
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
|
||||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2 h1:x8vtB3zMecnlqZIwJNUUpwYKYSqCz5jXbiyv0ZJJZeI=
|
golang.org/x/crypto v0.5.0 h1:U/0M97KRkSFvyD/3FSmdP5W5swImpNgle/EHFhOsQPE=
|
||||||
golang.org/x/crypto v0.0.0-20221010152910-d6f0a8c073c2/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
golang.org/x/crypto v0.5.0/go.mod h1:NK/OQwhpMQP3MwtdjgLlYHnH9ebylxKWv3e0fK+mkQU=
|
||||||
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a h1:NmSIgad6KjE6VvHciPZuNRTKxGhlPfD6OA87W/PLkqg=
|
|
||||||
golang.org/x/crypto v0.0.0-20221012134737-56aed061732a/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||||
@ -274,6 +289,8 @@ golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwY
|
|||||||
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
|
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
|
||||||
|
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||||
@ -293,6 +310,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ
|
|||||||
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
|
||||||
|
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@ -303,7 +322,6 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
|
||||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
@ -328,23 +346,22 @@ golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7w
|
|||||||
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20211031064116-611d5d643895/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14 h1:k5II8e6QD8mITdi+okbbmR/cIyEbeXLBhy5Ha4nevyc=
|
golang.org/x/sys v0.4.0 h1:Zr2JFtRQNX3BCZ8YtxRE9hNJYC8J6I1MVbMg6owUp18=
|
||||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
golang.org/x/term v0.4.0 h1:O7UWfv5+A2qiuulQk30kVinPoMtoIPeVaKLEgLpVkvg=
|
||||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
|
golang.org/x/text v0.6.0 h1:3XmdazWV+ubf7QgHSTWeykHOci5oeekaGJBLkrkaw4k=
|
||||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||||
@ -493,6 +510,8 @@ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8
|
|||||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8=
|
||||||
|
gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
@ -506,6 +525,8 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh
|
|||||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||||
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||||
|
maunium.net/go/mautrix v0.13.0 h1:CRdpMFc1kDSNnCZMcqahR9/pkDy/vgRbd+fHnSCl6Yg=
|
||||||
|
maunium.net/go/mautrix v0.13.0/go.mod h1:gYMQPsZ9lQpyKlVp+DGwOuc9LIcE/c8GZW2CvKHISgM=
|
||||||
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
|
||||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||||
|
489
pkg/backy/backy.go
Normal file
489
pkg/backy/backy.go
Normal file
@ -0,0 +1,489 @@
|
|||||||
|
// backy.go
|
||||||
|
// Copyright (C) Andrew Woodlee 2023
|
||||||
|
// License: Apache-2.0
|
||||||
|
package backy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
"bytes"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"os"
|
||||||
|
"os/exec"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
)
|
||||||
|
|
||||||
|
var requiredKeys = []string{"commands", "cmd-configs"}
|
||||||
|
|
||||||
|
var Sprintf = fmt.Sprintf
|
||||||
|
|
||||||
|
type BackyOptionFunc func(*BackyConfigOpts)
|
||||||
|
|
||||||
|
func (c *BackyConfigOpts) LogLvl(level string) BackyOptionFunc {
|
||||||
|
return func(bco *BackyConfigOpts) {
|
||||||
|
c.BackyLogLvl = &level
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *BackyConfigOpts) GetConfig() {
|
||||||
|
c.ConfigFile = ReadAndParseConfigFile(c.ConfigFilePath)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewOpts(configFilePath string, opts ...BackyOptionFunc) *BackyConfigOpts {
|
||||||
|
b := &BackyConfigOpts{}
|
||||||
|
b.ConfigFilePath = configFilePath
|
||||||
|
for _, opt := range opts {
|
||||||
|
opt(b)
|
||||||
|
}
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
NewConfig initializes new config that holds information from the config file
|
||||||
|
*/
|
||||||
|
func NewConfig() *BackyConfigFile {
|
||||||
|
return &BackyConfigFile{
|
||||||
|
Cmds: make(map[string]Command),
|
||||||
|
CmdConfigLists: make(map[string]*CmdConfig),
|
||||||
|
Hosts: make(map[string]Host),
|
||||||
|
Notifications: make(map[string]*NotificationsConfig),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type environmentVars struct {
|
||||||
|
file string
|
||||||
|
env []string
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Runs a backup configuration
|
||||||
|
*/
|
||||||
|
|
||||||
|
func (command *Command) RunCmd(log *zerolog.Logger) {
|
||||||
|
|
||||||
|
var envVars = environmentVars{
|
||||||
|
file: command.Env,
|
||||||
|
env: command.Environment,
|
||||||
|
}
|
||||||
|
envVars.env = append(envVars.env, os.Environ()...)
|
||||||
|
|
||||||
|
var cmdArgsStr string
|
||||||
|
for _, v := range command.CmdArgs {
|
||||||
|
cmdArgsStr += fmt.Sprintf(" %s", v)
|
||||||
|
}
|
||||||
|
var hostStr string
|
||||||
|
if command.Host != nil {
|
||||||
|
hostStr = *command.Host
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Info().Str("Command", fmt.Sprintf("Running command: %s %s on host %s", command.Cmd, cmdArgsStr, hostStr)).Send()
|
||||||
|
if command.Host != nil {
|
||||||
|
command.RemoteHost.Host = *command.Host
|
||||||
|
command.RemoteHost.Port = 22
|
||||||
|
sshc, err := command.RemoteHost.ConnectToSSHHost(log)
|
||||||
|
if err != nil {
|
||||||
|
log.Err(fmt.Errorf("ssh dial: %w", err)).Send()
|
||||||
|
}
|
||||||
|
defer sshc.Close()
|
||||||
|
commandSession, err := sshc.NewSession()
|
||||||
|
if err != nil {
|
||||||
|
log.Err(fmt.Errorf("new ssh session: %w", err)).Send()
|
||||||
|
}
|
||||||
|
defer commandSession.Close()
|
||||||
|
|
||||||
|
injectEnvIntoSSH(envVars, commandSession, log)
|
||||||
|
cmd := command.Cmd
|
||||||
|
for _, a := range command.CmdArgs {
|
||||||
|
cmd += " " + a
|
||||||
|
}
|
||||||
|
|
||||||
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
|
commandSession.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||||
|
commandSession.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||||
|
err = commandSession.Run(cmd)
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stdout", command.Cmd), stdoutBuf.Bytes()).Send()
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stderr", command.Cmd), stderrBuf.Bytes()).Send()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(fmt.Errorf("error when running cmd: %s: %w", command.Cmd, err)).Send()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// shell := "/bin/bash"
|
||||||
|
var err error
|
||||||
|
if command.Shell != "" {
|
||||||
|
cmdArgsStr = fmt.Sprintf("%s %s", command.Cmd, cmdArgsStr)
|
||||||
|
localCMD := exec.Command(command.Shell, "-c", cmdArgsStr)
|
||||||
|
if command.Dir != nil {
|
||||||
|
localCMD.Dir = *command.Dir
|
||||||
|
}
|
||||||
|
|
||||||
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
|
localCMD.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||||
|
localCMD.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||||
|
injectEnvIntoLocalCMD(envVars, localCMD, log)
|
||||||
|
err = localCMD.Run()
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stdout", command.Cmd), stdoutBuf.Bytes()).Send()
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stderr", command.Cmd), stderrBuf.Bytes()).Send()
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(fmt.Errorf("error when running cmd: %s: %w", command.Cmd, err)).Send()
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
localCMD := exec.Command(command.Cmd, command.CmdArgs...)
|
||||||
|
if command.Dir != nil {
|
||||||
|
localCMD.Dir = *command.Dir
|
||||||
|
}
|
||||||
|
var stdoutBuf, stderrBuf bytes.Buffer
|
||||||
|
localCMD.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||||
|
localCMD.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||||
|
injectEnvIntoLocalCMD(envVars, localCMD, log)
|
||||||
|
err = localCMD.Run()
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stdout", command.Cmd), stdoutBuf.Bytes()).Send()
|
||||||
|
log.Info().Bytes(fmt.Sprintf("%s stderr", command.Cmd), stderrBuf.Bytes()).Send()
|
||||||
|
if err != nil {
|
||||||
|
log.Error().Err(fmt.Errorf("error when running cmd: %s: %w", command.Cmd, err)).Send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func cmdListWorker(id int, jobs <-chan *CmdConfig, config *BackyConfigFile, results chan<- string) {
|
||||||
|
for j := range jobs {
|
||||||
|
// fmt.Println("worker", id, "started job", j)
|
||||||
|
for _, cmd := range j.Order {
|
||||||
|
cmdToRun := config.Cmds[cmd]
|
||||||
|
cmdToRun.RunCmd(&config.Logger)
|
||||||
|
}
|
||||||
|
// fmt.Println("worker", id, "finished job", j)
|
||||||
|
results <- "done"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunBackyConfig runs a command list from the BackyConfigFile.
|
||||||
|
func (config *BackyConfigFile) RunBackyConfig() {
|
||||||
|
configListsLen := len(config.CmdConfigLists)
|
||||||
|
jobs := make(chan *CmdConfig, configListsLen)
|
||||||
|
results := make(chan string)
|
||||||
|
// configChan := make(chan map[string]Command)
|
||||||
|
|
||||||
|
// This starts up 3 workers, initially blocked
|
||||||
|
// because there are no jobs yet.
|
||||||
|
for w := 1; w <= 3; w++ {
|
||||||
|
go cmdListWorker(w, jobs, config, results)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Here we send 5 `jobs` and then `close` that
|
||||||
|
// channel to indicate that's all the work we have.
|
||||||
|
// configChan <- config.Cmds
|
||||||
|
for _, cmdConfig := range config.CmdConfigLists {
|
||||||
|
jobs <- cmdConfig
|
||||||
|
// fmt.Println("sent job", config.Order)
|
||||||
|
}
|
||||||
|
close(jobs)
|
||||||
|
|
||||||
|
for a := 1; a <= configListsLen; a++ {
|
||||||
|
<-results
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ReadAndParseConfigFile validates and reads the config file.
|
||||||
|
func ReadAndParseConfigFile(configFile string) *BackyConfigFile {
|
||||||
|
|
||||||
|
backyConfigFile := NewConfig()
|
||||||
|
|
||||||
|
backyViper := viper.New()
|
||||||
|
|
||||||
|
if configFile != "" {
|
||||||
|
backyViper.SetConfigFile(configFile)
|
||||||
|
} else {
|
||||||
|
backyViper.SetConfigName("backy.yaml") // name of config file (with extension)
|
||||||
|
backyViper.SetConfigType("yaml") // REQUIRED if the config file does not have the extension in the name
|
||||||
|
backyViper.AddConfigPath(".") // optionally look for config in the working directory
|
||||||
|
backyViper.AddConfigPath("$HOME/.config/backy") // call multiple times to add many search paths
|
||||||
|
}
|
||||||
|
err := backyViper.ReadInConfig() // Find and read the config file
|
||||||
|
if err != nil { // Handle errors reading the config file
|
||||||
|
panic(fmt.Errorf("fatal error reading config file %s: %w", backyViper.ConfigFileUsed(), err))
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckForConfigValues(backyViper)
|
||||||
|
|
||||||
|
var backyLoggingOpts *viper.Viper
|
||||||
|
backyLoggingOptsSet := backyViper.IsSet("logging")
|
||||||
|
if backyLoggingOptsSet {
|
||||||
|
backyLoggingOpts = backyViper.Sub("logging")
|
||||||
|
}
|
||||||
|
verbose := backyLoggingOpts.GetBool("verbose")
|
||||||
|
|
||||||
|
logFile := backyLoggingOpts.GetString("file")
|
||||||
|
if verbose {
|
||||||
|
zerolog.SetGlobalLevel(zerolog.ErrorLevel)
|
||||||
|
globalLvl := zerolog.GlobalLevel().String()
|
||||||
|
os.Setenv("BACKY_LOGLEVEL", globalLvl)
|
||||||
|
}
|
||||||
|
output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC1123}
|
||||||
|
output.FormatLevel = func(i interface{}) string {
|
||||||
|
return strings.ToUpper(fmt.Sprintf("| %-6s|", i))
|
||||||
|
}
|
||||||
|
output.FormatMessage = func(i interface{}) string {
|
||||||
|
return fmt.Sprintf("%s", i)
|
||||||
|
}
|
||||||
|
output.FormatFieldName = func(i interface{}) string {
|
||||||
|
return fmt.Sprintf("%s: ", i)
|
||||||
|
}
|
||||||
|
output.FormatFieldValue = func(i interface{}) string {
|
||||||
|
return strings.ToUpper(fmt.Sprintf("%s", i))
|
||||||
|
}
|
||||||
|
|
||||||
|
fileLogger := &lumberjack.Logger{
|
||||||
|
MaxSize: 500, // megabytes
|
||||||
|
MaxBackups: 3,
|
||||||
|
MaxAge: 28, //days
|
||||||
|
Compress: true, // disabled by default
|
||||||
|
}
|
||||||
|
if strings.TrimSpace(logFile) != "" {
|
||||||
|
fileLogger.Filename = logFile
|
||||||
|
} else {
|
||||||
|
fileLogger.Filename = "./backy.log"
|
||||||
|
}
|
||||||
|
|
||||||
|
// UNIX Time is faster and smaller than most timestamps
|
||||||
|
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||||
|
// zerolog.TimeFieldFormat = time.RFC1123
|
||||||
|
writers := zerolog.MultiLevelWriter(os.Stdout, fileLogger)
|
||||||
|
log := zerolog.New(writers).With().Timestamp().Logger()
|
||||||
|
|
||||||
|
backyConfigFile.Logger = log
|
||||||
|
|
||||||
|
commandsMap := backyViper.GetStringMapString("commands")
|
||||||
|
commandsMapViper := backyViper.Sub("commands")
|
||||||
|
unmarshalErr := commandsMapViper.Unmarshal(&backyConfigFile.Cmds)
|
||||||
|
if unmarshalErr != nil {
|
||||||
|
panic(fmt.Errorf("error unmarshalling cmds struct: %w", unmarshalErr))
|
||||||
|
}
|
||||||
|
|
||||||
|
var cmdNames []string
|
||||||
|
for k := range commandsMap {
|
||||||
|
cmdNames = append(cmdNames, k)
|
||||||
|
}
|
||||||
|
hostConfigsMap := make(map[string]*viper.Viper)
|
||||||
|
|
||||||
|
for _, cmdName := range cmdNames {
|
||||||
|
var backupCmdStruct Command
|
||||||
|
subCmd := backyViper.Sub(getNestedConfig("commands", cmdName))
|
||||||
|
|
||||||
|
hostSet := subCmd.IsSet("host")
|
||||||
|
host := subCmd.GetString("host")
|
||||||
|
|
||||||
|
if hostSet {
|
||||||
|
log.Debug().Timestamp().Str(cmdName, "host is set").Str("host", host).Send()
|
||||||
|
backupCmdStruct.Host = &host
|
||||||
|
if backyViper.IsSet(getNestedConfig("hosts", host)) {
|
||||||
|
hostconfig := backyViper.Sub(getNestedConfig("hosts", host))
|
||||||
|
hostConfigsMap[host] = hostconfig
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log.Debug().Timestamp().Str(cmdName, "host is not set").Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// backyConfigFile.Cmds[cmdName] = backupCmdStruct
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
cmdListCfg := backyViper.Sub("cmd-configs")
|
||||||
|
unmarshalErr = cmdListCfg.Unmarshal(&backyConfigFile.CmdConfigLists)
|
||||||
|
if unmarshalErr != nil {
|
||||||
|
panic(fmt.Errorf("error unmarshalling cmd list struct: %w", unmarshalErr))
|
||||||
|
}
|
||||||
|
var cmdNotFoundSliceErr []error
|
||||||
|
for cmdListName, cmdList := range backyConfigFile.CmdConfigLists {
|
||||||
|
for _, cmdInList := range cmdList.Order {
|
||||||
|
// log.Info().Msgf("CmdList %s Cmd %s", cmdListName, cmdInList)
|
||||||
|
_, cmdNameFound := backyConfigFile.Cmds[cmdInList]
|
||||||
|
if !cmdNameFound {
|
||||||
|
cmdNotFoundStr := fmt.Sprintf("command %s is not defined in config file", cmdInList)
|
||||||
|
cmdNotFoundErr := errors.New(cmdNotFoundStr)
|
||||||
|
cmdNotFoundSliceErr = append(cmdNotFoundSliceErr, cmdNotFoundErr)
|
||||||
|
} else {
|
||||||
|
log.Info().Str(cmdInList, "found in "+cmdListName).Send()
|
||||||
|
// backyConfigFile.CmdLists[cmdListName] = append(backyConfigFile.CmdLists[cmdListName], cmdInList)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(cmdNotFoundSliceErr) > 0 {
|
||||||
|
var cmdNotFoundErrorLog = log.Fatal()
|
||||||
|
for _, err := range cmdNotFoundSliceErr {
|
||||||
|
if err != nil {
|
||||||
|
cmdNotFoundErrorLog.Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cmdNotFoundErrorLog.Send()
|
||||||
|
}
|
||||||
|
|
||||||
|
// var notificationSlice []string
|
||||||
|
for name, cmdCfg := range backyConfigFile.CmdConfigLists {
|
||||||
|
for _, notificationID := range cmdCfg.Notifications {
|
||||||
|
// if !contains(notificationSlice, notificationID) {
|
||||||
|
|
||||||
|
cmdCfg.NotificationsConfig = make(map[string]*NotificationsConfig)
|
||||||
|
notifConfig := backyViper.Sub(getNestedConfig("notifications", notificationID))
|
||||||
|
config := &NotificationsConfig{
|
||||||
|
Config: notifConfig,
|
||||||
|
Enabled: true,
|
||||||
|
}
|
||||||
|
cmdCfg.NotificationsConfig[notificationID] = config
|
||||||
|
// First we get a "copy" of the entry
|
||||||
|
if entry, ok := cmdCfg.NotificationsConfig[notificationID]; ok {
|
||||||
|
|
||||||
|
// Then we modify the copy
|
||||||
|
entry.Config = notifConfig
|
||||||
|
entry.Enabled = true
|
||||||
|
|
||||||
|
// Then we reassign the copy
|
||||||
|
cmdCfg.NotificationsConfig[notificationID] = entry
|
||||||
|
}
|
||||||
|
backyConfigFile.CmdConfigLists[name].NotificationsConfig[notificationID] = config
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
var notificationsMap = make(map[string]interface{})
|
||||||
|
if backyViper.IsSet("notifications") {
|
||||||
|
notificationsMap = backyViper.GetStringMap("notifications")
|
||||||
|
for id := range notificationsMap {
|
||||||
|
notifConfig := backyViper.Sub(getNestedConfig("notifications", id))
|
||||||
|
config := &NotificationsConfig{
|
||||||
|
Config: notifConfig,
|
||||||
|
Enabled: true,
|
||||||
|
}
|
||||||
|
backyConfigFile.Notifications[id] = config
|
||||||
|
}
|
||||||
|
|
||||||
|
// for _, notif := range backyConfigFile.Notifications {
|
||||||
|
// fmt.Printf("Type: %s\n", notif.Config.GetString("type"))
|
||||||
|
// notificationID := notif.Config.GetString("id")
|
||||||
|
// if !contains(notificationSlice, notificationID) {
|
||||||
|
// config := backyConfigFile.Notifications[notificationID]
|
||||||
|
// config.Enabled = false
|
||||||
|
// backyConfigFile.Notifications[notificationID] = config
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
return backyConfigFile
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNestedConfig(nestedConfig, key string) string {
|
||||||
|
return fmt.Sprintf("%s.%s", nestedConfig, key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func resolveDir(path string) (string, error) {
|
||||||
|
usr, err := user.Current()
|
||||||
|
if err != nil {
|
||||||
|
return path, err
|
||||||
|
}
|
||||||
|
dir := usr.HomeDir
|
||||||
|
if path == "~" {
|
||||||
|
// In case of "~", which won't be caught by the "else if"
|
||||||
|
path = dir
|
||||||
|
} else if strings.HasPrefix(path, "~/") {
|
||||||
|
// Use strings.HasPrefix so we don't match paths like
|
||||||
|
// "/something/~/something/"
|
||||||
|
path = filepath.Join(dir, path[2:])
|
||||||
|
}
|
||||||
|
return path, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func injectEnvIntoSSH(envVarsToInject environmentVars, process *ssh.Session, log *zerolog.Logger) {
|
||||||
|
if envVarsToInject.file != "" {
|
||||||
|
envPath, envPathErr := resolveDir(envVarsToInject.file)
|
||||||
|
if envPathErr != nil {
|
||||||
|
log.Error().Err(envPathErr).Send()
|
||||||
|
}
|
||||||
|
file, err := os.Open(envPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Err(err).Send()
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
envVar := scanner.Text()
|
||||||
|
envVarArr := strings.Split(envVar, "=")
|
||||||
|
process.Setenv(envVarArr[0], envVarArr[1])
|
||||||
|
}
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
log.Err(err).Send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(envVarsToInject.env) > 0 {
|
||||||
|
for _, envVal := range envVarsToInject.env {
|
||||||
|
if strings.Contains(envVal, "=") {
|
||||||
|
envVarArr := strings.Split(envVal, "=")
|
||||||
|
process.Setenv(strings.ToUpper(envVarArr[0]), envVarArr[1])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func injectEnvIntoLocalCMD(envVarsToInject environmentVars, process *exec.Cmd, log *zerolog.Logger) {
|
||||||
|
if envVarsToInject.file != "" {
|
||||||
|
envPath, envPathErr := resolveDir(envVarsToInject.file)
|
||||||
|
if envPathErr != nil {
|
||||||
|
log.Error().Err(envPathErr).Send()
|
||||||
|
}
|
||||||
|
file, err := os.Open(envPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Err(err).Send()
|
||||||
|
}
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
scanner := bufio.NewScanner(file)
|
||||||
|
for scanner.Scan() {
|
||||||
|
envVar := scanner.Text()
|
||||||
|
process.Env = append(process.Env, envVar)
|
||||||
|
}
|
||||||
|
if err := scanner.Err(); err != nil {
|
||||||
|
log.Err(err).Send()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(envVarsToInject.env) > 0 {
|
||||||
|
for _, envVal := range envVarsToInject.env {
|
||||||
|
if strings.Contains(envVal, "=") {
|
||||||
|
process.Env = append(process.Env, envVal)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func contains(s []string, e string) bool {
|
||||||
|
for _, a := range s {
|
||||||
|
if a == e {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
func CheckForConfigValues(config *viper.Viper) {
|
||||||
|
|
||||||
|
for _, key := range requiredKeys {
|
||||||
|
isKeySet := config.IsSet(key)
|
||||||
|
if !isKeySet {
|
||||||
|
logging.ExitWithMSG(Sprintf("Config key %s is not defined in %s", key, config.ConfigFileUsed()), 1, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
99
pkg/backy/ssh.go
Normal file
99
pkg/backy/ssh.go
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
// ssh.go
|
||||||
|
// Copyright (C) Andrew Woodlee 2023
|
||||||
|
// License: Apache-2.0
|
||||||
|
|
||||||
|
package backy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"os"
|
||||||
|
"os/user"
|
||||||
|
"path/filepath"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/kevinburke/ssh_config"
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
"golang.org/x/crypto/ssh/knownhosts"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConnectToSSHHost connects to a host by looking up the config values in the directory ~/.ssh/config
|
||||||
|
// Other than host, it does not yet respect other config values set in the backy config file.
|
||||||
|
// It returns an ssh.Client used to run commands against.
|
||||||
|
func (remoteConfig *Host) ConnectToSSHHost(log *zerolog.Logger) (*ssh.Client, error) {
|
||||||
|
|
||||||
|
var sshClient *ssh.Client
|
||||||
|
var connectErr error
|
||||||
|
|
||||||
|
khPath := filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts")
|
||||||
|
f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
|
||||||
|
cfg, _ := ssh_config.Decode(f)
|
||||||
|
for _, host := range cfg.Hosts {
|
||||||
|
// var hostKey ssh.PublicKey
|
||||||
|
if host.Matches(remoteConfig.Host) {
|
||||||
|
var identityFile string
|
||||||
|
if remoteConfig.PrivateKeyPath == "" {
|
||||||
|
identityFile, _ = cfg.Get(remoteConfig.Host, "IdentityFile")
|
||||||
|
usr, _ := user.Current()
|
||||||
|
dir := usr.HomeDir
|
||||||
|
if identityFile == "~" {
|
||||||
|
// In case of "~", which won't be caught by the "else if"
|
||||||
|
identityFile = dir
|
||||||
|
} else if strings.HasPrefix(identityFile, "~/") {
|
||||||
|
// Use strings.HasPrefix so we don't match paths like
|
||||||
|
// "/something/~/something/"
|
||||||
|
identityFile = filepath.Join(dir, identityFile[2:])
|
||||||
|
}
|
||||||
|
remoteConfig.PrivateKeyPath = filepath.Join(identityFile)
|
||||||
|
log.Debug().Str("Private key path", remoteConfig.PrivateKeyPath).Send()
|
||||||
|
}
|
||||||
|
remoteConfig.HostName, _ = cfg.Get(remoteConfig.Host, "HostName")
|
||||||
|
remoteConfig.User, _ = cfg.Get(remoteConfig.Host, "User")
|
||||||
|
if remoteConfig.HostName == "" {
|
||||||
|
port, _ := cfg.Get(remoteConfig.Host, "Port")
|
||||||
|
if port == "" {
|
||||||
|
port = "22"
|
||||||
|
}
|
||||||
|
// remoteConfig.HostName[0] = remoteConfig.Host + ":" + port
|
||||||
|
} else {
|
||||||
|
// for index, hostName := range remoteConfig.HostName {
|
||||||
|
port, _ := cfg.Get(remoteConfig.Host, "Port")
|
||||||
|
if port == "" {
|
||||||
|
port = "22"
|
||||||
|
}
|
||||||
|
remoteConfig.HostName = remoteConfig.HostName + ":" + port
|
||||||
|
// remoteConfig.HostName[index] = hostName + ":" + port
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Add value/option to config for host key and add bool to check for host key
|
||||||
|
hostKeyCallback, err := knownhosts.New(khPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("could not create hostkeycallback function")
|
||||||
|
}
|
||||||
|
privateKey, err := os.ReadFile(remoteConfig.PrivateKeyPath)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("read private key error")
|
||||||
|
}
|
||||||
|
signer, err := ssh.ParsePrivateKey(privateKey)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal().Err(err).Msg("parse private key error")
|
||||||
|
}
|
||||||
|
sshConfig := &ssh.ClientConfig{
|
||||||
|
User: remoteConfig.User,
|
||||||
|
Auth: []ssh.AuthMethod{ssh.PublicKeys(signer)},
|
||||||
|
HostKeyCallback: hostKeyCallback,
|
||||||
|
// HostKeyAlgorithms: []string{ssh.KeyAlgoECDSA256},
|
||||||
|
}
|
||||||
|
// for _, host := range remoteConfig.HostName {
|
||||||
|
log.Info().Msgf("Connecting to host %s", remoteConfig.HostName)
|
||||||
|
|
||||||
|
sshClient, connectErr = ssh.Dial("tcp", remoteConfig.HostName, sshConfig)
|
||||||
|
if connectErr != nil {
|
||||||
|
log.Fatal().Str("host", remoteConfig.HostName).Err(connectErr).Send()
|
||||||
|
}
|
||||||
|
// }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return sshClient, connectErr
|
||||||
|
}
|
116
pkg/backy/types.go
Normal file
116
pkg/backy/types.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
// types.go
|
||||||
|
// Copyright (C) Andrew Woodlee 2023
|
||||||
|
// License: Apache-2.0
|
||||||
|
package backy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
"github.com/spf13/viper"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Host defines a host to which to connect.
|
||||||
|
// If not provided, the values will be looked up in the default ssh config files
|
||||||
|
type Host struct {
|
||||||
|
ConfigFilePath string `yaml:"config-file-path,omitempty"`
|
||||||
|
UseConfigFile bool
|
||||||
|
Empty bool
|
||||||
|
Host string
|
||||||
|
HostName string
|
||||||
|
Port uint16
|
||||||
|
PrivateKeyPath string
|
||||||
|
PrivateKeyPassword string
|
||||||
|
User string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Command struct {
|
||||||
|
// Remote bool `yaml:"remote,omitempty"`
|
||||||
|
|
||||||
|
Output BackyCommandOutput `yaml:"-"`
|
||||||
|
|
||||||
|
// command to run
|
||||||
|
Cmd string `yaml:"cmd"`
|
||||||
|
|
||||||
|
// host on which to run cmd
|
||||||
|
Host *string `yaml:"host,omitempty"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
Shell specifies which shell to run the command in, if any.
|
||||||
|
Not applicable when host is defined.
|
||||||
|
*/
|
||||||
|
Shell string `yaml:"shell,omitempty"`
|
||||||
|
|
||||||
|
RemoteHost Host `yaml:"-"`
|
||||||
|
|
||||||
|
// cmdArgs is an array that holds the arguments to cmd
|
||||||
|
CmdArgs []string `yaml:"cmdArgs,omitempty"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
Dir specifies a directory in which to run the command.
|
||||||
|
Ignored if Host is set.
|
||||||
|
*/
|
||||||
|
Dir *string `yaml:"dir,omitempty"`
|
||||||
|
|
||||||
|
// Env points to a file containing env variables to be used with the command
|
||||||
|
Env string `yaml:"env,omitempty"`
|
||||||
|
|
||||||
|
// Environment holds env variables to be used with the command
|
||||||
|
Environment []string `yaml:"environment,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type CmdConfig struct {
|
||||||
|
Order []string `yaml:"order,omitempty"`
|
||||||
|
Notifications []string `yaml:"notifications,omitempty"`
|
||||||
|
NotificationsConfig map[string]*NotificationsConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackyConfigFile struct {
|
||||||
|
/*
|
||||||
|
Cmds holds the commands for a list.
|
||||||
|
Key is the name of the command,
|
||||||
|
*/
|
||||||
|
Cmds map[string]Command `yaml:"commands"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
CmdLConfigists holds the lists of commands to be run in order.
|
||||||
|
Key is the command list name.
|
||||||
|
*/
|
||||||
|
CmdConfigLists map[string]*CmdConfig `yaml:"cmd-configs"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
Hosts holds the Host config.
|
||||||
|
key is the host.
|
||||||
|
*/
|
||||||
|
Hosts map[string]Host `yaml:"hosts"`
|
||||||
|
|
||||||
|
/*
|
||||||
|
Notifications holds the config for different notifications.
|
||||||
|
*/
|
||||||
|
Notifications map[string]*NotificationsConfig
|
||||||
|
|
||||||
|
Logger zerolog.Logger
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackyConfigOpts struct {
|
||||||
|
// Holds config file
|
||||||
|
ConfigFile *BackyConfigFile
|
||||||
|
// Holds config file
|
||||||
|
ConfigFilePath string
|
||||||
|
|
||||||
|
// Global log level
|
||||||
|
BackyLogLvl *string
|
||||||
|
}
|
||||||
|
|
||||||
|
type NotificationsConfig struct {
|
||||||
|
Config *viper.Viper
|
||||||
|
Enabled bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type CmdOutput struct {
|
||||||
|
StdErr []byte
|
||||||
|
StdOut []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackyCommandOutput interface {
|
||||||
|
Error() error
|
||||||
|
GetOutput() CmdOutput
|
||||||
|
}
|
22
pkg/logging/logging.go
Normal file
22
pkg/logging/logging.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package logging
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/rs/zerolog"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Logging struct {
|
||||||
|
Err error
|
||||||
|
Output string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Logfile struct {
|
||||||
|
LogfilePath string
|
||||||
|
}
|
||||||
|
|
||||||
|
func ExitWithMSG(msg string, code int, log *zerolog.Logger) {
|
||||||
|
fmt.Printf("%s\n", msg)
|
||||||
|
os.Exit(code)
|
||||||
|
}
|
5
pkg/notifications/email.go
Normal file
5
pkg/notifications/email.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package notifications
|
||||||
|
|
||||||
|
func GetConfig() {
|
||||||
|
|
||||||
|
}
|
101
pkg/notifications/notification.go
Normal file
101
pkg/notifications/notification.go
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
// notification.go
|
||||||
|
// Copyright (C) Andrew Woodlee 2023
|
||||||
|
// License: Apache-2.0
|
||||||
|
package notifications
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||||
|
"github.com/nikoksr/notify"
|
||||||
|
"github.com/nikoksr/notify/service/mail"
|
||||||
|
"github.com/nikoksr/notify/service/matrix"
|
||||||
|
"maunium.net/go/mautrix/id"
|
||||||
|
)
|
||||||
|
|
||||||
|
type matrixStruct struct {
|
||||||
|
homeserver string
|
||||||
|
roomid id.RoomID
|
||||||
|
accessToken string
|
||||||
|
userId id.UserID
|
||||||
|
}
|
||||||
|
|
||||||
|
type mailConfig struct {
|
||||||
|
senderaddress string
|
||||||
|
host string
|
||||||
|
to []string
|
||||||
|
username string
|
||||||
|
password string
|
||||||
|
port string
|
||||||
|
}
|
||||||
|
|
||||||
|
var services []notify.Notifier
|
||||||
|
|
||||||
|
func SetupCommandsNotifiers(backyConfig backy.BackyConfigFile, ids ...string) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// SetupNotify sets up notify instances for each command list.
|
||||||
|
|
||||||
|
func SetupNotify(backyConfig backy.BackyConfigFile) {
|
||||||
|
|
||||||
|
for _, cmdConfig := range backyConfig.CmdConfigLists {
|
||||||
|
for notifyID, notifConfig := range cmdConfig.NotificationsConfig {
|
||||||
|
if cmdConfig.NotificationsConfig[notifyID].Enabled {
|
||||||
|
config := notifConfig.Config
|
||||||
|
switch notifConfig.Config.GetString("type") {
|
||||||
|
case "matrix":
|
||||||
|
// println(config.GetString("access-token"))
|
||||||
|
mtrx := matrixStruct{
|
||||||
|
userId: id.UserID(config.GetString("user-id")),
|
||||||
|
roomid: id.RoomID(config.GetString("room-id")),
|
||||||
|
accessToken: config.GetString("access-token"),
|
||||||
|
homeserver: config.GetString("homeserver"),
|
||||||
|
}
|
||||||
|
mtrxClient, _ := setupMatrix(mtrx)
|
||||||
|
services = append(services, mtrxClient)
|
||||||
|
case "mail":
|
||||||
|
mailCfg := mailConfig{
|
||||||
|
senderaddress: config.GetString("senderaddress"),
|
||||||
|
password: config.GetString("password"),
|
||||||
|
username: config.GetString("username"),
|
||||||
|
to: config.GetStringSlice("to"),
|
||||||
|
host: config.GetString("host"),
|
||||||
|
port: fmt.Sprint(config.GetUint16("port")),
|
||||||
|
}
|
||||||
|
mailClient := setupMail(mailCfg)
|
||||||
|
services = append(services, mailClient)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
backyNotify := notify.New()
|
||||||
|
|
||||||
|
backyNotify.UseServices(services...)
|
||||||
|
|
||||||
|
// err := backyNotify.Send(
|
||||||
|
// context.Background(),
|
||||||
|
// "Subject/Title",
|
||||||
|
// "The actual message - Hello, you awesome gophers! :)",
|
||||||
|
// )
|
||||||
|
// if err != nil {
|
||||||
|
// panic(err)
|
||||||
|
// }
|
||||||
|
// logging.ExitWithMSG("This was a test of notifications", 0, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupMatrix(config matrixStruct) (*matrix.Matrix, error) {
|
||||||
|
matrixClient, matrixErr := matrix.New(config.userId, config.roomid, config.homeserver, config.accessToken)
|
||||||
|
if matrixErr != nil {
|
||||||
|
panic(matrixErr)
|
||||||
|
}
|
||||||
|
return matrixClient, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func setupMail(config mailConfig) *mail.Mail {
|
||||||
|
mailClient := mail.New(config.senderaddress, config.host+":"+config.port)
|
||||||
|
mailClient.AuthenticateSMTP("", config.username, config.password, config.host)
|
||||||
|
mailClient.AddReceivers(config.to...)
|
||||||
|
return mailClient
|
||||||
|
}
|
Reference in New Issue
Block a user