Compare commits
130 Commits
2f73df73b1
...
v0.7.0
Author | SHA1 | Date | |
---|---|---|---|
67a1eab908 | |||
c618ca33f8 | |||
6e7d912fa2 | |||
b90d1958b2 | |||
c187fbb735 | |||
c3de4386ab | |||
e20141043c | |||
11ec1a98d8 | |||
8788d473a5 | |||
edc669b340 | |||
086835453b | |||
5d3c265ce9 | |||
8c633fd4b2 | |||
a664edaed7 | |||
e88773e289 | |||
5c2bfcc940 | |||
aee513f786 | |||
6b99cfa196 | |||
c24e8086e9 | |||
c12bbe3bee | |||
33febd662e | |||
5635c1edd0 | |||
e169778c82 | |||
c838bfe815 | |||
e81a5def47 | |||
18884c640d | |||
ee2256bfb2 | |||
82d79c520a | |||
c30ae2ac3e | |||
fc738597ff | |||
aebef21eb4 | |||
c660e97434 | |||
d35fdc890d | |||
6fe1f26c71 | |||
5b5568910d | |||
3425330890 | |||
b5f7c3fd72 | |||
01efeab13f | |||
9a663f4260 | |||
7c635c36e0 | |||
fff33849da | |||
3391ffa4e6 | |||
b7d1be495e | |||
2daf2f130d | |||
d120c2ca8f | |||
02fd04930d | |||
10b0abe707 | |||
291a954e9c | |||
e43eecf383 | |||
ea676fe0da | |||
e73bd9ff3b | |||
fd9426181f | |||
c25edc5d78 | |||
aebfbda64e | |||
5fe0629b0f | |||
7d6acd77b5 | |||
9d646297c7 | |||
bf8d261cf3 | |||
686cd0019a | |||
b7b002bd72 | |||
b8a63f39f5 | |||
feacb83274 | |||
2aeb435167 | |||
51f5084dd0 | |||
cf04e4456a | |||
25dc6225b3 | |||
a300f696d3 | |||
8161aaa0a9 | |||
a6bfabe22f | |||
a5466fc121 | |||
fbf2d9cbbc | |||
437642608b | |||
a4214b2b3f | |||
6ccb75f4fa | |||
b8a82b2836 | |||
78428a49fc | |||
42bc11bf1a | |||
44e3d534f6 | |||
1fbe3282c8 | |||
10a6342233 | |||
a35db2e05d | |||
7c4868ee4b | |||
affdd0abfd | |||
7224661c71 | |||
e353ed0225 | |||
37bd69b675 | |||
14bca64657 | |||
d9baf44199 | |||
6de94d038f | |||
a04d1db077 | |||
62942540b5 | |||
904a579994 | |||
4b382bddd9 | |||
5e7c52997c | |||
f7676e73ba | |||
2ca5f193e4 | |||
9ffa2e473e | |||
9fd60b6bf7 | |||
951bf97eb2 | |||
a2a89011fe | |||
d893a2684e | |||
ee83586072 | |||
02321870b5 | |||
3e9138e05a | |||
51f9e9a776 | |||
37c20aaafa | |||
9c202cf3e9 | |||
c3fa74e442 | |||
0f3cf0d9c4 | |||
059f4c0097 | |||
03f54c8714 | |||
37c57f6438 | |||
1c7515a633 | |||
8079030752 | |||
15019fbd61 | |||
3960d5ec75 | |||
9f615b0750 | |||
8e9d563d1f | |||
e2f4553303 | |||
15a7ca6c3d | |||
ae87ccb4b5 | |||
6b85913316 | |||
9d07298eb0 | |||
9648fe8ab9 | |||
14650c4db1 | |||
3863f34fc0 | |||
abec574b76 | |||
198d0ca4b9 | |||
b25c7ea5ea | |||
59c2c028c8 |
9
.changes/0.2.4.md
Normal file
9
.changes/0.2.4.md
Normal file
@ -0,0 +1,9 @@
|
||||
## 0.2.4 - 2023-02-18
|
||||
### Added
|
||||
* Notifications now display errors and the output of the failed command.
|
||||
* CI configs for GitHub and Woodpecker
|
||||
* Added `version` subcommand
|
||||
### Changed
|
||||
* Console logging can be disabled by setting `console-disabled` in the `logging` object
|
||||
## Fixed
|
||||
* If Host was not defined for an incomplete `hosts` object, any commands would fail as they could not look up the values in the SSH config files.
|
6
.changes/header.tpl.md
Normal file
6
.changes/header.tpl.md
Normal file
@ -0,0 +1,6 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
0
.changes/unreleased/.gitkeep
Normal file
0
.changes/unreleased/.gitkeep
Normal file
8
.changes/v0.3.0.md
Normal file
8
.changes/v0.3.0.md
Normal file
@ -0,0 +1,8 @@
|
||||
## v0.3.0 - 2023-01-07
|
||||
### Added
|
||||
* Getting environment variables and passwords from Vault (not tested yet)
|
||||
* Vault configuration to config (not tested yet)
|
||||
* Ability to run scripts from file on local machine on the remote host
|
||||
* Ability to get ouput in the notification of a list for individual commands or all commands
|
||||
### Changed
|
||||
* Make SSH connections close after all commands have been run; reuse previous connections if needed
|
3
.changes/v0.3.1.md
Normal file
3
.changes/v0.3.1.md
Normal file
@ -0,0 +1,3 @@
|
||||
## v0.3.1 - 2023-07-20
|
||||
### Changed
|
||||
* If an SSH session failed to be created, the command would fail. This would be caused when restarting the SSH host. The SSH connection is attempted to be created again. If successful, the command is executed normally.
|
13
.changes/v0.4.0.md
Normal file
13
.changes/v0.4.0.md
Normal file
@ -0,0 +1,13 @@
|
||||
## v0.4.0 - 2023-09-08
|
||||
|
||||
### Added
|
||||
|
||||
* Added `scriptEnvFile` to command object that allows one to specify an environment file (or any file really) when a `scriptFile` is run. Inspired by the practice of keeping environment variables and scripts or commands seperate.
|
||||
* Basis for listing commands
|
||||
|
||||
### Changed
|
||||
|
||||
* BREAKING: Notifications object now takes the form of service.id, where service can be "mail" or "matrix" and id is a unique id for the service.
|
||||
* BREAKING: Since the change to the notifications object, cmd-lists' inner map key 'notifications' must be of the form service.id. id must be defined for that service. See notifications docs for aviliable services.
|
||||
* Config parser is now the simpler Koanf - Keys are now case-sensitive
|
||||
* Log size limited to 50 Mb
|
9
.changes/v0.5.0.md
Normal file
9
.changes/v0.5.0.md
Normal file
@ -0,0 +1,9 @@
|
||||
## v0.5.0 - 2024-11-19
|
||||
### Added
|
||||
* Lists can now go in a file. See docs for more information.
|
||||
* commands.[name].type: script now opens `scriptEnvFile`.
|
||||
* Hooks for Commands.[name]. Error, success, and final. [#12]
|
||||
### Changed
|
||||
* GetKnownHosts is now a method of Host
|
||||
### Fixed
|
||||
* make command logger be used for errors, not just when running the command
|
4
.changes/v0.6.0.md
Normal file
4
.changes/v0.6.0.md
Normal file
@ -0,0 +1,4 @@
|
||||
## v0.6.0 - 2025-01-04
|
||||
### Added
|
||||
* Command Type Package - allows one to perform package operations [docs](https://backy.cybershell.xyz/config/packages/)
|
||||
* Exec subcommand `host` allows for parallel execution of commands on hosts. [See docs](https://backy.cybershell.xyz/cli/exec)
|
3
.changes/v0.6.1.md
Normal file
3
.changes/v0.6.1.md
Normal file
@ -0,0 +1,3 @@
|
||||
## v0.6.1 - 2025-01-04
|
||||
### Fixed
|
||||
* When running a list, hooks now run explicitly after the command executes. Fixed panic due to improper logic.
|
16
.changes/v0.7.0.md
Normal file
16
.changes/v0.7.0.md
Normal file
@ -0,0 +1,16 @@
|
||||
## v0.7.0 - 2025-02-11
|
||||
### Added
|
||||
* [feat]: package `packageOperation` option `checkVersion` implemented
|
||||
* user management added - see docs
|
||||
* Support for remote config sources. Only config file and list can be used for now.
|
||||
* Cache functionality - still a WIP
|
||||
* Flag `--s3-endpoint` for config file fetching from S3
|
||||
### Changed
|
||||
* Internal refactoring of config setup
|
||||
* Formatting and sending for notifications
|
||||
* name of `configfetcher` to `remotefetcher`
|
||||
* Flags that took comma-separated lists now have to be passed multiple times for each argument.
|
||||
* Hosts passed to `exec host` now checked against default SSH config files
|
||||
### Fixed
|
||||
* Parsing of remote URLs when determining list config file path
|
||||
* Incorrect error notification template value
|
26
.changie.yaml
Normal file
26
.changie.yaml
Normal file
@ -0,0 +1,26 @@
|
||||
changesDir: .changes
|
||||
unreleasedDir: unreleased
|
||||
headerPath: header.tpl.md
|
||||
changelogPath: CHANGELOG.md
|
||||
versionExt: md
|
||||
versionFormat: '## {{.Version}} - {{.Time.Format "2006-01-02"}}'
|
||||
kindFormat: '### {{.Kind}}'
|
||||
changeFormat: '* {{.Body}}'
|
||||
kinds:
|
||||
- label: Added
|
||||
auto: minor
|
||||
- label: Changed
|
||||
auto: major
|
||||
- label: Deprecated
|
||||
auto: minor
|
||||
- label: Removed
|
||||
auto: major
|
||||
- label: Fixed
|
||||
auto: patch
|
||||
- label: Security
|
||||
auto: patch
|
||||
newlines:
|
||||
afterChangelogHeader: 1
|
||||
beforeChangelogVersion: 1
|
||||
endOfVersion: 1
|
||||
envPrefix: CHANGIE_
|
1
.frontmatter/database/mediaDb.json
Normal file
1
.frontmatter/database/mediaDb.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
1
.frontmatter/database/taxonomyDb.json
Normal file
1
.frontmatter/database/taxonomyDb.json
Normal file
@ -0,0 +1 @@
|
||||
{}
|
40
.github/workflows/release.yml
vendored
Normal file
40
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
name: goreleaser
|
||||
|
||||
on:
|
||||
push:
|
||||
# run only against tags
|
||||
tags:
|
||||
- '*'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
packages: write
|
||||
# issues: write
|
||||
|
||||
jobs:
|
||||
goreleaser:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- run: git fetch --force --tags
|
||||
- uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.20'
|
||||
cache: true
|
||||
# More assembly might be required: Docker logins, GPG, etc. It all depends
|
||||
# on your needs.
|
||||
- name: Get tag
|
||||
id: tag
|
||||
uses: dawidd6/action-get-tag@v1
|
||||
with:
|
||||
# Optionally strip `v` prefix
|
||||
strip_v: false
|
||||
- uses: goreleaser/goreleaser-action@v4
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --release-notes=".changes/${{steps.tag.outputs.tag}}.md" -f .goreleaser/github.yml --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GORELEASER_TOKEN }}
|
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
|
||||
dist/
|
||||
.codegpt
|
||||
|
||||
*.log
|
||||
*.sh
|
7
.gitmodules
vendored
Normal file
7
.gitmodules
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
[submodule "docs/themes/hugo-theme-relearn"]
|
||||
path = docs/themes/hugo-theme-relearn
|
||||
url = https://github.com/McShelby/hugo-theme-relearn.git
|
||||
|
||||
[submodule "docs/themes/plausible-hugo"]
|
||||
path = docs/themes/plausible-hugo
|
||||
url = https://github.com/divinerites/plausible-hugo.git
|
44
.goreleaser/gitea.yml
Normal file
44
.goreleaser/gitea.yml
Normal file
@ -0,0 +1,44 @@
|
||||
version: 2
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
- GOPROXY=https://goproxy.io
|
||||
goos:
|
||||
- freebsd
|
||||
- linux
|
||||
goarch:
|
||||
- "386"
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
# this name template makes the OS and Arch compatible with the results of uname.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_{{ .Version }}_
|
||||
{{- 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:
|
||||
version_template: "{{ incpatch .Version }}-next"
|
||||
changelog:
|
||||
disable: false
|
||||
|
||||
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
|
42
.goreleaser/github.yml
Normal file
42
.goreleaser/github.yml
Normal file
@ -0,0 +1,42 @@
|
||||
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||
# Make sure to check the documentation at https://goreleaser.com
|
||||
version: 2
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- freebsd
|
||||
- linux
|
||||
goarch:
|
||||
- "386"
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
archives:
|
||||
- format: tar.gz
|
||||
# this name template makes the OS and Arch compatible with the results of uname.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_{{ .Version }}_
|
||||
{{- 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:
|
||||
version_template: "{{ incpatch .Version }}-next"
|
||||
changelog:
|
||||
sort: asc
|
||||
filters:
|
||||
exclude:
|
||||
- '^docs:'
|
||||
- '^test:'
|
46
.goreleaser/vern.yml
Normal file
46
.goreleaser/vern.yml
Normal file
@ -0,0 +1,46 @@
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
- go mod tidy
|
||||
builds:
|
||||
- env:
|
||||
- CGO_ENABLED=0
|
||||
goos:
|
||||
- freebsd
|
||||
- linux
|
||||
goarch:
|
||||
- "386"
|
||||
- amd64
|
||||
- arm64
|
||||
|
||||
archives:
|
||||
- format: binary
|
||||
# this name template makes the OS and Arch compatible with the results of uname.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_{{ .Version }}_
|
||||
{{- 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.vern.cc/api/v1
|
||||
download: https://git.vern.cc
|
||||
# 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
|
10
.vscode/settings.json
vendored
10
.vscode/settings.json
vendored
@ -1,5 +1,13 @@
|
||||
{
|
||||
"cSpell.words": [
|
||||
"Cmds"
|
||||
"Cmds",
|
||||
"remotefetcher",
|
||||
"knadh",
|
||||
"koanf",
|
||||
"mattn",
|
||||
"maunium",
|
||||
"mautrix",
|
||||
"nikoksr",
|
||||
"Strs"
|
||||
]
|
||||
}
|
12
.woodpecker/gitea.yml
Normal file
12
.woodpecker/gitea.yml
Normal file
@ -0,0 +1,12 @@
|
||||
steps:
|
||||
release:
|
||||
image: goreleaser/goreleaser
|
||||
commands:
|
||||
- goreleaser release -f .goreleaser/gitea.yml --release-notes=".changes/$(go run backy.go version -V).md"
|
||||
secrets: [ gitea_token ]
|
||||
when:
|
||||
event: tag
|
||||
|
||||
when:
|
||||
- event: tag
|
||||
branch: master
|
14
.woodpecker/go-lint.yml
Normal file
14
.woodpecker/go-lint.yml
Normal file
@ -0,0 +1,14 @@
|
||||
steps:
|
||||
build:
|
||||
image: golang
|
||||
commands:
|
||||
- go build
|
||||
- go test
|
||||
release:
|
||||
image: golangci/golangci-lint:v1.53.3
|
||||
commands:
|
||||
- golangci-lint run -v --timeout 5m
|
||||
|
||||
when:
|
||||
- event: push
|
||||
branch: develop
|
29
.woodpecker/publish-docs.yml
Normal file
29
.woodpecker/publish-docs.yml
Normal file
@ -0,0 +1,29 @@
|
||||
steps:
|
||||
build:
|
||||
image: hugomods/hugo:ci
|
||||
commands:
|
||||
- git submodule foreach 'git fetch origin; git checkout $(git describe --tags `git rev-list --tags --max-count=1`);'
|
||||
- cd docs
|
||||
- hugo mod get -u github.com/divinerites/plausible-hugo
|
||||
- hugo mod get -u github.com/McShelby/hugo-theme-relearn@7.3.1
|
||||
- hugo
|
||||
|
||||
deploy:
|
||||
image: codingkoopa/git-rsync-openssh
|
||||
commands:
|
||||
- cd docs
|
||||
- echo "nameserver 1.1.1.1" > /etc/resolv.conf
|
||||
- mkdir ~/.ssh && chmod -R 700 ~/.ssh
|
||||
# - apt update -y && apt install openssh-client rsync -y
|
||||
- echo "$SSH_HOST_KEY" > ~/.ssh/known_hosts
|
||||
- echo -e '#!/bin/sh\necho "$SSH_PASSPHRASE"' | tr -d '\r' > ~/.ssh/.print_ssh_password
|
||||
# - cat ~/.ssh/.print_ssh_password
|
||||
- chmod 700 ~/.ssh/.print_ssh_password
|
||||
- eval $(ssh-agent -s)
|
||||
- echo "$SSH_DEPLOY_KEY" | tr -d '\r' | DISPLAY=":0.0" SSH_ASKPASS=~/.ssh/.print_ssh_password setsid ssh-add -
|
||||
- rsync -atv --delete --progress public/ backy@backy.cybershell.xyz:docs
|
||||
- rsync -atv --delete --progress vangen/ backy@backy.cybershell.xyz:vangen-go
|
||||
secrets: [ ssh_host_key, ssh_deploy_key, ssh_passphrase ]
|
||||
|
||||
when:
|
||||
- branch: master
|
79
CHANGELOG.md
Normal file
79
CHANGELOG.md
Normal file
@ -0,0 +1,79 @@
|
||||
# Changelog
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html),
|
||||
and is generated by [Changie](https://github.com/miniscruff/changie).
|
||||
|
||||
|
||||
## v0.7.0 - 2025-02-11
|
||||
### Added
|
||||
* [feat]: package `packageOperation` option `checkVersion` implemented
|
||||
* user management added - see docs
|
||||
* Support for remote config sources. Only config file and list can be used for now.
|
||||
* Cache functionality - still a WIP
|
||||
* Flag `--s3-endpoint` for config file fetching from S3
|
||||
### Changed
|
||||
* Internal refactoring of config setup
|
||||
* Formatting and sending for notifications
|
||||
* name of `configfetcher` to `remotefetcher`
|
||||
* Flags that took comma-separated lists now have to be passed multiple times for each argument.
|
||||
* Hosts passed to `exec host` now checked against default SSH config files
|
||||
### Fixed
|
||||
* Parsing of remote URLs when determining list config file path
|
||||
* Incorrect error notification template value
|
||||
|
||||
## v0.6.1 - 2025-01-04
|
||||
### Fixed
|
||||
* When running a list, hooks now run explicitly after the command executes. Fixed panic due to improper logic.
|
||||
## v0.6.0 - 2025-01-04
|
||||
### Added
|
||||
* Command Type Package - allows one to perform package operations [docs](https://backy.cybershell.xyz/config/packages/)
|
||||
* Exec subcommand `host` allows for parallel execution of commands on hosts. [See docs](https://backy.cybershell.xyz/cli/exec)
|
||||
|
||||
## v0.5.0 - 2024-11-19
|
||||
### Added
|
||||
* Lists can now go in a file. See docs for more information.
|
||||
* commands.[name].type: script now opens `scriptEnvFile`.
|
||||
* Hooks for Commands.[name]. Error, success, and final. [#12]
|
||||
### Changed
|
||||
* GetKnownHosts is now a method of Host
|
||||
### Fixed
|
||||
* make command logger be used for errors, not just when running the command
|
||||
|
||||
## v0.4.0 - 2023-09-08
|
||||
|
||||
### Added
|
||||
|
||||
* Added `scriptEnvFile` to command object that allows one to specify an environment file (or any file really) when a `scriptFile` is run. Inspired by the practice of keeping environment variables and scripts or commands seperate.
|
||||
* Basis for listing commands
|
||||
|
||||
### Changed
|
||||
|
||||
* BREAKING: Notifications object now takes the form of service.id, where service can be "mail" or "matrix" and id is a unique id for the service.
|
||||
* BREAKING: Since the change to the notifications object, cmd-lists' inner map key 'notifications' must be of the form service.id. id must be defined for that service. See notifications docs for aviliable services.
|
||||
* Config parser is now the simpler Koanf - Keys are now case-sensitive
|
||||
* Log size limited to 50 Mb
|
||||
|
||||
## v0.3.1 - 2023-07-20
|
||||
### Changed
|
||||
* If an SSH session failed to be created, the command would fail. This would be caused when restarting the SSH host. The SSH connection is attempted to be created again. If successful, the command is executed normally.
|
||||
|
||||
## v0.3.0 - 2023-01-07
|
||||
### Added
|
||||
* Getting environment variables and passwords from Vault (not tested yet)
|
||||
* Vault configuration to config (not tested yet)
|
||||
* Ability to run scripts from file on local machine on the remote host
|
||||
* Ability to get ouput in the notification of a list for individual commands or all commands
|
||||
### Changed
|
||||
* Make SSH connections close after all commands have been run; reuse previous connections if needed
|
||||
|
||||
## 0.2.4 - 2023-02-18
|
||||
### Added
|
||||
* Notifications now display errors and the output of the failed command.
|
||||
* CI configs for GitHub and Woodpecker
|
||||
* Added `version` subcommand
|
||||
### Changed
|
||||
* Console logging can be disabled by setting `console-disabled` in the `logging` object
|
||||
## Fixed
|
||||
* If Host was not defined for an incomplete `hosts` object, any commands would fail as they could not look up the values in the SSH config files.
|
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.
|
22
README.md
Normal file
22
README.md
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
# Backy - an application to manage backups
|
||||
|
||||
See the [install documentation](https://backy.cybershell.xyz/getting-started/install/index.html)
|
||||
|
||||
## Security
|
||||
|
||||
The latest version is currently the only supported version.
|
||||
|
||||
## Features
|
||||
|
||||
- Allows easy configuration of executable commands
|
||||
|
||||
- Allows for commands to be run on many hosts over SSH
|
||||
|
||||
- Commands can be grouped in list to run in specific order
|
||||
|
||||
- Notifications on completion and failure
|
||||
|
||||
- Run in cron mode
|
||||
|
||||
- For any command, especially backup commands
|
21
backy.code-workspace
Normal file
21
backy.code-workspace
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"name": "backy",
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"cSpell.words": [
|
||||
"Cmds",
|
||||
"remotefetcher",
|
||||
"knadh",
|
||||
"koanf",
|
||||
"mattn",
|
||||
"maunium",
|
||||
"mautrix",
|
||||
"nikoksr",
|
||||
"Strs"
|
||||
]
|
||||
}
|
||||
}
|
1
cmd/.gitignore
vendored
1
cmd/.gitignore
vendored
@ -1 +1,2 @@
|
||||
*.yaml
|
||||
*.yml
|
43
cmd/backup.go
Normal file
43
cmd/backup.go
Normal file
@ -0,0 +1,43 @@
|
||||
// backup.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
backupCmd = &cobra.Command{
|
||||
Use: "backup [--lists=list1 --lists list2 ... | -l list1 -l list2 ...]",
|
||||
Short: "Runs commands defined in config file. Use -l flag multiple times to run multiple lists.",
|
||||
Long: "Backup executes commands defined in config file.\nUse the --lists or -l flag to execute the specified lists. If not flag is not given, all lists will be executed.",
|
||||
Run: Backup,
|
||||
}
|
||||
)
|
||||
|
||||
// Holds command list to run
|
||||
var cmdLists []string
|
||||
|
||||
func init() {
|
||||
parseS3Config()
|
||||
|
||||
backupCmd.Flags().StringArrayVarP(&cmdLists, "lists", "l", nil, "Accepts comma-separated names of command lists to execute.")
|
||||
|
||||
}
|
||||
|
||||
func Backup(cmd *cobra.Command, args []string) {
|
||||
backyConfOpts := backy.NewOpts(cfgFile, backy.AddCommandLists(cmdLists))
|
||||
backyConfOpts.InitConfig()
|
||||
backyConfOpts.ReadConfig()
|
||||
|
||||
backyConfOpts.RunListConfig("")
|
||||
for _, host := range backyConfOpts.Hosts {
|
||||
if host.SshClient != nil {
|
||||
host.SshClient.Close()
|
||||
}
|
||||
}
|
||||
}
|
31
cmd/config.go
Normal file
31
cmd/config.go
Normal file
@ -0,0 +1,31 @@
|
||||
package cmd
|
||||
|
||||
// import (
|
||||
// "git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
|
||||
// "github.com/spf13/cobra"
|
||||
// )
|
||||
|
||||
// var (
|
||||
// configCmd = &cobra.Command{
|
||||
// Use: "config list ...",
|
||||
// Short: "Runs commands defined in config file.",
|
||||
// Long: `Cron executes commands at the time defined in config file.`,
|
||||
// Run: config,
|
||||
// }
|
||||
|
||||
// cmds []string
|
||||
// lists []string
|
||||
// )
|
||||
|
||||
// func config(cmd *cobra.Command, args []string) {
|
||||
|
||||
// opts := backy.NewOpts(cfgFile, backy.cronEnabled())
|
||||
// opts.InitConfig()
|
||||
|
||||
// }
|
||||
|
||||
// func init() {
|
||||
|
||||
// configCmd.PersistentFlags().StringArrayVarP(&cmds, "cmds", "c", nil, "Accepts comma-seperated list of commands to list")
|
||||
// }
|
26
cmd/cron.go
Normal file
26
cmd/cron.go
Normal file
@ -0,0 +1,26 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
cronCmd = &cobra.Command{
|
||||
Use: "cron [flags]",
|
||||
Short: "Starts a scheduler that runs lists defined in config file.",
|
||||
Long: `Cron starts a scheduler that executes command lists at the time defined in config file.`,
|
||||
Run: cron,
|
||||
}
|
||||
)
|
||||
|
||||
func cron(cmd *cobra.Command, args []string) {
|
||||
parseS3Config()
|
||||
|
||||
opts := backy.NewOpts(cfgFile, backy.EnableCron())
|
||||
opts.InitConfig()
|
||||
opts.ReadConfig()
|
||||
|
||||
opts.Cron()
|
||||
}
|
39
cmd/exec.go
Normal file
39
cmd/exec.go
Normal file
@ -0,0 +1,39 @@
|
||||
// exec.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
execCmd = &cobra.Command{
|
||||
Use: "exec command ...",
|
||||
Short: "Runs commands defined in config file in order given.",
|
||||
Long: `Exec executes commands defined in config file in order given.`,
|
||||
Run: execute,
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
execCmd.AddCommand(hostExecCommand)
|
||||
|
||||
}
|
||||
|
||||
func execute(cmd *cobra.Command, args []string) {
|
||||
parseS3Config()
|
||||
|
||||
if len(args) < 1 {
|
||||
logging.ExitWithMSG("Please provide a command to run. Pass --help to see options.", 1, nil)
|
||||
}
|
||||
|
||||
opts := backy.NewOpts(cfgFile, backy.AddCommands(args), backy.SetLogFile(logFile))
|
||||
opts.InitConfig()
|
||||
opts.ReadConfig()
|
||||
opts.ExecuteCmds()
|
||||
}
|
72
cmd/host.go
Normal file
72
cmd/host.go
Normal file
@ -0,0 +1,72 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
hostExecCommand = &cobra.Command{
|
||||
Use: "host [--command=command1 --command=command2 ... | -c command1 -c command2 ...] [--hosts=host1 --hosts=hosts2 ... | -m host1 -m host2 ...] ",
|
||||
Short: "Runs command defined in config file on the hosts in order specified.",
|
||||
Long: "Host executes specified commands on the hosts defined in config file.\nUse the --commands or -c flag to choose the commands.",
|
||||
Run: Host,
|
||||
}
|
||||
)
|
||||
|
||||
// Holds list of hosts to run commands on
|
||||
var hostsList []string
|
||||
|
||||
// Holds command list to run
|
||||
var cmdList []string
|
||||
|
||||
func init() {
|
||||
|
||||
hostExecCommand.Flags().StringArrayVarP(&hostsList, "hosts", "m", nil, "Accepts space-separated names of hosts. Specify multiple times for multiple hosts.")
|
||||
hostExecCommand.Flags().StringArrayVarP(&cmdList, "command", "c", nil, "Accepts space-separated names of commands. Specify multiple times for multiple commands.")
|
||||
parseS3Config()
|
||||
|
||||
}
|
||||
|
||||
// cli input should be hosts and commands. Hosts are defined in config files.
|
||||
// commands can be passed by the following mutually exclusive options:
|
||||
// 1. as a list of commands defined in the config file
|
||||
// 2. stdin (on command line) (TODO)
|
||||
|
||||
func Host(cmd *cobra.Command, args []string) {
|
||||
backyConfOpts := backy.NewOpts(cfgFile, backy.SetLogFile(logFile))
|
||||
backyConfOpts.InitConfig()
|
||||
|
||||
backyConfOpts.ReadConfig()
|
||||
|
||||
// check CLI input
|
||||
if hostsList == nil {
|
||||
logging.ExitWithMSG("error: hosts must be specified", 1, &backyConfOpts.Logger)
|
||||
}
|
||||
|
||||
for _, h := range hostsList {
|
||||
// check if h exists in the config file
|
||||
_, hostFound := backyConfOpts.Hosts[h]
|
||||
if !hostFound {
|
||||
// check if h exists in the SSH config file
|
||||
hostFoundInConfig, s := backy.CheckIfHostHasHostName(h)
|
||||
if !hostFoundInConfig {
|
||||
logging.ExitWithMSG("host "+h+" not found", 1, &backyConfOpts.Logger)
|
||||
}
|
||||
// create host with hostname and host
|
||||
backyConfOpts.Hosts[h] = &backy.Host{Host: h, HostName: s}
|
||||
}
|
||||
}
|
||||
if cmdList == nil {
|
||||
logging.ExitWithMSG("error: commands must be specified", 1, &backyConfOpts.Logger)
|
||||
}
|
||||
for _, c := range cmdList {
|
||||
_, cmdFound := backyConfOpts.Cmds[c]
|
||||
if !cmdFound {
|
||||
logging.ExitWithMSG("cmd "+c+" not found", 1, &backyConfOpts.Logger)
|
||||
}
|
||||
}
|
||||
|
||||
backyConfOpts.ExecCmdsSSH(cmdList, hostsList)
|
||||
}
|
49
cmd/list.go
Normal file
49
cmd/list.go
Normal file
@ -0,0 +1,49 @@
|
||||
// backup.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var (
|
||||
listCmd = &cobra.Command{
|
||||
Use: "list [--list=list1,list2,... | -l list1, list2,...] [ -cmd cmd1 cmd2 cmd3...]",
|
||||
Short: "Lists commands, lists, or hosts defined in config file.",
|
||||
Long: "Backup lists commands or groups defined in config file.\nUse the --lists or -l flag to list the specified lists. If not flag is not given, all lists will be executed.",
|
||||
Run: List,
|
||||
}
|
||||
)
|
||||
|
||||
var listsToList []string
|
||||
var cmdsToList []string
|
||||
|
||||
func init() {
|
||||
|
||||
listCmd.Flags().StringSliceVarP(&listsToList, "lists", "l", nil, "Accepts comma-separated names of command lists to list.")
|
||||
listCmd.Flags().StringSliceVarP(&cmdsToList, "cmds", "c", nil, "Accepts comma-separated names of commands to list.")
|
||||
|
||||
}
|
||||
|
||||
func List(cmd *cobra.Command, args []string) {
|
||||
|
||||
// setup based on whats passed in:
|
||||
// - cmds
|
||||
// - lists
|
||||
// - if none, list all commands
|
||||
if cmdLists != nil {
|
||||
|
||||
}
|
||||
parseS3Config()
|
||||
|
||||
opts := backy.NewOpts(cfgFile)
|
||||
|
||||
opts.InitConfig()
|
||||
opts.ReadConfig()
|
||||
|
||||
opts.ListCommand("rm-sn-db")
|
||||
}
|
49
cmd/root.go
49
cmd/root.go
@ -1,60 +1,49 @@
|
||||
// root.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var (
|
||||
// Used for flags.
|
||||
cfgFile string
|
||||
verbose bool
|
||||
logFile string
|
||||
s3Endpoint string
|
||||
|
||||
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.`,
|
||||
Long: `Backy is a command-line application useful for configuring backups, or any commands run in sequence.`,
|
||||
}
|
||||
)
|
||||
|
||||
// Execute executes the root command.
|
||||
func Execute() error {
|
||||
return rootCmd.Execute()
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
rootCmd.PersistentFlags().StringVar(&logFile, "log-file", "", "log file to write to")
|
||||
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "c", "", "config file to read from")
|
||||
rootCmd.PersistentFlags().StringVarP(&cfgFile, "config", "f", "", "config file to read from")
|
||||
rootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Sets verbose level")
|
||||
rootCmd.PersistentFlags().Bool("viper", true, "use Viper for configuration")
|
||||
rootCmd.PersistentFlags().StringVar(&s3Endpoint, "s3-endpoint", "", "Sets the S3 endpoint used for config file fetching. Overrides S3_ENDPOINT env variable.")
|
||||
rootCmd.AddCommand(backupCmd, execCmd, cronCmd, versionCmd, listCmd)
|
||||
}
|
||||
|
||||
func initConfig() {
|
||||
backyConfig := viper.New()
|
||||
if cfgFile != "" {
|
||||
// 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())
|
||||
func parseS3Config() {
|
||||
if s3Endpoint != "" {
|
||||
os.Setenv("S3_ENDPOINT", s3Endpoint)
|
||||
}
|
||||
}
|
||||
|
39
cmd/version.go
Normal file
39
cmd/version.go
Normal file
@ -0,0 +1,39 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const versionStr = "0.7.0"
|
||||
|
||||
var (
|
||||
versionCmd = &cobra.Command{
|
||||
Use: "version [flags]",
|
||||
Short: "Prints the version and exits",
|
||||
Long: "Prints the version and exits. No arguments just prints the version number only.",
|
||||
Run: version,
|
||||
}
|
||||
numOnly bool
|
||||
vPre bool
|
||||
)
|
||||
|
||||
func init() {
|
||||
versionCmd.PersistentFlags().BoolVarP(&numOnly, "num", "n", false, "Output the version number only.")
|
||||
versionCmd.PersistentFlags().BoolVarP(&vPre, "vpre", "V", false, "Output the version with v prefixed.")
|
||||
}
|
||||
|
||||
func version(cmd *cobra.Command, args []string) {
|
||||
|
||||
if numOnly && !vPre {
|
||||
fmt.Printf("%s\n", versionStr)
|
||||
} else if vPre && !numOnly {
|
||||
fmt.Printf("v%s\n", versionStr)
|
||||
} else {
|
||||
fmt.Printf("Backy version: %s\n", versionStr)
|
||||
}
|
||||
|
||||
os.Exit(0)
|
||||
}
|
2
docs/.gitignore
vendored
Normal file
2
docs/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
public/
|
||||
resources/_gen
|
0
docs/.hugo_build.lock
Normal file
0
docs/.hugo_build.lock
Normal file
6
docs/archetypes/default.md
Normal file
6
docs/archetypes/default.md
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
title: "{{ replace .Name "-" " " | title }}"
|
||||
date: {{ .Date }}
|
||||
draft: true
|
||||
---
|
||||
|
78
docs/config.yaml
Normal file
78
docs/config.yaml
Normal file
@ -0,0 +1,78 @@
|
||||
baseURL: https://backy.cybershell.xyz/
|
||||
languageCode: en-us
|
||||
title: A tool for commands
|
||||
theme:
|
||||
- hugo-theme-relearn
|
||||
- plausible-hugo
|
||||
outputs:
|
||||
home:
|
||||
- HTML
|
||||
- RSS
|
||||
- PRINT
|
||||
module:
|
||||
imports:
|
||||
- path: github.com/divinerites/plausible-hugo
|
||||
- path: github.com/McShelby/hugo-theme-relearn
|
||||
params:
|
||||
themeVariant:
|
||||
- auto: []
|
||||
identifier: relearn-auto
|
||||
name: Relearn Light/Dark
|
||||
- identifier: relearn-light
|
||||
- identifier: relearn-dark
|
||||
- identifier: relearn-bright
|
||||
- auto:
|
||||
- zen-light
|
||||
- zen-dark
|
||||
identifier: zen-auto
|
||||
name: Zen Light/Dark
|
||||
- identifier: zen-light
|
||||
- identifier: zen-dark
|
||||
- auto:
|
||||
- learn
|
||||
- neon
|
||||
identifier: retro-auto
|
||||
name: Retro Learn/Neon
|
||||
- identifier: neon
|
||||
- identifier: learn
|
||||
plausible:
|
||||
enable: true
|
||||
domain: backy.cybershell.xyz
|
||||
outbound_link: true
|
||||
gitstar: false
|
||||
selfhosted_domain: stats.andrewnw.com
|
||||
author:
|
||||
name: Andrew Woodlee
|
||||
alwaysopen: false
|
||||
editURL: ""
|
||||
description: ""
|
||||
showVisitedLinks: false
|
||||
disableSearch: false
|
||||
disableSearchHiddenPages: false
|
||||
disableSeoHiddenPages: false
|
||||
disableTagHiddenPages: false
|
||||
disableAssetsBusting: false
|
||||
disableGeneratorVersion: false
|
||||
disableInlineCopyToClipBoard: false
|
||||
disableShortcutsTitle: false
|
||||
disableLandingPageButton: true
|
||||
disableLanguageSwitchingButton: false
|
||||
disableBreadcrumb: true
|
||||
disableToc: false
|
||||
math: true
|
||||
customMathJaxURL: https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
|
||||
mathJaxInitialize: "{}"
|
||||
mermaid: true
|
||||
customMermaidURL: https://unpkg.com/mermaid/dist/mermaid.min.js
|
||||
mermaidInitialize: '{ "theme": "default" }'
|
||||
disableSwagger: false
|
||||
customSwaggerURL: https://unpkg.com/rapidoc/dist/rapidoc-min.js
|
||||
swaggerInitialize: '{ "theme": "light" }'
|
||||
disableNextPrev: true
|
||||
ordersectionsby: weight
|
||||
titleSeparator: "-"
|
||||
collapsibleMenu: true
|
||||
additionalContentLanguage:
|
||||
- en
|
||||
disableExplicitIndexURLs: false
|
||||
externalLinkTarget: _blank
|
32
docs/content/_index.md
Normal file
32
docs/content/_index.md
Normal file
@ -0,0 +1,32 @@
|
||||
+++
|
||||
archetype = "home"
|
||||
title = "Backy"
|
||||
+++
|
||||
|
||||
Backy is a tool for automating data backup and remote command execution. It can work over SSH, and provides completion and failure notifications, error reporting, and more.
|
||||
|
||||
Why the name Backy? Because I wanted an app for backups.
|
||||
|
||||
View the [changelog here](https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/CHANGELOG.md).
|
||||
|
||||
{{% notice tip %}}
|
||||
Feel free to open a [PR](https://git.andrewnw.xyz/CyberShell/backy/pulls), raise an [issue](https://git.andrewnw.xyz/CyberShell/backy/issues "Open a Gitea Issue")(s), or request new feature(s).
|
||||
{{% /notice %}}
|
||||
|
||||
## Features
|
||||
|
||||
- Allows easy configuration of executable commands
|
||||
|
||||
- Allows for running package operations
|
||||
|
||||
- Allows configuring failure, success, and final hooks
|
||||
|
||||
- Allows for commands to be run on many hosts over SSH
|
||||
|
||||
- Commands can be grouped in list to run in specific order
|
||||
|
||||
- Notifications on completion and failure
|
||||
|
||||
- Run in cron mode
|
||||
|
||||
- For any command, especially backup commands
|
145
docs/content/cli/_index.md
Normal file
145
docs/content/cli/_index.md
Normal file
@ -0,0 +1,145 @@
|
||||
---
|
||||
title: CLI
|
||||
weight: 4
|
||||
---
|
||||
|
||||
This page lists documentation for the CLI.
|
||||
|
||||
## Backy
|
||||
|
||||
```
|
||||
Backy is a command-line application useful for configuring backups, or any commands run in sequence.
|
||||
|
||||
Usage:
|
||||
backy [command]
|
||||
|
||||
Available Commands:
|
||||
backup Runs commands defined in config file.
|
||||
completion Generate the autocompletion script for the specified shell
|
||||
cron Starts a scheduler that runs lists defined in config file.
|
||||
exec Runs commands defined in config file in order given.
|
||||
help Help about any command
|
||||
list Lists commands, lists, or hosts defined in config file.
|
||||
version Prints the version and exits
|
||||
|
||||
Flags:
|
||||
-f, --config string config file to read from
|
||||
-h, --help help for backy
|
||||
-v, --verbose Sets verbose level
|
||||
|
||||
Use "backy [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
# Subcommands
|
||||
|
||||
## backup
|
||||
|
||||
```
|
||||
Backup executes commands defined in config file.
|
||||
Use the --lists or -l flag to execute the specified lists. If not flag is not given, all lists will be executed.
|
||||
|
||||
Usage:
|
||||
backy backup [--lists=list1,list2,... | -l list1, list2,...] [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for backup
|
||||
-l, --lists strings Accepts comma-separated names of command lists to execute.
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
```
|
||||
|
||||
## cron
|
||||
|
||||
```
|
||||
Cron starts a scheduler that executes command lists at the time defined in config file.
|
||||
|
||||
Usage:
|
||||
backy cron [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for cron
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
```
|
||||
|
||||
## exec
|
||||
|
||||
```
|
||||
Exec executes commands defined in config file in order given.
|
||||
|
||||
Usage:
|
||||
backy exec command ... [flags]
|
||||
backy exec [command]
|
||||
|
||||
Available Commands:
|
||||
host Runs command defined in config file on the hosts in order specified.
|
||||
|
||||
Flags:
|
||||
-h, --help help for exec
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
|
||||
Use "backy exec [command] --help" for more information about a command.
|
||||
```
|
||||
|
||||
### exec host
|
||||
|
||||
```
|
||||
Host executes specified commands on the hosts defined in config file.
|
||||
Use the --commands or -c flag to choose the commands.
|
||||
|
||||
Usage:
|
||||
backy exec host [--commands=command1,command2, ... | -c command1,command2, ...] [--hosts=host1,hosts2, ... | -m host1,host2, ...] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --commands strings Accepts comma-separated names of commands.
|
||||
-h, --help help for host
|
||||
-m, --hosts strings Accepts comma-separated names of hosts.
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
```
|
||||
|
||||
## version
|
||||
|
||||
```
|
||||
Prints the version and exits. No arguments just prints the version number only.
|
||||
|
||||
Usage:
|
||||
backy version [flags]
|
||||
|
||||
Flags:
|
||||
-h, --help help for version
|
||||
-n, --num Output the version number only.
|
||||
-V, --vpre Output the version with v prefixed.
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
```
|
||||
|
||||
## list
|
||||
|
||||
```
|
||||
Backup lists commands or groups defined in config file.
|
||||
Use the --lists or -l flag to list the specified lists. If not flag is not given, all lists will be executed.
|
||||
|
||||
Usage:
|
||||
backy list [--list=list1,list2,... | -l list1, list2,...] [ -cmd cmd1 cmd2 cmd3...] [flags]
|
||||
|
||||
Flags:
|
||||
-c, --cmds strings Accepts comma-separated names of commands to list.
|
||||
-h, --help help for list
|
||||
-l, --lists strings Accepts comma-separated names of command lists to list.
|
||||
|
||||
Global Flags:
|
||||
-f, --config string config file to read from
|
||||
-v, --verbose Sets verbose level
|
||||
```
|
19
docs/content/cli/exec.md
Normal file
19
docs/content/cli/exec.md
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
title: Exec
|
||||
---
|
||||
|
||||
The `exec` subcommand can do some things that the configuration file can't do yet. The command `exec host` can execute commands on many hosts.
|
||||
|
||||
`exec host` takes the following arguments:
|
||||
|
||||
```sh
|
||||
-c, --commands strings Accepts comma-separated names of commands.
|
||||
-h, --help help for host
|
||||
-m, --hosts strings Accepts comma-separated names of hosts.
|
||||
```
|
||||
|
||||
The commands have to be defined in the config file. The hosts need to at least be in the ssh_config(5) file.
|
||||
|
||||
```sh
|
||||
backy exec host [--commands=command1,command2, ... | -c command1,command2, ...] [--hosts=host1,hosts2, ... | -m host1,host2, ...] [flags]
|
||||
```
|
40
docs/content/config/_index.md
Normal file
40
docs/content/config/_index.md
Normal file
@ -0,0 +1,40 @@
|
||||
---
|
||||
title: "Configuring Backy"
|
||||
weight: 3
|
||||
description: >
|
||||
This page tells you how to configure Backy.
|
||||
---
|
||||
|
||||
This is the section on the config file.
|
||||
|
||||
To use a specific file:
|
||||
```backy [command] -f /path/to/file```
|
||||
|
||||
You can also use a remote file:
|
||||
```
|
||||
backy [command] -f `s3/http source`
|
||||
```
|
||||
|
||||
See remote resources docs for specific info.
|
||||
|
||||
If you leave the config path blank, the following paths will be searched in order:
|
||||
|
||||
1. `./backy.yml`
|
||||
2. `./backy.yaml`
|
||||
3. The same two files above contained in a `backy` subdirectory under in what is returned by Go's `os` package function `UserConfigDir()`.
|
||||
|
||||
{{% expand title="`UserConfigDir()` documentation:" %}}
|
||||
|
||||
Up-to date documentation for this function may be found on [GoDoc](https://pkg.go.dev/os#UserConfigDir).
|
||||
|
||||
>UserConfigDir returns the default root directory to use for user-specific configuration data. Users should create their own application-specific subdirectory within this one and use that.
|
||||
|
||||
>On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%. On Plan 9, it returns $home/lib.
|
||||
|
||||
>If the location cannot be determined (for example, $HOME is not defined), then it will return an error.
|
||||
|
||||
{{% /expand %}}
|
||||
|
||||
See the rest of the documentation, titles included below, in this section to configure it.
|
||||
|
||||
{{% children description="true" %}}
|
99
docs/content/config/command-lists.md
Normal file
99
docs/content/config/command-lists.md
Normal file
@ -0,0 +1,99 @@
|
||||
---
|
||||
title: "Command Lists"
|
||||
weight: 2
|
||||
description: >
|
||||
This page tells you how to get use command lists.
|
||||
---
|
||||
|
||||
Command lists are for executing commands in sequence and getting notifications from them.
|
||||
|
||||
The top-level object key can be anything you want but not the same as another.
|
||||
|
||||
Lists can go in a separate file. Command lists should be in a separate file if:
|
||||
|
||||
1. key 'cmd-lists.file' is specified
|
||||
2. lists.yml or lists.yaml is found in the same directory as the backy config file
|
||||
|
||||
{{% notice info %}}
|
||||
The lists file is also checked in remote resources.
|
||||
|
||||
The lists file is ignored under the following condition:
|
||||
|
||||
If a remote config file is specified (on the command-line using `-f`) and the lists file is not found in the same directory, the lists file is assumed to not exist.
|
||||
{{% /notice %}}
|
||||
|
||||
```yaml {lineNos="true" wrap="true" title="yaml"}
|
||||
test2:
|
||||
name: test2
|
||||
order:
|
||||
- test
|
||||
- test2
|
||||
notifications:
|
||||
- mail.prod-email
|
||||
- matrix.sysadmin
|
||||
cron: "0 * * * * *"
|
||||
```
|
||||
|
||||
| key | description | type | required
|
||||
| --- | --- | --- | --- |
|
||||
| `order` | Defines the sequence of commands to execute | `[]string` | yes |
|
||||
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
|
||||
| `notifications` | The notification service(s) and ID(s) to use on success and failure. Must be *`service.id`*. See the [notifications documentation page](/config/notifications/) for more | `[]string` | no |
|
||||
| `name` | Optional name of the list | `string` | no |
|
||||
| `cron` | Time at which to schedule the list. Only has affect when cron subcommand is run. | `string` | no |
|
||||
|
||||
### Order
|
||||
|
||||
The order is an array of commands to execute in order. Each command must be defined.
|
||||
|
||||
```yaml
|
||||
order:
|
||||
- cmd-1
|
||||
- cmd-2
|
||||
```
|
||||
|
||||
### getOutput
|
||||
|
||||
Get command output when a notification is sent.
|
||||
|
||||
Is not required. Can be `true` or `false`. Default is `false`.
|
||||
|
||||
### Notifications
|
||||
|
||||
An array of notification IDs to use on success and failure. Must match any of the `notifications` object map keys.
|
||||
|
||||
### Name
|
||||
|
||||
Name is optional. If name is not defined, name will be the object's map key.
|
||||
|
||||
### Cron mode
|
||||
|
||||
Backy also has a cron mode, so one can run `backy cron` and start a process that schedules jobs to run at times defined in the configuration file.
|
||||
|
||||
Adding `cron: 0 0 1 * * *` to a `cmd-lists` object will schedule the list at 1 in the morning. See [https://crontab.guru/](https://crontab.guru/) for reference.
|
||||
|
||||
{{% notice tip %}}
|
||||
Note: Backy uses the second field of cron, so add anything except `*` to the beginning of a regular cron expression.
|
||||
{{% /notice %}}
|
||||
|
||||
```yaml {lineNos="true" wrap="true" title="yaml"}
|
||||
cmd-lists:
|
||||
docker-container-backup: # this can be any name you want
|
||||
# all commands have to be defined
|
||||
order:
|
||||
- stop-docker-container
|
||||
- backup-docker-container-script
|
||||
- shell-cmd
|
||||
- hostname
|
||||
- start-docker-container
|
||||
notifications:
|
||||
- matrix.id
|
||||
name: backup-some-container
|
||||
cron: "0 0 1 * * *"
|
||||
hostname:
|
||||
name: hostname
|
||||
order:
|
||||
- hostname
|
||||
notifications:
|
||||
- mail.prod-email
|
||||
```
|
152
docs/content/config/commands/_index.md
Normal file
152
docs/content/config/commands/_index.md
Normal file
@ -0,0 +1,152 @@
|
||||
---
|
||||
title: "Commands"
|
||||
description: Commands are just that, commands
|
||||
weight: 1
|
||||
---
|
||||
|
||||
|
||||
|
||||
### Example Config
|
||||
|
||||
```yaml
|
||||
commands:
|
||||
stop-docker-container:
|
||||
cmd: docker
|
||||
Args:
|
||||
- compose
|
||||
- -f /some/path/to/docker-compose.yaml
|
||||
- down
|
||||
# if host is not defined, command will be run locally
|
||||
# The host has to be defined in either the config file or the SSH Config files
|
||||
host: some-host
|
||||
hooks
|
||||
error:
|
||||
- some-other-command-when-failing
|
||||
success:
|
||||
- success-command
|
||||
final:
|
||||
- final-command
|
||||
backup-docker-container-script:
|
||||
cmd: /path/to/local/script
|
||||
# script file is input as stdin to SSH
|
||||
type: scriptFile # also can be script
|
||||
environment:
|
||||
- FOO=BAR
|
||||
- APP=$VAR
|
||||
```
|
||||
|
||||
Values available for this section **(case-sensitive)**:
|
||||
|
||||
| name | notes | type | required
|
||||
| --- | --- | --- | --- |
|
||||
| `cmd` | Defines the command to execute | `string` | yes |
|
||||
| `Args` | Defines the arguments to the command | `[]string` | no |
|
||||
| `environment` | Defines environment variables for the command | `[]string` | no |
|
||||
| `type` | See documentation further down the page. Additional fields may be required. | `string` | no |
|
||||
| `getOutput` | Command(s) output is in the notification(s) | `bool` | no |
|
||||
| `host` | If not specified, the command will execute locally. | `string` | no |
|
||||
| `scriptEnvFile` | When type is `scriptFile` or `script`, this file is prepended to the input. | `string` | no |
|
||||
| `shell` | Run the command in the shell | `string` | no |
|
||||
| `hooks` | Hooks are used at the end of the individual command. Must have at least `error`, `success`, or `final`. | `map[string][]string` | no |
|
||||
|
||||
#### cmd
|
||||
|
||||
cmd must be a valid command or script to execute.
|
||||
|
||||
#### Args
|
||||
|
||||
args must be arguments to cmd as they would be passed on the command-line:
|
||||
|
||||
```sh
|
||||
cmd [arg1 arg2 ...]
|
||||
```
|
||||
|
||||
Define them in an array:
|
||||
|
||||
```yaml
|
||||
Args:
|
||||
- arg1
|
||||
- arg2
|
||||
- arg3
|
||||
```
|
||||
|
||||
### getOutput
|
||||
|
||||
Get command output when a notification is sent.
|
||||
|
||||
Is not required. Can be `true` or `false`.
|
||||
|
||||
#### host
|
||||
|
||||
{{% notice info %}}
|
||||
If any `host` is not defined or left blank, the command will run on the local machine.
|
||||
{{% /notice %}}
|
||||
|
||||
Host may or may not be defined in the `hosts` section.
|
||||
|
||||
{{% notice info %}}
|
||||
If any `host` from the commands section does not match any object in the `hosts` section, the `Host` is assumed to be this value. This value will be used to search in the default SSH config files.
|
||||
|
||||
For example, say that I have a host defined in my SSH config with the `Host` defined as `web-prod`.
|
||||
If I assign a value to host as `host: web-prod` and don't specify this value in the `hosts` object, web-prod will be used as the `Host` in searching the SSH config files.
|
||||
{{% /notice %}}
|
||||
|
||||
### shell
|
||||
|
||||
If shell is defined, the command will run in the specified shell.
|
||||
Make sure to escape any shell input.
|
||||
|
||||
### scriptEnvFile
|
||||
|
||||
Path to a file.
|
||||
|
||||
When type is `script` or `scriptFile` , the script is appended to this file.
|
||||
|
||||
This is useful for specifying environment variables or other things so they don't have to be included in the script.
|
||||
|
||||
### type
|
||||
|
||||
The following options are available:
|
||||
|
||||
| name | description |
|
||||
| --- | --- |
|
||||
| script | `cmd` is used as the script |
|
||||
| scriptFile | Can only be run on a host. `cmd` is read and used as the script, and `scriptEnvFile` can be used to add env variables |
|
||||
| package | Run package operations. See [dedicated page](/config/packages) for configuring package commands |
|
||||
| user | Run user operations. See [dedicated page](/config/user-commands) for configuring package commands |
|
||||
|
||||
### environment
|
||||
|
||||
The environment variables support expansion:
|
||||
|
||||
- using escaped values `$VAR` or `${VAR}`
|
||||
|
||||
For now, the variables have to be defined in an `.env` file in the same directory that the program is run from.
|
||||
|
||||
If using it with host specified, the SSH server has to be configured to accept those env variables.
|
||||
|
||||
If the command is run locally, the OS's environment is added.
|
||||
|
||||
### hooks
|
||||
|
||||
Hooks are run after the command is run.
|
||||
|
||||
Errors are run if the command errors, success if it returns no error. Final hooks are run regardless of error condition.
|
||||
|
||||
Values for hooks are as follows:
|
||||
|
||||
```yaml
|
||||
command:
|
||||
hook:
|
||||
# these commands are defined elsewhere in the file
|
||||
error:
|
||||
- errcommand
|
||||
success:
|
||||
- successcommand
|
||||
final:
|
||||
- donecommand
|
||||
```
|
||||
|
||||
### packages
|
||||
|
||||
See the [dedicated page](/config/packages) for package configuration.
|
79
docs/content/config/commands/packages.md
Normal file
79
docs/content/config/commands/packages.md
Normal file
@ -0,0 +1,79 @@
|
||||
---
|
||||
title: "Packages"
|
||||
weight: 2
|
||||
description: This is dedicated to package commands.
|
||||
---
|
||||
|
||||
This is dedicated to `package` commands. The command `type` field must be `package`. Package is a type that allows one to perform package operations. There are several additional options available when `type` is `package`:
|
||||
|
||||
| name | notes | type | required |
|
||||
| --- | --- | --- | --- |
|
||||
| `packageName` | The name of a package to be modified. | `string` | yes |
|
||||
| `packageManager` | The name of the package manger to be used. | `string` | yes |
|
||||
| `packageOperation` | The type of operation to perform. | `string` | yes |
|
||||
| `packageVersion` | The version of a package. | `string` | no |
|
||||
|
||||
|
||||
#### example
|
||||
|
||||
The following is an example of a package command:
|
||||
|
||||
```yaml
|
||||
update-docker:
|
||||
type: package
|
||||
shell: zsh
|
||||
packageName: docker-ce
|
||||
packageManager: apt
|
||||
packageOperation: install
|
||||
host: debian-based-host
|
||||
```
|
||||
|
||||
#### packageOperation
|
||||
|
||||
The following package operations are supported:
|
||||
|
||||
- `install`
|
||||
- `remove`
|
||||
- `upgrade`
|
||||
- `checkVersion`
|
||||
|
||||
#### packageManager
|
||||
|
||||
The following package managers are recognized:
|
||||
|
||||
- `apt`
|
||||
- `yum`
|
||||
- `dnf`
|
||||
|
||||
#### package command args
|
||||
|
||||
You can add additional arguments using the standard `Args` key. This is useful for adding more packages, yet it does not work with `checkVersion`.
|
||||
|
||||
### Development
|
||||
|
||||
The PackageManager interface provides an easy way to enforce functions and options. There are two interfaces, `PackageManager` and `ConfigurablePackageManager` in the directory `pkg/pkgman`. Go's import-cycle "feature" caused me to implement functional options using a third interface. `PackageManagerOption`is a function that takes an interface.
|
||||
|
||||
#### PackageManager
|
||||
|
||||
```go
|
||||
// PackageManager is an interface used to define common package commands. This shall be implemented by every package.
|
||||
type PackageManager interface {
|
||||
Install(pkg, version string, args []string) (string, []string)
|
||||
Remove(pkg string, args []string) (string, []string)
|
||||
Upgrade(pkg, version string) (string, []string) // Upgrade a specific package
|
||||
UpgradeAll() (string, []string)
|
||||
|
||||
// Configure applies functional options to customize the package manager.
|
||||
Configure(options ...pkgcommon.PackageManagerOption)
|
||||
}
|
||||
```
|
||||
|
||||
There are a few functional options that should be implemented using the `ConfigurablePackageManager` interface:
|
||||
|
||||
```go
|
||||
// ConfigurablePackageManager defines methods for setting configuration options.
|
||||
type ConfigurablePackageManager interface {
|
||||
SetUseAuth(useAuth bool)
|
||||
SetAuthCommand(authCommand string)
|
||||
}
|
||||
```
|
62
docs/content/config/commands/user-commands.md
Normal file
62
docs/content/config/commands/user-commands.md
Normal file
@ -0,0 +1,62 @@
|
||||
---
|
||||
title: "User commands"
|
||||
weight: 2
|
||||
description: This is dedicated to user commands.
|
||||
---
|
||||
|
||||
This is dedicated to `user` commands. The command `type` field must be `user`. User is a type that allows one to perform user operations. There are several additional options available when `type` is `user`:
|
||||
|
||||
| name | notes | type | required |
|
||||
| --- | --- | --- | --- |
|
||||
| `userName` | The name of a user to be configured. | `string` | yes |
|
||||
| `userOperation` | The type of operation to perform. | `string` | yes |
|
||||
| `userID` | The user ID to use. | `string` | yes |
|
||||
| `userGroups` | The groups the user should be added to. | `[]string` | yes |
|
||||
| `userShell` | The shell for the user. | `string` | yes |
|
||||
| `userHome` | The user's home directory. | `string` | no |
|
||||
|
||||
|
||||
#### example
|
||||
|
||||
The following is an example of a package command:
|
||||
|
||||
```yaml
|
||||
addUser:
|
||||
name: add user backy with custom home dir
|
||||
type: user
|
||||
userName: backy
|
||||
userHome: /opt/backy
|
||||
userOperation: add
|
||||
host: some-host
|
||||
```
|
||||
|
||||
#### userOperation
|
||||
|
||||
The following package operations are supported:
|
||||
|
||||
- `add`
|
||||
- `remove`
|
||||
- `modify`
|
||||
- `password`
|
||||
- `checkIfExists`
|
||||
|
||||
### Development
|
||||
|
||||
The UserManager interface provides an way easy to add new commands. There is one interface `Usermanager` in directory `pkg/usermanager`.
|
||||
|
||||
#### UserManager
|
||||
|
||||
```go
|
||||
// UserManager defines the interface for user management operations.
|
||||
// All functions but one return a string for the command and any args.
|
||||
type UserManager interface {
|
||||
AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string)
|
||||
RemoveUser(username string) (string, []string)
|
||||
ModifyUser(username, homeDir, shell string, groups []string) (string, []string)
|
||||
// Modify password uses chpasswd for Linux systems to build the command to change the password
|
||||
// Should return a password as the last argument
|
||||
// TODO: refactor when adding more systems instead of Linux
|
||||
ModifyPassword(username, password string) (string, *strings.Reader, string)
|
||||
UserExists(username string) (string, []string)
|
||||
}
|
||||
```
|
24
docs/content/config/hosts.md
Normal file
24
docs/content/config/hosts.md
Normal file
@ -0,0 +1,24 @@
|
||||
---
|
||||
title: "Hosts"
|
||||
weight: 2
|
||||
description: >
|
||||
This page tells you how to use hosts.
|
||||
---
|
||||
|
||||
| Key | Description | Type | Required |
|
||||
|----------------------|---------------------------------------------------------------|----------|----------|
|
||||
| `OS` | Operating system of the host (used for package commands) | `string` | no |
|
||||
| `config` | Path to the SSH config file | `string` | no |
|
||||
| `host` | Specifies the `Host` ssh_config(5) directive | `string` | yes |
|
||||
| `hostname` | Hostname of the host | `string` | no |
|
||||
| `knownhostsfile` | Path to the known hosts file | `string` | no |
|
||||
| `port` | Port number to connect to | `uint16` | no |
|
||||
| `proxyjump` | Proxy jump hosts, comma-separated | `string` | no |
|
||||
| `password` | Password for SSH authentication | `string` | no |
|
||||
| `privatekeypath` | Path to the private key file | `string` | no |
|
||||
| `privatekeypassword` | Password for the private key file | `string` | no |
|
||||
| `user` | Username for SSH authentication | `string` | no |
|
||||
|
||||
## exec host subcommand
|
||||
|
||||
Backy has a subcommand `exec host`. This subcommand takes the flags of `-m host1 -m host2`. For now these hosts need to be defined in the config file.
|
75
docs/content/config/notifications.md
Normal file
75
docs/content/config/notifications.md
Normal file
@ -0,0 +1,75 @@
|
||||
---
|
||||
title: "Notifications"
|
||||
weight: 3
|
||||
description: >
|
||||
This page tells you how to get set up Backy notifications.
|
||||
---
|
||||
|
||||
Notifications are only configurable for command lists, as of right now.
|
||||
|
||||
Notifications can be sent on command list completion and failure.
|
||||
|
||||
The supported platforms for notifications are email (SMTP) and [Matrix](https://matrix.org/).
|
||||
|
||||
Notifications are defined by service, with the current form following below. Ids must come after the service.
|
||||
|
||||
```yaml
|
||||
notifications:
|
||||
mail:
|
||||
prod-email:
|
||||
host: yourhost.tld
|
||||
port: 587
|
||||
senderaddress: email@domain.tld
|
||||
to:
|
||||
- admin@domain.tld
|
||||
username: smtp-username@domain.tld
|
||||
password: your-password-here
|
||||
|
||||
matrix:
|
||||
matrix:
|
||||
home-server: your-home-server.tld
|
||||
room-id: room-id
|
||||
access-token: your-access-token
|
||||
user-id: your-user-id
|
||||
```
|
||||
|
||||
Sections recognized are `mail` and `matrix`
|
||||
|
||||
There must be a section with an id (eg. `mail.test-svr`) following one of these sections.
|
||||
|
||||
### mail
|
||||
|
||||
| key | description | type
|
||||
| --- | --- | ---
|
||||
| `host` | Specifies the SMTP host to connect to | `string`
|
||||
| `port` | Specifies the SMTP port | `uint16`
|
||||
| `senderaddress` | Address from which to send mail | `string`
|
||||
| `to` | Recipients to send emails to | `[]string`
|
||||
| `username` | SMTP username | `string`
|
||||
| `password` | SMTP password | `string`
|
||||
|
||||
### matrix
|
||||
|
||||
| key | description | type
|
||||
| --- | --- | ---
|
||||
| `home-server` | Specifies the Matrix server connect to | `string`
|
||||
| `room-id` | Specifies the room ID of the room to send messages to | `string`
|
||||
| `access-token` | Matrix access token | `string`
|
||||
| `user-id` | Matrix user ID | `string`
|
||||
|
||||
To get your access token (assumes you are using [Element](https://element.io/)) :
|
||||
|
||||
1. Log in to the account you want to get the access token for. Click on the name in the top left corner, then "Settings".
|
||||
2. Click the "Help & About" tab (left side of the dialog).
|
||||
3. Scroll to the bottom and click on `<click to reveal>` part of Access Token.
|
||||
4. Copy your access token to a safe place.
|
||||
|
||||
To get the room ID:
|
||||
|
||||
1. On Element or a similar client, navigate to the room.
|
||||
2. Navigate to the settings from the top menu.
|
||||
3. Click on Advanced, the room ID is there.
|
||||
|
||||
{{% notice info %}}
|
||||
Make sure to quote the room ID, as [YAML spec defines tags using `!`](https://yaml.org/spec/1.2.2/#3212-tags).
|
||||
{{% /notice %}}
|
17
docs/content/config/remote-resources.md
Normal file
17
docs/content/config/remote-resources.md
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
title: "Remote resources"
|
||||
weight: 2
|
||||
description: This is dedicated to configuring remote resources.
|
||||
---
|
||||
|
||||
Remote resources can be used for a lot of things, including config files and scripts.
|
||||
|
||||
## Config file
|
||||
|
||||
For the main config file to be fetched remotely, pass the URL using `-f [url]`.
|
||||
|
||||
If using S3, you should use the s3 protocol URI: `s3://bucketName/key/path`. You will also need to set the env variable `S3_ENDPOINT` to the appropriate value. The flag `--s3-endpoint` can be used to override this value or to set this value, if not already set.
|
||||
|
||||
## Scripts
|
||||
|
||||
Scripts will be coming later.
|
27
docs/content/config/vault.md
Normal file
27
docs/content/config/vault.md
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
title: "Vault"
|
||||
weight: 4
|
||||
description: Set up and configure vault.
|
||||
---
|
||||
|
||||
[Vault](https://www.vaultproject.io/) is a tool for storing secrets and other data securely.
|
||||
|
||||
Vault config can be used by prefixing `vault:` in front of a password or ENV var.
|
||||
|
||||
This is the object in the config file:
|
||||
|
||||
```yaml
|
||||
vault:
|
||||
token: hvs.tXqcASvTP8wg92f7riyvGyuf
|
||||
address: http://127.0.0.1:8200
|
||||
enabled: false
|
||||
keys:
|
||||
- name: mongourl
|
||||
mountpath: secret
|
||||
path: mongo/url
|
||||
type: # KVv1 or KVv2
|
||||
- name:
|
||||
path:
|
||||
type:
|
||||
mountpath:
|
||||
```
|
10
docs/content/getting-started/_index.md
Normal file
10
docs/content/getting-started/_index.md
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
title: "Getting started"
|
||||
weight: 2
|
||||
description: >
|
||||
This page tells you how to get started with Backy.
|
||||
---
|
||||
|
||||
If you have not installed Backy, [see the install documentation](install).
|
||||
|
||||
If you need to configure it, [see the config page](config).
|
161
docs/content/getting-started/config.md
Normal file
161
docs/content/getting-started/config.md
Normal file
@ -0,0 +1,161 @@
|
||||
---
|
||||
title: "Config File Definitions"
|
||||
description: >
|
||||
This page tells you how to configure Backy.
|
||||
---
|
||||
|
||||
### Commands
|
||||
|
||||
The commands section is for defining commands. These can be run with or without a shell and on a host or locally.
|
||||
|
||||
See the [commands documentation](/config/commands) for further information.
|
||||
|
||||
```yaml
|
||||
commands:
|
||||
stop-docker-container:
|
||||
output: true # Optional and only when run in list and notifications are sent
|
||||
cmd: docker
|
||||
args:
|
||||
- compose
|
||||
- -f /some/path/to/docker-compose.yaml
|
||||
- down
|
||||
# if host is not defined, cmd will be run locally
|
||||
host: some-host
|
||||
backup-docker-container-script:
|
||||
cmd: /path/to/script
|
||||
# The host has to be defined in the config file
|
||||
host: some-host
|
||||
environment:
|
||||
- FOO=BAR
|
||||
- APP=$VAR # defined in .env file in config directory
|
||||
shell-cmd:
|
||||
cmd: rsync
|
||||
shell: bash
|
||||
args:
|
||||
- -av
|
||||
- some-host:/path/to/data
|
||||
- ~/Docker/Backups/docker-data
|
||||
script:
|
||||
type: scriptFile # run a local script on a remote host
|
||||
cmd: path/to/your/script.sh
|
||||
host: some-host
|
||||
hostname:
|
||||
cmd: hostname
|
||||
```
|
||||
|
||||
### Lists
|
||||
|
||||
To execute groups of commands in sequence, use a list configuration.
|
||||
|
||||
```yaml
|
||||
cmd-lists:
|
||||
cmds-to-run: # this can be any name you want
|
||||
# all commands have to be defined in the commands section
|
||||
order:
|
||||
- stop-docker-container
|
||||
- backup-docker-container-script
|
||||
- shell-cmd
|
||||
- hostname
|
||||
getOutput: true # Optional and only for when notifications are sent
|
||||
notifications:
|
||||
- matrix
|
||||
name: backup-some-server
|
||||
hostname:
|
||||
name: hostname
|
||||
order:
|
||||
- hostname
|
||||
notifications:
|
||||
- prod-email
|
||||
```
|
||||
|
||||
### Hosts
|
||||
|
||||
The hosts object may or may not be defined.
|
||||
|
||||
{{% notice info %}}
|
||||
If any `host` from a commands object does not match any `host` object, the needed values will be checked in the default SSH config files.
|
||||
{{% /notice %}}
|
||||
|
||||
```yaml
|
||||
hosts:
|
||||
# any needed ssh_config(5) keys/values not listed here will be looked up in the config file or the default config file
|
||||
some-host:
|
||||
hostname: some-hostname
|
||||
config: ~/.ssh/config
|
||||
user: user
|
||||
privatekeypath: /path/to/private/key
|
||||
port: 22
|
||||
# can also be env:VAR or the password itself
|
||||
password: file:/path/to/file
|
||||
# can also be env:VAR or the password itself
|
||||
privatekeypassword: file:/path/to/file
|
||||
# only one is supported for now
|
||||
proxyjump: some-proxy-host
|
||||
```
|
||||
|
||||
### Notifications
|
||||
|
||||
The notifications object can have two forms.
|
||||
|
||||
For more, [see the notification object documentation](/config/notifications). The top-level map key is id that has to be referenced by the `cmd-lists` key `notifications`.
|
||||
|
||||
```yaml
|
||||
notifications:
|
||||
mail:
|
||||
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:
|
||||
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
|
||||
```
|
||||
|
||||
### Logging
|
||||
|
||||
cmd-std-out controls whether commands output is echoed to StdOut.
|
||||
|
||||
If logfile is not defined, the log file will be written to the config directory in the file `backy.log`.
|
||||
|
||||
`console-disabled` controls whether the logging messages are echoed to StdOut. Default is false.
|
||||
|
||||
`verbose` basically does nothing as all necessary info is already output.
|
||||
|
||||
```yaml
|
||||
logging:
|
||||
verbose: false
|
||||
file: path/to/log/file.log
|
||||
console-disabled: false
|
||||
cmd-std-out: false
|
||||
```
|
||||
|
||||
### Vault
|
||||
|
||||
[Vault](https://www.vaultproject.io/) can be used to get some configuration values and ENV variables securely.
|
||||
|
||||
```
|
||||
vault:
|
||||
token: hvs.tXqcASvTP8wg92f7riyvGyuf
|
||||
address: http://127.0.0.1:8200
|
||||
enabled: false
|
||||
keys:
|
||||
- name: mongourl
|
||||
mountpath: secret
|
||||
path: mongo/url
|
||||
type: # KVv1 or KVv2
|
||||
- name:
|
||||
path:
|
||||
type:
|
||||
mountpath:
|
||||
```
|
21
docs/content/getting-started/install.md
Normal file
21
docs/content/getting-started/install.md
Normal file
@ -0,0 +1,21 @@
|
||||
---
|
||||
title: "Install Backy"
|
||||
weight: 1
|
||||
description: >
|
||||
This page tells you how to install Backy.
|
||||
---
|
||||
|
||||
|
||||
Binaries are available from the [release page](https://git.andrewnw.xyz/CyberShell/backy/releases). Make sure to get the correct version for your system, which supports x86_64, ARM64, and i386.
|
||||
|
||||
### Source Install
|
||||
|
||||
You can install from source. You will need [Go installed](https://go.dev/doc/install).
|
||||
|
||||
Then run:
|
||||
|
||||
```bash
|
||||
go install git.andrewnw.xyz/CyberShell/backy@master
|
||||
```
|
||||
|
||||
Once set, jump over to the [config docs](/getting-started/config) and start configuring your file.
|
9
docs/content/repositories/_index.md
Normal file
9
docs/content/repositories/_index.md
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
title: "Repositories"
|
||||
weight: 5
|
||||
---
|
||||
|
||||
The repo mirrors are:
|
||||
|
||||
* [https://git.andrewnw.xyz/CyberShell/backy](https://git.andrewnw.xyz/CyberShell/backy)
|
||||
* [https://github.com/CybersShell/backy](https://github.com/CybersShell/backy)
|
8
docs/go.mod
Normal file
8
docs/go.mod
Normal file
@ -0,0 +1,8 @@
|
||||
module git.andrewnw.xyz/CyberShell/backy/docs
|
||||
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa // indirect
|
||||
github.com/divinerites/plausible-hugo v1.21.1 // indirect
|
||||
)
|
10
docs/go.sum
Normal file
10
docs/go.sum
Normal file
@ -0,0 +1,10 @@
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20230209073138-890d12ea922d h1:weq1mrQ/qNAvGrNgvZVL1K8adbT3bswZf2ABLr/LCIA=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20230209073138-890d12ea922d/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20241210183303-16d4de84becf h1:bMx4kwM7Q+dAzvSOWs3XWZ25o+n4mI0GPHqzbzeWb3M=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20241210183303-16d4de84becf/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20250102210630-dd0597ffa4b2 h1:sWaC1/dL65v3iRvblEAaBLpKC5TIT0R9JASk1hZNET8=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20250102210630-dd0597ffa4b2/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa h1:G+OnMEzK4XOzbbcf1SmaGyOYJ0h5idp/IJdguWs8ioU=
|
||||
github.com/McShelby/hugo-theme-relearn v0.0.0-20250103114405-80e448e5bdaa/go.mod h1:mKQQdxZNIlLvAj8X3tMq+RzntIJSr9z7XdzuMomt0IM=
|
||||
github.com/divinerites/plausible-hugo v1.21.1 h1:ZTWwjhZ0PmLMacCVGlcGiYFEZW7VaYE767tchDskOug=
|
||||
github.com/divinerites/plausible-hugo v1.21.1/go.mod h1:cxr+YB3FUwbLon8KCs4pV4Ankbkq6lJxTQUpNb5KqPo=
|
84
docs/layouts/_default/baseof.html
Normal file
84
docs/layouts/_default/baseof.html
Normal file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
{{- block "storeOutputFormat" . }}{{ end }}
|
||||
{{- if .IsHome }}
|
||||
{{- $hugoVersion := "0.126.0" }}
|
||||
{{- if lt hugo.Version $hugoVersion }}
|
||||
{{- errorf "The Relearn theme requires Hugo %s or later" $hugoVersion }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if .Site.Params.description }}
|
||||
{{- warnf "UNSUPPORTED usage of 'params.description' config parameter found, move it to the front matter of your home page; see https://mcshelby.github.io/hugo-theme-relearn/introduction/releasenotes/6/#6-0-0" }}
|
||||
{{- end }}
|
||||
<html lang="{{ .Page.Language.LanguageCode }}" dir="{{ .Page.Language.LanguageDirection | default (T "Reading-direction") | default "ltr" }}" itemscope itemtype="http://schema.org/Article" data-r-output-format="{{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}">
|
||||
<head>
|
||||
{{ partial "plausible_head.html" . }}
|
||||
{{- partial "meta.html" . }}
|
||||
{{- $title := partial "title.gotmpl" (dict "page" . "fullyQualified" true "reverse" true) }}
|
||||
<title>{{ $title }}</title>
|
||||
|
||||
{{- /* multilingual stuff */}}
|
||||
{{- if .IsTranslated -}}
|
||||
{{- range $index, $trans := .AllTranslations }}
|
||||
{{- if eq $index 0 }}
|
||||
<link href="{{ partial "permalink.gotmpl" (dict "to" . "abs" true) }}" rel="alternate" hreflang="x-default">
|
||||
{{- end }}
|
||||
<link href="{{ partial "permalink.gotmpl" (dict "to" . "abs" true) }}" rel="alternate" hreflang="{{ .Language.LanguageCode }}">
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{- /* output formats */}}
|
||||
{{- $page := . }}
|
||||
{{- $link := "<link href=\"%s\" rel=\"%s\" type=\"%s\" title=\"%s\">" }}
|
||||
{{- range .AlternativeOutputFormats }}
|
||||
{{- if eq .Rel "canonical" }}
|
||||
{{ (printf $link (partial "permalink.gotmpl" (dict "to" . "abs" true)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||
{{- else if not (partial "_relearn/pageIsSpecial.gotmpl" $page) }}
|
||||
{{ (printf $link (partial "permalink.gotmpl" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- partialCached "favicon.html" . }}
|
||||
{{- partial "stylesheet.html" . }}
|
||||
{{- partial "dependencies.gotmpl" (dict "page" . "location" "header") }}
|
||||
{{- partial "custom-header.html" . }}
|
||||
</head>
|
||||
<body class="mobile-support {{ with .Store.Get "relearnOutputFormat" }}{{ . }}{{ else }}html{{ end }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}{{- if .Site.Params.disableHoverBlockCopyToClipBoard }} disableHoverBlockCopyToClipBoard{{ end }}" data-url="{{ partial "permalink.gotmpl" (dict "to" .) }}">
|
||||
<div id="R-body" class="default-animation">
|
||||
<div id="R-body-overlay"></div>
|
||||
<nav id="R-topbar">
|
||||
<div class="topbar-wrapper">
|
||||
<div class="topbar-sidebar-divider"></div>
|
||||
<div class="topbar-area topbar-area-start" data-area="start">
|
||||
{{- partial "topbar/area/start.html" . }}
|
||||
</div>
|
||||
{{- $showBreadcrumb := (and (not .Params.disableBreadcrumb) (not .Site.Params.disableBreadcrumb)) }}
|
||||
{{- if $showBreadcrumb }}
|
||||
<ol class="topbar-breadcrumbs breadcrumbs highlightable" itemscope itemtype="http://schema.org/BreadcrumbList">
|
||||
{{- partial "breadcrumbs.html" (dict "page" .) }}
|
||||
</ol>
|
||||
{{- else }}
|
||||
<span class="topbar-breadcrumbs highlightable">
|
||||
{{ partial "title.gotmpl" (dict "page" . "linkTitle" true) }}
|
||||
</span>
|
||||
{{- end }}
|
||||
<div class="topbar-area topbar-area-end" data-area="end">
|
||||
{{- partial "topbar/area/end.html" . }}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
<div id="R-main-overlay"></div>
|
||||
<main id="R-body-inner" class="highlightable{{ with or .Type "default" }} {{ . }}{{ end }}" tabindex="-1">
|
||||
<div class="flex-block-wrapper">
|
||||
{{- block "body" . }}{{ end }}
|
||||
</div>
|
||||
</main>
|
||||
{{- partial "custom-comments.html" . }}
|
||||
</div>
|
||||
{{- block "menu" . }}{{ end }}
|
||||
{{- $assetBusting := partialCached "assetbusting.gotmpl" . }}
|
||||
<script src="{{"js/clipboard.min.js" | relURL}}{{ $assetBusting }}" defer></script>
|
||||
<script src="{{"js/perfect-scrollbar.min.js" | relURL}}{{ $assetBusting }}" defer></script>
|
||||
{{- partial "dependencies.gotmpl" (dict "page" . "location" "footer") }}
|
||||
<script src="{{"js/theme.js" | relURL}}{{ $assetBusting }}" defer></script>
|
||||
{{- partial "custom-footer.html" . }}
|
||||
</body>
|
||||
</html>
|
46
docs/layouts/partials/logo.html
Normal file
46
docs/layouts/partials/logo.html
Normal file
File diff suppressed because one or more lines are too long
1
docs/themes/hugo-theme-relearn
vendored
Submodule
1
docs/themes/hugo-theme-relearn
vendored
Submodule
Submodule docs/themes/hugo-theme-relearn added at 80e448e5bd
1
docs/themes/plausible-hugo
vendored
Submodule
1
docs/themes/plausible-hugo
vendored
Submodule
Submodule docs/themes/plausible-hugo added at 25d00b53c8
20
docs/vangen.json
Normal file
20
docs/vangen.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"domain": "go.cybershell.xyz",
|
||||
"docsDomain": "pkg.go.dev",
|
||||
"repositories": [
|
||||
{
|
||||
"prefix": "backy",
|
||||
"type": "git",
|
||||
"hidden": false,
|
||||
"url": "https://git.andrewnw.xyz/CyberShell/backy",
|
||||
"source": {
|
||||
"home": "https://git.andrewnw.xyz/CyberShell/backy",
|
||||
"dir": "https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/{/dir}",
|
||||
"file": "https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/{/dir}/{file}#L{line}"
|
||||
},
|
||||
"website": {
|
||||
"url": "https://backy.cybershell.xyz/"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
25
docs/vangen/backy/index.html
Normal file
25
docs/vangen/backy/index.html
Normal file
@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>go.cybershell.xyz/backy</title>
|
||||
<meta name="go-import" content="go.cybershell.xyz/backy git https://git.andrewnw.xyz/CyberShell/backy">
|
||||
<meta name="go-source" content="go.cybershell.xyz/backy https://git.andrewnw.xyz/CyberShell/backy https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/{/dir} https://git.andrewnw.xyz/CyberShell/backy/src/branch/master/{/dir}/{file}#L{line}">
|
||||
<style>
|
||||
* { font-family: sans-serif; }
|
||||
body { margin-top: 0; }
|
||||
.content { display: inline-block; }
|
||||
code { display: block; font-family: monospace; font-size: 1em; background-color: #d5d5d5; padding: 1em; margin-bottom: 16px; }
|
||||
ul { margin-top: 16px; margin-bottom: 16px; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
<h2>go.cybershell.xyz/backy</h2>
|
||||
<code>go get go.cybershell.xyz/backy</code>
|
||||
<code>import "go.cybershell.xyz/backy"</code>
|
||||
Home: <a href="https://backy.cybershell.xyz/">https://backy.cybershell.xyz/</a><br/>
|
||||
Source: <a href="https://git.andrewnw.xyz/CyberShell/backy">https://git.andrewnw.xyz/CyberShell/backy</a><br/>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
108
examples/backy.yaml
Normal file
108
examples/backy.yaml
Normal file
@ -0,0 +1,108 @@
|
||||
commands:
|
||||
stop-docker-container:
|
||||
cmd: docker
|
||||
Args:
|
||||
- compose
|
||||
- -f /some/path/to/docker-compose.yaml
|
||||
- down
|
||||
# if host is not defined, cmd will be run locally
|
||||
host: some-host
|
||||
hooks:
|
||||
final:
|
||||
- hostname
|
||||
error:
|
||||
- hostname
|
||||
backup-docker-container-script:
|
||||
cmd: /path/to/script
|
||||
# The host has to be defined in the config file
|
||||
host: some-host
|
||||
environment:
|
||||
- FOO=BAR
|
||||
- APP=$VAR
|
||||
shell-cmd:
|
||||
cmd: rsync
|
||||
shell: bash
|
||||
Args:
|
||||
- -av some-host:/path/to/data ~/Docker/Backups/docker-data
|
||||
hostname:
|
||||
cmd: hostname
|
||||
update-docker:
|
||||
type: package
|
||||
shell: zsh # best to run package commands in a shell
|
||||
packageName: docker-ce
|
||||
Args:
|
||||
- docker-ce-cli
|
||||
packageManager: apt
|
||||
packageOperation: install
|
||||
update-dockerApt:
|
||||
# type: package
|
||||
shell: zsh
|
||||
cmd: apt
|
||||
Args:
|
||||
- update
|
||||
- "&&"
|
||||
- apt install -y docker-ce
|
||||
- docker-ce-cli
|
||||
packageManager: apt
|
||||
packageOperation: install
|
||||
|
||||
cmd-lists:
|
||||
cmds-to-run: # this can be any name you want
|
||||
# all commands have to be defined
|
||||
order:
|
||||
- stop-docker-container
|
||||
- backup-docker-container-script
|
||||
- shell-cmd
|
||||
- hostname
|
||||
notifications:
|
||||
- matrix.matrix
|
||||
name: backup-some-server
|
||||
cron: "0 0 1 * * *"
|
||||
hostname:
|
||||
name: hostname
|
||||
order:
|
||||
- hostname
|
||||
notifications:
|
||||
- mail.prod-email
|
||||
|
||||
hosts:
|
||||
# any ssh_config(5) keys/values not listed here will be looked up in the config file or the default config file
|
||||
some-host:
|
||||
hostname: some-hostname
|
||||
config: ~/.ssh/config
|
||||
user: user
|
||||
privatekeypath: /path/to/private/key
|
||||
port: 22
|
||||
# can also be env:VAR
|
||||
password: file:/path/to/file
|
||||
# only one is supported for now
|
||||
proxyjump: some-proxy-host
|
||||
|
||||
# optional
|
||||
logging:
|
||||
verbose: true
|
||||
file: ./backy.log
|
||||
console: false
|
||||
cmd-std-out: false
|
||||
|
||||
|
||||
notifications:
|
||||
mail:
|
||||
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:
|
||||
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
|
67
frontmatter.json
Normal file
67
frontmatter.json
Normal file
@ -0,0 +1,67 @@
|
||||
{
|
||||
"$schema": "https://frontmatter.codes/frontmatter.schema.json",
|
||||
"frontMatter.taxonomy.contentTypes": [
|
||||
{
|
||||
"name": "default",
|
||||
"pageBundle": false,
|
||||
"previewPath": null,
|
||||
"fields": [
|
||||
{
|
||||
"title": "Title",
|
||||
"name": "title",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"title": "Description",
|
||||
"name": "description",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"title": "Publishing date",
|
||||
"name": "date",
|
||||
"type": "datetime",
|
||||
"default": "{{now}}",
|
||||
"isPublishDate": true
|
||||
},
|
||||
{
|
||||
"title": "Content preview",
|
||||
"name": "preview",
|
||||
"type": "image"
|
||||
},
|
||||
{
|
||||
"title": "Is in draft",
|
||||
"name": "draft",
|
||||
"type": "draft"
|
||||
},
|
||||
{
|
||||
"title": "Tags",
|
||||
"name": "tags",
|
||||
"type": "tags"
|
||||
},
|
||||
{
|
||||
"title": "Categories",
|
||||
"name": "categories",
|
||||
"type": "categories"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"frontMatter.framework.id": "hugo",
|
||||
"frontMatter.content.publicFolder": "static",
|
||||
"frontMatter.content.pageFolders": [
|
||||
{
|
||||
"title": "content",
|
||||
"path": "[[workspace]]/docs/content",
|
||||
"originalPath": "[[workspace]]/docs/content"
|
||||
},
|
||||
{
|
||||
"title": "config-main",
|
||||
"path": "[[workspace]]/docs/content/config",
|
||||
"originalPath": "[[workspace]]/docs/content/config"
|
||||
},
|
||||
{
|
||||
"title": "gs",
|
||||
"path": "[[workspace]]/docs/content/getting-started"
|
||||
}
|
||||
]
|
||||
}
|
67
getCommandHelp
Executable file
67
getCommandHelp
Executable file
@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
CLI_PAGE="docs/content/cli/_index.md"
|
||||
echo "---
|
||||
title: "CLI"
|
||||
weight: 4
|
||||
---
|
||||
|
||||
This page lists documentation for the CLI.
|
||||
" > _index.md
|
||||
|
||||
BACKYCOMMAND="go run backy.go"
|
||||
|
||||
echo "## Backy " >> _index.md
|
||||
echo " " >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo " " >> _index.md
|
||||
|
||||
|
||||
echo "# Subcommands" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
echo "## backup" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} backup -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
echo "## cron" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} cron -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
echo "## exec" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} exec -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
echo "### exec host" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} exec host -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
|
||||
echo "## version" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} version -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
echo "" >> _index.md
|
||||
|
||||
echo "## list" >> _index.md
|
||||
echo "" >> _index.md
|
||||
echo "\`\`\`" >> _index.md
|
||||
eval "${BACKYCOMMAND} list -h >> _index.md"
|
||||
echo "\`\`\`" >> _index.md
|
||||
|
||||
|
||||
mv _index.md "$CLI_PAGE"
|
101
go.mod
101
go.mod
@ -1,32 +1,95 @@
|
||||
module git.andrewnw.xyz/CyberShell/backy
|
||||
|
||||
// module git.andrewnw.xyz/CyberShell/command
|
||||
go 1.23
|
||||
|
||||
go 1.19
|
||||
toolchain go1.23.1
|
||||
|
||||
replace git.andrewnw.xyz/CyberShell/backy => /home/andrew/Projects/backy
|
||||
|
||||
require (
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.76.0
|
||||
github.com/go-co-op/gocron v1.37.0
|
||||
github.com/hashicorp/vault/api v1.15.0
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/kevinburke/ssh_config v1.2.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.14.0
|
||||
golang.org/x/crypto v0.4.0
|
||||
github.com/knadh/koanf/parsers/yaml v0.1.0
|
||||
github.com/knadh/koanf/providers/rawbytes v0.1.0
|
||||
github.com/knadh/koanf/v2 v2.1.2
|
||||
github.com/mattn/go-isatty v0.0.20
|
||||
github.com/minio/minio-go/v7 v7.0.84
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/nikoksr/notify v1.3.0
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rs/zerolog v1.33.0
|
||||
github.com/sethvargo/go-password v0.3.1
|
||||
github.com/spf13/cobra v1.8.1
|
||||
golang.org/x/crypto v0.33.0
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
maunium.net/go/mautrix v0.23.0
|
||||
mvdan.cc/sh/v3 v3.10.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/fsnotify/fsnotify v1.6.0 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.1 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.32 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.32 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.32 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.6 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.13 // indirect
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.13 // indirect
|
||||
github.com/aws/smithy-go v1.22.2 // indirect
|
||||
github.com/cenkalti/backoff/v3 v3.2.2 // indirect
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/go-ini/ini v1.67.0 // indirect
|
||||
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
|
||||
github.com/go-jose/go-jose/v4 v4.0.1 // indirect
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
||||
github.com/goccy/go-json v0.10.5 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9 // indirect
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 // indirect
|
||||
github.com/hashicorp/go-sockaddr v1.0.7 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/magiconair/properties v1.8.7 // indirect
|
||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible // indirect
|
||||
github.com/klauspost/compress v1.17.11 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 // indirect
|
||||
github.com/knadh/koanf/maps v0.1.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
|
||||
github.com/spf13/afero v1.9.3 // indirect
|
||||
github.com/spf13/cast v1.5.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/subosito/gotenv v1.4.1 // indirect
|
||||
golang.org/x/sys v0.3.0 // indirect
|
||||
golang.org/x/text v0.5.0 // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/rogpeppe/go-internal v1.13.1 // indirect
|
||||
github.com/rs/xid v1.6.0 // indirect
|
||||
github.com/ryanuber/go-glob v1.0.0 // indirect
|
||||
github.com/spf13/pflag v1.0.6 // indirect
|
||||
github.com/stretchr/objx v0.5.2 // indirect
|
||||
github.com/stretchr/testify v1.10.0 // indirect
|
||||
github.com/tidwall/gjson v1.18.0 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
go.mau.fi/util v0.8.4 // indirect
|
||||
go.uber.org/atomic v1.11.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 // indirect
|
||||
golang.org/x/net v0.34.0 // indirect
|
||||
golang.org/x/sync v0.11.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/text v0.22.0 // indirect
|
||||
golang.org/x/time v0.10.0 // indirect
|
||||
maunium.net/go/maulogger/v2 v2.4.1 // indirect
|
||||
)
|
||||
|
751
go.sum
751
go.sum
@ -1,493 +1,362 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
|
||||
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
|
||||
cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.44.3/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY=
|
||||
cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc=
|
||||
cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0=
|
||||
cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To=
|
||||
cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4=
|
||||
cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M=
|
||||
cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc=
|
||||
cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk=
|
||||
cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs=
|
||||
cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc=
|
||||
cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY=
|
||||
cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI=
|
||||
cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk=
|
||||
cloud.google.com/go v0.75.0/go.mod h1:VGuuCn7PG0dwsd5XPVm2Mm3wlh3EL55/79EKB6hlPTY=
|
||||
cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o=
|
||||
cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE=
|
||||
cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc=
|
||||
cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg=
|
||||
cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc=
|
||||
cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ=
|
||||
cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE=
|
||||
cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk=
|
||||
cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I=
|
||||
cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw=
|
||||
cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA=
|
||||
cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU=
|
||||
cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw=
|
||||
cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos=
|
||||
cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk=
|
||||
cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs=
|
||||
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=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
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-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.7 h1:ky5o35oENWi0JYWUZkB7WYvVPP+bcRF5/Iq7JWSb5Rw=
|
||||
github.com/aws/aws-sdk-go-v2 v1.32.7/go.mod h1:P5WJBrYqqbWVaOxgH0X/FYYD47/nooaPOZPlQdmiN2U=
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.1 h1:iTDl5U6oAhkNPba0e1t1hrwAo02ZMqbrGq4k5JBWM5E=
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.1/go.mod h1:5PMILGVKiW32oDzjj6RU52yrNrDPUHcbZQYr1sM7qmM=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7 h1:lL7IfaFzngfx0ZwUGOZdsFFnQ5uLvR0hWqqhyE7Q9M8=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.7/go.mod h1:QraP0UcVlQJsmHfioCrveWOC1nbiWUl3ej08h4mXWoc=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 h1:zAxi9p3wsZMIaVCdoiQp2uZ9k1LsZvmAnoTBeZPXom0=
|
||||
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8/go.mod h1:3XkePX5dSaxveLAYY7nsbsZZrKxCyEuE5pM4ziFxyGg=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26 h1:I/5wmGMffY4happ8NOCuIUEWGUvvFp5NSeQcXl9RHcI=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.26/go.mod h1:FR8f4turZtNy6baO0KJ5FJUmXH/cSkI9fOngs0yl6mA=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.32 h1:BjUcr3X3K0wZPGFg2bxOWW3VPN8rkE3/61zhP+IHviA=
|
||||
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.32/go.mod h1:80+OGC/bgzzFFTUmcuwD0lb4YutwQeKLFpmt6hoWapU=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26 h1:zXFLuEuMMUOvEARXFUVJdfqZ4bvvSgdGRq/ATcrQxzM=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.26/go.mod h1:3o2Wpy0bogG1kyOPrgkXA8pgIfEEv0+m19O9D5+W8y8=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.32 h1:m1GeXHVMJsRsUAqG6HjZWx9dj7F5TR+cF1bjyfYyBd4=
|
||||
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.32/go.mod h1:IitoQxGfaKdVLNg0hD8/DXmAqNy0H4K2H2Sf91ti8sI=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26 h1:GeNJsIFHB+WW5ap2Tec4K6dzcVTsRbsT1Lra46Hv9ME=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.26/go.mod h1:zfgMpwHDXX2WGoG84xG2H+ZlPTkJUU4YUvx2svLQYWo=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.32 h1:OIHj/nAhVzIXGzbAE+4XmZ8FPvro3THr6NlqErJc3wY=
|
||||
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.32/go.mod h1:LiBEsDo34OJXqdDlRGsilhlIiXR7DL+6Cx2f4p1EgzI=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1 h1:iXtILhvDxB6kPvEXgsDhGaZCSC6LQET5ZHSdJozeI0Y=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.1/go.mod h1:9nu0fVANtYiAePIBh2/pFUSwtJ402hLnp854CNoDOeE=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 h1:D4oz8/CzT9bAEYtVhSBmFj2dNOtaHOtMKc2vHBwYizA=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2/go.mod h1:Za3IHqTQ+yNcRHxu1OFucBh0ACZT4j4VQFF0BqpZcLY=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7 h1:tB4tNw83KcajNAzaIMhkhVI2Nt8fAZd5A5ro113FEMY=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.7/go.mod h1:lvpyBGkZ3tZ9iSsUIcC2EWp+0ywa7aK3BLT+FwZi+mQ=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.6 h1:cCBJaT7EeEojpJ4s7wTDbhZlHVJOgNHN7iw6qVurGaw=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.6/go.mod h1:WYH1ABybY7JK9TITPnk6ZlP7gQB8psI4c9qDmMsnLSA=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7 h1:8eUsivBQzZHqe/3FE+cqwfH+0p5Jo8PFM/QYQSmeZ+M=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.7/go.mod h1:kLPQvGUmxn/fqiCrDeohwG33bq2pQpGeY62yRO6Nrh0=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.13 h1:SYVGSFQHlchIcy6e7x12bsrxClCXSP5et8cqVhL8cuw=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.13/go.mod h1:kizuDaLX37bG5WZaoxGPQR/LNFXpxp0vsUnqfkWXfNE=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7 h1:Hi0KGbrnr57bEHWM0bJ1QcBzxLrL/k2DHvGYhb8+W1w=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.7/go.mod h1:wKNgWgExdjjrm4qvfbTorkvocEstaoDl4WCvGfeCy9c=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.13 h1:OBsrtam3rk8NfBEq7OLOMm5HtQ9Yyw32X4UQMya/wjw=
|
||||
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.13/go.mod h1:3U4gFA5pmoCOja7aq4nSaIAGbaOHv2Yl2ug018cmC+Q=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0 h1:SAfh4pNx5LuTafKKWR02Y+hL3A+3TX8cTKG1OIAJaBk=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.72.0/go.mod h1:r+xl5yzMk9083rMR+sJ5TYj9Tihvf/l1oxzZXDgGj2Q=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.76.0 h1:ehvUZNVrGA1Usa6yYo8A8pUqrigRelWXSbcCqYpRLeI=
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.76.0/go.mod h1:KuLNrwYJFaC2AVZ+CVVc12k9NyqwgWsoNNHjwqF6QNk=
|
||||
github.com/aws/smithy-go v1.22.1 h1:/HPHZQ0g7f4eUeK6HKglFz8uwVfZKgoI25rb/J+dnro=
|
||||
github.com/aws/smithy-go v1.22.1/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
|
||||
github.com/aws/smithy-go v1.22.2 h1:6D9hW43xKFrRx/tXXfAlIZc4JI+yQe6snnWcQyxSyLQ=
|
||||
github.com/aws/smithy-go v1.22.2/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/cenkalti/backoff/v3 v3.2.2 h1:cfUAAO3yvKMYKPrvhDuHSwQnhZNk/RMHKdZqKTxfm6M=
|
||||
github.com/cenkalti/backoff/v3 v3.2.2/go.mod h1:cIeZDE3IrqwwJl6VUwCN6trj1oXrTS4rc0ij+ULvLYs=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8=
|
||||
github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE=
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/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.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
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/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po=
|
||||
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/frankban/quicktest v1.14.3 h1:FJKSZTDHjyhriyC81FLQ0LY93eSai0ZyR/ZIkd3ZUKE=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
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/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/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-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y=
|
||||
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
|
||||
github.com/frankban/quicktest v1.14.5 h1:dfYrrRyLtiqT9GyKXgdh+k4inNeTvmGbuSgZ3lx3GhA=
|
||||
github.com/frankban/quicktest v1.14.5/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
|
||||
github.com/go-co-op/gocron v1.33.1 h1:wjX+Dg6Ae29a/f9BSQjY1Rl+jflTpW9aDyMqseCj78c=
|
||||
github.com/go-co-op/gocron v1.33.1/go.mod h1:NLi+bkm4rRSy1F8U7iacZOz0xPseMoIOnvabGoSe/no=
|
||||
github.com/go-co-op/gocron v1.37.0 h1:ZYDJGtQ4OMhTLKOKMIch+/CY70Brbb1dGdooLEhh7b0=
|
||||
github.com/go-co-op/gocron v1.37.0/go.mod h1:3L/n6BkO7ABj+TrfSVXLRzsP26zmikL4ISkLQ0O8iNY=
|
||||
github.com/go-ini/ini v1.67.0 h1:z6ZrTEZqSWOTyH2FlglNbNgARyHG8oLW9gMELqKr06A=
|
||||
github.com/go-ini/ini v1.67.0/go.mod h1:ByCAeIL28uOIIG0E3PJtZPDL8WnHpFKFOtgjp+3Ies8=
|
||||
github.com/go-jose/go-jose/v3 v3.0.0 h1:s6rrhirfEP/CGIoc6p+PZAeogN2SxKav6Wp7+dyMWVo=
|
||||
github.com/go-jose/go-jose/v3 v3.0.0/go.mod h1:RNkWWRld676jZEYoV3+XK8L2ZnNSvIsxFMht0mSX+u8=
|
||||
github.com/go-jose/go-jose/v3 v3.0.3 h1:fFKWeig/irsp7XD2zBxvnmA/XaRWp5V3CBsZXJF7G7k=
|
||||
github.com/go-jose/go-jose/v3 v3.0.3/go.mod h1:5b+7YgP7ZICgJDBdfjZaIt+H/9L9T/YQrVfLAMboGkQ=
|
||||
github.com/go-jose/go-jose/v4 v4.0.1 h1:QVEPDE3OluqXBQZDcnNvQrInro2h0e4eqNbnZSWqS6U=
|
||||
github.com/go-jose/go-jose/v4 v4.0.1/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY=
|
||||
github.com/go-test/deep v1.0.2 h1:onZX1rnHT3Wv6cqNgYyFOOlgVKJrksuCMCRvJStbMYw=
|
||||
github.com/go-test/deep v1.0.2/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
||||
github.com/goccy/go-json v0.10.4 h1:JSwxQzIqKfmFX1swYPpUThQZp/Ka4wzJdK0LWVytLPM=
|
||||
github.com/goccy/go-json v0.10.4/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
|
||||
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.5.0/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.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
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/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/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
||||
github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM=
|
||||
github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
|
||||
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
|
||||
github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g=
|
||||
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
|
||||
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
|
||||
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
|
||||
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
|
||||
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
|
||||
github.com/hashicorp/go-hclog v0.16.2 h1:K4ev2ib4LdQETX5cSZBG0DVLk1jwGqSPXBjdah3veNs=
|
||||
github.com/hashicorp/go-hclog v0.16.2/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
|
||||
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
|
||||
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
|
||||
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
|
||||
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4 h1:ZQgVdpTdAL7WpMIwLzCfbalOcSUdkDZnpUv3/+BxzFA=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.4/go.mod h1:Jy/gPYAdjqffZ/yFGCFV2doI5wjtH1ewM9u8iYVjtX8=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
|
||||
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc=
|
||||
github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7 h1:UpiO20jno/eV1eVZcxqWnUohyKRe1g8FPV/xH1s/2qs=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.7/go.mod h1:QmrqtbKuxxSWTN3ETMPuB+VtEiBJ/A9XhoYGv8E1uD8=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9 h1:FW0YttEnUNDJ2WL9XcrrfteS1xW8u+sh4ggM8pN5isQ=
|
||||
github.com/hashicorp/go-secure-stdlib/parseutil v0.1.9/go.mod h1:Ll013mhdmsVDuoIXVfBtvgGJsXDYkTw1kooNcoCXuE0=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.1/go.mod h1:gKOamz3EwoIoJq7mlMIRBpVTAUn8qPCrEclOKKWhD3U=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2 h1:kes8mmyCpxJsI7FTwtzRqEy9CdjCtrXrXGuOpxEA7Ts=
|
||||
github.com/hashicorp/go-secure-stdlib/strutil v0.1.2/go.mod h1:Gou2R9+il93BqX25LAKCLuM+y9U2T4hlwvT1yprcna4=
|
||||
github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A=
|
||||
github.com/hashicorp/go-sockaddr v1.0.5 h1:dvk7TIXCZpmfOlM+9mlcrWmWjw/wlKT+VDq2wMvfPJU=
|
||||
github.com/hashicorp/go-sockaddr v1.0.5/go.mod h1:uoUUmtwU7n9Dv3O4SNLeFvg0SxQ3lyjsj6+CCykpaxI=
|
||||
github.com/hashicorp/go-sockaddr v1.0.7 h1:G+pTkSO01HpR5qCxg7lxfsFEZaG+C0VssTy/9dbT+Fw=
|
||||
github.com/hashicorp/go-sockaddr v1.0.7/go.mod h1:FZQbEYa1pxkQ7WLpyXJ6cbjpT8q0YgQaK/JakXqGyWw=
|
||||
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/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/inconshreveable/mousetrap v1.0.1/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/hashicorp/vault/api v1.10.0 h1:/US7sIjWN6Imp4o/Rj1Ce2Nr5bki/AXi9vAW3p2tOJQ=
|
||||
github.com/hashicorp/vault/api v1.10.0/go.mod h1:jo5Y/ET+hNyz+JnKDt8XLAdKs+AM0G5W0Vp1IrFI8N8=
|
||||
github.com/hashicorp/vault/api v1.15.0 h1:O24FYQCWwhwKnF7CuSqP30S51rTV7vz1iACXE/pj5DA=
|
||||
github.com/hashicorp/vault/api v1.15.0/go.mod h1:+5YTO09JGn0u+b6ySD/LLVf8WkJCPLAL2Vkmrn2+CM8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
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/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
||||
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/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/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg=
|
||||
github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc=
|
||||
github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9 h1:66ze0taIn2H33fBvCkXuv9BmCwDfafmiIVpKV9kKGuY=
|
||||
github.com/klauspost/cpuid/v2 v2.2.9/go.mod h1:rqkxqrZ1EhYM9G+hXH7YdowN5R5RGN6NK4QwQ3WMXF8=
|
||||
github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs=
|
||||
github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI=
|
||||
github.com/knadh/koanf/parsers/yaml v0.1.0 h1:ZZ8/iGfRLvKSaMEECEBPM1HQslrZADk8fP1XFUxVI5w=
|
||||
github.com/knadh/koanf/parsers/yaml v0.1.0/go.mod h1:cvbUDC7AL23pImuQP0oRw/hPuccrNBS2bps8asS0CwY=
|
||||
github.com/knadh/koanf/providers/rawbytes v0.1.0 h1:dpzgu2KO6uf6oCb4aP05KDmKmAmI51k5pe8RYKQ0qME=
|
||||
github.com/knadh/koanf/providers/rawbytes v0.1.0/go.mod h1:mMTB1/IcJ/yE++A2iEZbY1MLygX7vttU+C+S/YmPu9c=
|
||||
github.com/knadh/koanf/v2 v2.0.1 h1:1dYGITt1I23x8cfx8ZnldtezdyaZtfAuRtIFOiRzK7g=
|
||||
github.com/knadh/koanf/v2 v2.0.1/go.mod h1:ZeiIlIDXTE7w1lMT6UVcNiRAS2/rCeLn/GdLNvY1Dus=
|
||||
github.com/knadh/koanf/v2 v2.1.2 h1:I2rtLRqXRy1p01m/utEtpZSSA6dcJbgGVuE27kW2PzQ=
|
||||
github.com/knadh/koanf/v2 v2.1.2/go.mod h1:Gphfaen0q1Fc1HTgJgSTC4oRX9R2R5ErYMZJy8fLJBo=
|
||||
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.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
|
||||
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.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
|
||||
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
|
||||
github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.84 h1:D1HVmAF8JF8Bpi6IU4V9vIEj+8pc+xU88EWMs2yed0E=
|
||||
github.com/minio/minio-go/v7 v7.0.84/go.mod h1:57YXpvc5l3rjPdhqNrDsvVlY0qPI6UTk1bflAe+9doY=
|
||||
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
|
||||
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
|
||||
github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s=
|
||||
github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
|
||||
github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
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/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/v2 v2.0.6 h1:nrzqCb7j9cDFj2coyLNLaZuJTLjWjlaz6nvTvIwycIU=
|
||||
github.com/pelletier/go-toml/v2 v2.0.6/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
|
||||
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
|
||||
github.com/nikoksr/notify v0.41.0 h1:4LGE41GpWdHX5M3Xo6DlWRwS2WLDbOq1Rk7IzY4vjmQ=
|
||||
github.com/nikoksr/notify v0.41.0/go.mod h1:FoE0UVPeopz1Vy5nm9vQZ+JVmYjEIjQgbFstbkw+cRE=
|
||||
github.com/nikoksr/notify v1.3.0 h1:UxzfxzAYGQD9a5JYLBTVx0lFMxeHCke3rPCkfWdPgLs=
|
||||
github.com/nikoksr/notify v1.3.0/go.mod h1:Xor2hMmkvrCfkCKvXGbcrESez4brac2zQjhd6U2BbeM=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
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/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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
|
||||
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
|
||||
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
|
||||
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
|
||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
|
||||
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
|
||||
github.com/rs/zerolog v1.30.0 h1:SymVODrcRsaRaSInD9yQtKbtWqwsfoPcRff/oRXLj4c=
|
||||
github.com/rs/zerolog v1.30.0/go.mod h1:/tk+P47gFdPXq4QYjvCmT5/Gsug2nagsFWBWhAiSi1w=
|
||||
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
|
||||
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/spf13/afero v1.9.3 h1:41FoI0fD7OR7mGcKE/aOiLkGreyf8ifIOQmJANWogMk=
|
||||
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/go.mod h1:SpXXQ5YoyJw6s3/6cMTQuxvgRl3PCJiyaX9p6b155UU=
|
||||
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=
|
||||
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/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
|
||||
github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/ryanuber/go-glob v1.0.0 h1:iQh3xXAumdQ+4Ufa5b25cRpC5TYKlno6hsv6Cb3pkBk=
|
||||
github.com/ryanuber/go-glob v1.0.0/go.mod h1:807d1WSdnB0XRJzKNil9Om6lcp/3a0v4qIHxIXzX/Yc=
|
||||
github.com/sethvargo/go-password v0.3.1 h1:WqrLTjo7X6AcVYfC6R7GtSyuUQR9hGyAj/f1PYQZCJU=
|
||||
github.com/sethvargo/go-password v0.3.1/go.mod h1:rXofC1zT54N7R8K/h1WDUdkf9BOx5OptoxrMBcrXzvs=
|
||||
github.com/spf13/cobra v1.7.0 h1:hyqWnYt1ZQShIddO5kBpj3vu05/++x6tJ6dg8EC572I=
|
||||
github.com/spf13/cobra v1.7.0/go.mod h1:uLxZILRyS/50WlhOIKD7W6V5bgeIt+4sICxh6uRMrb0=
|
||||
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
|
||||
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
|
||||
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/viper v1.14.0 h1:Rg7d3Lo706X9tHsJMUjdiwMpHB7W8WnSVOssIY+JElU=
|
||||
github.com/spf13/viper v1.14.0/go.mod h1:WT//axPky3FdvXHzGw33dNdXXXfFQqmEalje+egj8As=
|
||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
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.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
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.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/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.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/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||
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.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU=
|
||||
go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
|
||||
go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.16.0 h1:SyXa+dsSPpUlcwEDuKuEBJEz5vzTvOea+9rjyYodQFg=
|
||||
github.com/tidwall/gjson v1.16.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/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/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/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.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.mau.fi/util v0.0.0-20230906155759-14bad39a8718 h1:hmm5bZqE0M8+Uvys0HJPCSbAIZIwYtTkBKYPjAWHuMM=
|
||||
go.mau.fi/util v0.0.0-20230906155759-14bad39a8718/go.mod h1:AxuJUMCxpzgJ5eV9JbPWKRH8aAJJidxetNdUj7qcb84=
|
||||
go.mau.fi/util v0.8.4 h1:mVKlJcXWfVo8ZW3f4vqtjGpqtZqJvX4ETekxawt2vnQ=
|
||||
go.mau.fi/util v0.8.4/go.mod h1:MOfGTs1CBuK6ERTcSL4lb5YU7/ujz09eOPVEDckuazY=
|
||||
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
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-20190605123033-f99c8df09eb5/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-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||
golang.org/x/crypto v0.0.0-20211108221036-ceb1ce70b4fa/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.4.0 h1:UVQgzMY87xqpKNgb+kDsll2Igd33HszWHFLmpaRMq/8=
|
||||
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
||||
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-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
|
||||
golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek=
|
||||
golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY=
|
||||
golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
|
||||
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
|
||||
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs=
|
||||
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/crypto v0.0.0-20190911031432-227b76d455e7/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U=
|
||||
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
|
||||
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
|
||||
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8=
|
||||
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY=
|
||||
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3 h1:qNgPs5exUA+G0C96DrPwNrvLSj7GT/9D+3WMWUcUg34=
|
||||
golang.org/x/exp v0.0.0-20250207012021-f9890c6ad9f3/go.mod h1:tujkw807nyEEAamNbDrEGzRav+ilXA7PCRAd6xsmwiU=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
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-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
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-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
|
||||
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
|
||||
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/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-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
|
||||
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.11.0 h1:GGz8+XQP4FvTTrjZPzNKTMFtSXH80RAzG+5ghFPgK9w=
|
||||
golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/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-20191001151750-bb3f8db39f24/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-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/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-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.3.0 h1:w8ZOecv6NaNa/zC8944JTU3vz4u6Lagfk4RPQxv92NQ=
|
||||
golang.org/x/sys v0.3.0/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-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=
|
||||
golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.3.0 h1:qoo4akIqOcDME5bhc/NgxUdovd6BSS2uMsVjB56q1xI=
|
||||
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
|
||||
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
|
||||
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
||||
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.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.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.5.0 h1:OLmvp0KP+FVG99Ct/qFiL/Fhk4zp4QQnZ7b2U+5piUM=
|
||||
golang.org/x/text v0.5.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-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/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.10.0 h1:3usCWA8tQn0L8+hFJQNgzpWbd89begxN66o1Ojdn5L4=
|
||||
golang.org/x/time v0.10.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw=
|
||||
golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8=
|
||||
golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
|
||||
golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE=
|
||||
golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
|
||||
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
|
||||
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
|
||||
google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI=
|
||||
google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE=
|
||||
google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE=
|
||||
google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM=
|
||||
google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc=
|
||||
google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg=
|
||||
google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE=
|
||||
google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8=
|
||||
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0=
|
||||
google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc=
|
||||
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||
google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8=
|
||||
google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc=
|
||||
google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA=
|
||||
google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
|
||||
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
|
||||
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
|
||||
google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210108203827-ffc7fda8c3d7/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/genproto v0.0.0-20210226172003-ab064af71705/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
|
||||
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||
google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60=
|
||||
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
|
||||
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
|
||||
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8=
|
||||
google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
|
||||
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
|
||||
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
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/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
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/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
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.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
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/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
maunium.net/go/maulogger/v2 v2.4.1 h1:N7zSdd0mZkB2m2JtFUsiGTQQAdP0YeFWT7YMc80yAL8=
|
||||
maunium.net/go/maulogger/v2 v2.4.1/go.mod h1:omPuYwYBILeVQobz8uO3XC8DIRuEb5rXYlQSuqrbCho=
|
||||
maunium.net/go/mautrix v0.16.0 h1:iUqCzJE2yqBC1ddAK6eAn159My8rLb4X8g4SFtQh2Dk=
|
||||
maunium.net/go/mautrix v0.16.0/go.mod h1:XAjE9pTSGcr6vXaiNgQGiip7tddJ8FQV1a29u2QdBG4=
|
||||
maunium.net/go/mautrix v0.23.0 h1:HNlR19eew5lvrNSL2muhExaGhYdaGk5FfEiA82QqUP4=
|
||||
maunium.net/go/mautrix v0.23.0/go.mod h1:AGnnaz3ylGikUo1I1MJVn9QLsl2No1/ZNnGDyO0QD5s=
|
||||
mvdan.cc/sh/v3 v3.7.0 h1:lSTjdP/1xsddtaKfGg7Myu7DnlHItd3/M2tomOcNNBg=
|
||||
mvdan.cc/sh/v3 v3.7.0/go.mod h1:K2gwkaesF/D7av7Kxl0HbF5kGOd2ArupNTX3X44+8l8=
|
||||
mvdan.cc/sh/v3 v3.10.0 h1:v9z7N1DLZ7owyLM/SXZQkBSXcwr2IGMm2LY2pmhVXj4=
|
||||
mvdan.cc/sh/v3 v3.10.0/go.mod h1:z/mSSVyLFGZzqb3ZIKojjyqIx/xbmz/UHdCSv9HmqXY=
|
||||
|
@ -1,110 +1,438 @@
|
||||
// backy.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
package backy
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"os/exec"
|
||||
"text/template"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"embed"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
// 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
|
||||
Empty bool
|
||||
Host string
|
||||
HostName []string
|
||||
Port uint16
|
||||
PrivateKeyPath string
|
||||
PrivateKeyPassword string
|
||||
User string
|
||||
//go:embed templates/*.txt
|
||||
var templates embed.FS
|
||||
|
||||
var requiredKeys = []string{"commands"}
|
||||
|
||||
var Sprintf = fmt.Sprintf
|
||||
|
||||
// RunCmd runs a Command.
|
||||
// The environment of local commands will be the machine's environment plus any extra
|
||||
// variables specified in the Env file or Environment.
|
||||
// Dir can also be specified for local commands.
|
||||
//
|
||||
// Returns the output as a slice and an error, if any
|
||||
func (command *Command) RunCmd(cmdCtxLogger zerolog.Logger, opts *ConfigOpts) ([]string, error) {
|
||||
|
||||
var (
|
||||
ArgsStr string // concatenating the arguments
|
||||
cmdOutBuf bytes.Buffer
|
||||
cmdOutWriters io.Writer
|
||||
errSSH error
|
||||
|
||||
envVars = environmentVars{
|
||||
file: command.Env,
|
||||
env: command.Environment,
|
||||
}
|
||||
|
||||
type Command struct {
|
||||
Remote bool
|
||||
RemoteHost Host
|
||||
Cmd string
|
||||
Args []string
|
||||
}
|
||||
outputArr []string // holds the output strings returned by processes
|
||||
)
|
||||
|
||||
// BackupConfig is a configuration struct that is used to define backups
|
||||
type BackupConfig struct {
|
||||
Name string
|
||||
BackupType string
|
||||
ConfigPath string
|
||||
// Get the command type
|
||||
// This must be done before concatenating the arguments
|
||||
command = getCommandType(command)
|
||||
|
||||
Cmd Command
|
||||
}
|
||||
|
||||
/*
|
||||
* Runs a backup configuration
|
||||
*/
|
||||
|
||||
func (command Command) runCmd() logging.Logging {
|
||||
|
||||
var stdoutBuf, stderrBuf bytes.Buffer
|
||||
var err error
|
||||
var cmdArgs string
|
||||
for _, v := range command.Args {
|
||||
cmdArgs += v
|
||||
ArgsStr += fmt.Sprintf(" %s", v)
|
||||
}
|
||||
|
||||
var remoteHost = &command.RemoteHost
|
||||
fmt.Printf("\n\nRunning command: " + command.Cmd + " " + cmdArgs + " on host " + command.RemoteHost.Host + "...\n\n")
|
||||
if command.Remote {
|
||||
|
||||
remoteHost.Port = 22
|
||||
remoteHost.Host = command.RemoteHost.Host
|
||||
|
||||
sshClient, err := remoteHost.ConnectToSSHHost()
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("ssh dial: %w", err))
|
||||
// print the user's password if it is updated
|
||||
if command.Type == "user" {
|
||||
if command.UserOperation == "password" {
|
||||
cmdCtxLogger.Info().Str("password", command.UserPassword).Msg("user password to be updated")
|
||||
}
|
||||
defer sshClient.Close()
|
||||
s, err := sshClient.NewSession()
|
||||
if err != nil {
|
||||
panic(fmt.Errorf("new ssh session: %w", err))
|
||||
}
|
||||
defer s.Close()
|
||||
|
||||
cmd := command.Cmd
|
||||
for _, a := range command.Args {
|
||||
cmd += " " + a
|
||||
}
|
||||
|
||||
s.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||
s.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||
err = s.Run(cmd)
|
||||
if err != nil {
|
||||
return logging.Logging{
|
||||
Output: stdoutBuf.String(),
|
||||
Err: fmt.Errorf("error running " + cmd + ": " + stderrBuf.String()),
|
||||
// is host defined
|
||||
if command.Host != nil {
|
||||
outputArr, errSSH = command.RunCmdSSH(cmdCtxLogger, opts)
|
||||
if errSSH != nil {
|
||||
return outputArr, errSSH
|
||||
}
|
||||
}
|
||||
// fmt.Printf("Output: %s\n", string(output))
|
||||
} else {
|
||||
// shell := "/bin/bash"
|
||||
localCMD := exec.Command(command.Cmd, command.Args...)
|
||||
localCMD.Stdout = io.MultiWriter(os.Stdout, &stdoutBuf)
|
||||
localCMD.Stderr = io.MultiWriter(os.Stderr, &stderrBuf)
|
||||
|
||||
// Handle package operations
|
||||
if command.Type == "package" && command.PackageOperation == "checkVersion" {
|
||||
cmdCtxLogger.Info().Str("package", command.PackageName).Msg("Checking package versions")
|
||||
|
||||
// Execute the package version command
|
||||
cmd := exec.Command(command.Cmd, command.Args...)
|
||||
cmdOutWriters = io.MultiWriter(&cmdOutBuf)
|
||||
cmd.Stdout = cmdOutWriters
|
||||
cmd.Stderr = cmdOutWriters
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return nil, fmt.Errorf("error running command %s: %w", ArgsStr, err)
|
||||
}
|
||||
|
||||
return parsePackageVersion(cmdOutBuf.String(), cmdCtxLogger, command, cmdOutBuf)
|
||||
}
|
||||
|
||||
var localCMD *exec.Cmd
|
||||
var err error
|
||||
if command.Shell != "" {
|
||||
cmdCtxLogger.Info().Str("Command", fmt.Sprintf("Running command %s on local machine in %s", command.Name, command.Shell)).Send()
|
||||
|
||||
ArgsStr = fmt.Sprintf("%s %s", command.Cmd, ArgsStr)
|
||||
|
||||
localCMD = exec.Command(command.Shell, "-c", ArgsStr)
|
||||
|
||||
} else {
|
||||
|
||||
cmdCtxLogger.Info().Str("Command", fmt.Sprintf("Running command %s on local machine", command.Name)).Send()
|
||||
|
||||
// execute package commands in a shell
|
||||
if command.Type == "package" {
|
||||
cmdCtxLogger.Info().Str("package", command.PackageName).Msg("Executing package command")
|
||||
ArgsStr = fmt.Sprintf("%s %s", command.Cmd, ArgsStr)
|
||||
localCMD = exec.Command("/bin/sh", "-c", ArgsStr)
|
||||
} else {
|
||||
localCMD = exec.Command(command.Cmd, command.Args...)
|
||||
}
|
||||
}
|
||||
|
||||
if command.Dir != nil {
|
||||
localCMD.Dir = *command.Dir
|
||||
}
|
||||
|
||||
injectEnvIntoLocalCMD(envVars, localCMD, cmdCtxLogger)
|
||||
|
||||
cmdOutWriters = io.MultiWriter(&cmdOutBuf)
|
||||
|
||||
if IsCmdStdOutEnabled() {
|
||||
cmdOutWriters = io.MultiWriter(os.Stdout, &cmdOutBuf)
|
||||
}
|
||||
|
||||
localCMD.Stdout = cmdOutWriters
|
||||
localCMD.Stderr = cmdOutWriters
|
||||
|
||||
err = localCMD.Run()
|
||||
|
||||
outScanner := bufio.NewScanner(&cmdOutBuf)
|
||||
|
||||
for outScanner.Scan() {
|
||||
outMap := make(map[string]interface{})
|
||||
outMap["cmd"] = command.Cmd
|
||||
outMap["output"] = outScanner.Text()
|
||||
|
||||
if str, ok := outMap["output"].(string); ok {
|
||||
outputArr = append(outputArr, str)
|
||||
}
|
||||
// if command.GetOutput {
|
||||
cmdCtxLogger.Info().Fields(outMap).Send()
|
||||
// }
|
||||
}
|
||||
if err != nil {
|
||||
return logging.Logging{
|
||||
Output: stdoutBuf.String(),
|
||||
Err: fmt.Errorf(stderrBuf.String()),
|
||||
cmdCtxLogger.Error().Err(fmt.Errorf("error when running cmd %s: %w", command.Name, err)).Send()
|
||||
return outputArr, err
|
||||
}
|
||||
}
|
||||
return outputArr, nil
|
||||
}
|
||||
return logging.Logging{
|
||||
Output: stdoutBuf.String(),
|
||||
Err: nil,
|
||||
|
||||
func cmdListWorker(msgTemps *msgTemplates, jobs <-chan *CmdList, results chan<- CmdResult, opts *ConfigOpts) {
|
||||
for list := range jobs {
|
||||
fieldsMap := map[string]interface{}{"list": list.Name}
|
||||
var cmdLogger zerolog.Logger
|
||||
var cmdsRan []string
|
||||
var outStructArr []outStruct
|
||||
var hasError bool // Tracks if any command in the list failed
|
||||
|
||||
for _, cmd := range list.Order {
|
||||
cmdToRun := opts.Cmds[cmd]
|
||||
currentCmd := cmdToRun.Name
|
||||
fieldsMap["cmd"] = currentCmd
|
||||
cmdLogger = cmdToRun.GenerateLogger(opts)
|
||||
cmdLogger.Info().Fields(fieldsMap).Send()
|
||||
|
||||
outputArr, runErr := cmdToRun.RunCmd(cmdLogger, opts)
|
||||
cmdsRan = append(cmdsRan, cmd)
|
||||
|
||||
if runErr != nil {
|
||||
|
||||
// Log the error and send a failed result
|
||||
cmdLogger.Err(runErr).Send()
|
||||
results <- CmdResult{CmdName: cmd, ListName: list.Name, Error: runErr}
|
||||
|
||||
// Execute error hooks for the failed command
|
||||
cmdToRun.ExecuteHooks("error", opts)
|
||||
|
||||
// Notify failure
|
||||
if list.NotifyConfig != nil {
|
||||
notifyError(cmdLogger, msgTemps, list, cmdsRan, outStructArr, runErr, cmdToRun)
|
||||
}
|
||||
hasError = true
|
||||
break
|
||||
}
|
||||
|
||||
// Collect output if required
|
||||
if list.GetOutput || cmdToRun.GetOutput {
|
||||
outStructArr = append(outStructArr, outStruct{
|
||||
CmdName: currentCmd,
|
||||
CmdExecuted: currentCmd,
|
||||
Output: outputArr,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func New() BackupConfig {
|
||||
return BackupConfig{}
|
||||
// Notify success if no errors occurred
|
||||
if !hasError && list.NotifyConfig != nil && (list.NotifyOnSuccess || list.GetOutput) {
|
||||
notifySuccess(cmdLogger, msgTemps, list, cmdsRan, outStructArr)
|
||||
}
|
||||
|
||||
// Execute success and final hooks for all commands
|
||||
for _, cmd := range list.Order {
|
||||
cmdToRun := opts.Cmds[cmd]
|
||||
|
||||
// Execute success hooks if the command succeeded
|
||||
if !hasError || cmdsRanContains(cmd, cmdsRan) {
|
||||
cmdToRun.ExecuteHooks("success", opts)
|
||||
}
|
||||
|
||||
// Execute final hooks for every command
|
||||
cmdToRun.ExecuteHooks("final", opts)
|
||||
}
|
||||
|
||||
// Send the final result for the list
|
||||
if hasError {
|
||||
results <- CmdResult{CmdName: cmdsRan[len(cmdsRan)-1], ListName: list.Name, Error: fmt.Errorf("list execution failed")}
|
||||
} else {
|
||||
results <- CmdResult{CmdName: cmdsRan[len(cmdsRan)-1], ListName: list.Name, Error: nil}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to check if a command is in the list of executed commands
|
||||
func cmdsRanContains(cmd string, cmdsRan []string) bool {
|
||||
for _, c := range cmdsRan {
|
||||
if c == cmd {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Helper to notify errors
|
||||
func notifyError(logger zerolog.Logger, templates *msgTemplates, list *CmdList, cmdsRan []string, outStructArr []outStruct, err error, cmd *Command) {
|
||||
errStruct := map[string]interface{}{
|
||||
"listName": list.Name,
|
||||
"CmdsRan": cmdsRan,
|
||||
"CmdOutput": outStructArr,
|
||||
"Err": err,
|
||||
"CmdName": cmd.Name,
|
||||
"Command": cmd.Cmd,
|
||||
"Args": cmd.Args,
|
||||
}
|
||||
var errMsg bytes.Buffer
|
||||
if e := templates.err.Execute(&errMsg, errStruct); e != nil {
|
||||
logger.Err(e).Send()
|
||||
return
|
||||
}
|
||||
if e := list.NotifyConfig.Send(context.Background(), fmt.Sprintf("List %s failed", list.Name), errMsg.String()); e != nil {
|
||||
logger.Err(e).Send()
|
||||
}
|
||||
}
|
||||
|
||||
// Helper to notify success
|
||||
func notifySuccess(logger zerolog.Logger, templates *msgTemplates, list *CmdList, cmdsRan []string, outStructArr []outStruct) {
|
||||
successStruct := map[string]interface{}{
|
||||
"listName": list.Name,
|
||||
"CmdsRan": cmdsRan,
|
||||
"CmdOutput": outStructArr,
|
||||
}
|
||||
var successMsg bytes.Buffer
|
||||
if e := templates.success.Execute(&successMsg, successStruct); e != nil {
|
||||
logger.Err(e).Send()
|
||||
return
|
||||
}
|
||||
if e := list.NotifyConfig.Send(context.Background(), fmt.Sprintf("List %s succeeded", list.Name), successMsg.String()); e != nil {
|
||||
logger.Err(e).Send()
|
||||
}
|
||||
}
|
||||
|
||||
// RunListConfig runs a command list from the ConfigFile.
|
||||
func (opts *ConfigOpts) RunListConfig(cron string) {
|
||||
mTemps := &msgTemplates{
|
||||
err: template.Must(template.New("error.txt").ParseFS(templates, "templates/error.txt")),
|
||||
success: template.Must(template.New("success.txt").ParseFS(templates, "templates/success.txt")),
|
||||
}
|
||||
configListsLen := len(opts.CmdConfigLists)
|
||||
listChan := make(chan *CmdList, configListsLen)
|
||||
results := make(chan CmdResult, configListsLen)
|
||||
|
||||
// Start workers
|
||||
for w := 1; w <= configListsLen; w++ {
|
||||
go cmdListWorker(mTemps, listChan, results, opts)
|
||||
}
|
||||
|
||||
// Enqueue jobs
|
||||
for listName, cmdConfig := range opts.CmdConfigLists {
|
||||
if cmdConfig.Name == "" {
|
||||
cmdConfig.Name = listName
|
||||
}
|
||||
if cron == "" || cron == cmdConfig.Cron {
|
||||
listChan <- cmdConfig
|
||||
}
|
||||
}
|
||||
close(listChan)
|
||||
|
||||
// Process results
|
||||
for a := 1; a <= configListsLen; a++ {
|
||||
result := <-results
|
||||
opts.Logger.Debug().Msgf("Processing result for list %s, command %s", result.ListName, result.CmdName)
|
||||
|
||||
// Process final hooks for the list (already handled in worker)
|
||||
}
|
||||
opts.closeHostConnections()
|
||||
}
|
||||
|
||||
func (opts *ConfigOpts) ExecuteCmds() {
|
||||
for _, cmd := range opts.executeCmds {
|
||||
cmdToRun := opts.Cmds[cmd]
|
||||
cmdLogger := cmdToRun.GenerateLogger(opts)
|
||||
_, runErr := cmdToRun.RunCmd(cmdLogger, opts)
|
||||
if runErr != nil {
|
||||
opts.Logger.Err(runErr).Send()
|
||||
|
||||
cmdToRun.ExecuteHooks("error", opts)
|
||||
} else {
|
||||
|
||||
cmdToRun.ExecuteHooks("success", opts)
|
||||
}
|
||||
|
||||
cmdToRun.ExecuteHooks("final", opts)
|
||||
}
|
||||
|
||||
opts.closeHostConnections()
|
||||
|
||||
}
|
||||
|
||||
func (c *ConfigOpts) closeHostConnections() {
|
||||
for _, host := range c.Hosts {
|
||||
if host.isProxyHost {
|
||||
continue
|
||||
}
|
||||
if host.SshClient != nil {
|
||||
if _, err := host.SshClient.NewSession(); err == nil {
|
||||
c.Logger.Info().Msgf("Closing host connection %s", host.HostName)
|
||||
host.SshClient.Close()
|
||||
host.SshClient = nil
|
||||
}
|
||||
}
|
||||
for _, proxyHost := range host.ProxyHost {
|
||||
if proxyHost.isProxyHost {
|
||||
continue
|
||||
}
|
||||
if proxyHost.SshClient != nil {
|
||||
if _, err := host.SshClient.NewSession(); err == nil {
|
||||
c.Logger.Info().Msgf("Closing connection to proxy host %s", host.HostName)
|
||||
host.SshClient.Close()
|
||||
host.SshClient = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, host := range c.Hosts {
|
||||
if host.SshClient != nil {
|
||||
if _, err := host.SshClient.NewSession(); err == nil {
|
||||
c.Logger.Info().Msgf("Closing proxy host connection %s", host.HostName)
|
||||
host.SshClient.Close()
|
||||
host.SshClient = nil
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (cmd *Command) ExecuteHooks(hookType string, opts *ConfigOpts) {
|
||||
if cmd.Hooks == nil {
|
||||
return
|
||||
}
|
||||
switch hookType {
|
||||
case "error":
|
||||
for _, v := range cmd.Hooks.Error {
|
||||
errCmd := opts.Cmds[v]
|
||||
cmdLogger := opts.Logger.With().
|
||||
Str("backy-cmd", v).
|
||||
Logger()
|
||||
errCmd.RunCmd(cmdLogger, opts)
|
||||
}
|
||||
|
||||
case "success":
|
||||
for _, v := range cmd.Hooks.Success {
|
||||
successCmd := opts.Cmds[v]
|
||||
cmdLogger := opts.Logger.With().
|
||||
Str("backy-cmd", v).
|
||||
Logger()
|
||||
successCmd.RunCmd(cmdLogger, opts)
|
||||
}
|
||||
case "final":
|
||||
for _, v := range cmd.Hooks.Final {
|
||||
finalCmd := opts.Cmds[v]
|
||||
cmdLogger := opts.Logger.With().
|
||||
Str("backy-cmd", v).
|
||||
Logger()
|
||||
finalCmd.RunCmd(cmdLogger, opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (cmd *Command) GenerateLogger(opts *ConfigOpts) zerolog.Logger {
|
||||
cmdLogger := opts.Logger.With().
|
||||
Str("Backy-cmd", cmd.Name).Str("Host", "local machine").
|
||||
Logger()
|
||||
|
||||
if cmd.Host != nil {
|
||||
cmdLogger = opts.Logger.With().
|
||||
Str("Backy-cmd", cmd.Name).Str("Host", *cmd.Host).
|
||||
Logger()
|
||||
|
||||
}
|
||||
return cmdLogger
|
||||
}
|
||||
|
||||
func (opts *ConfigOpts) ExecCmdsSSH(cmdList []string, hostsList []string) {
|
||||
// Iterate over hosts and exec commands
|
||||
for _, h := range hostsList {
|
||||
host := opts.Hosts[h]
|
||||
for _, c := range cmdList {
|
||||
cmd := opts.Cmds[c]
|
||||
cmd.RemoteHost = host
|
||||
cmd.Host = &host.Host
|
||||
opts.Logger.Info().Str("host", h).Str("cmd", c).Send()
|
||||
_, err := cmd.RunCmdSSH(cmd.GenerateLogger(opts), opts)
|
||||
if err != nil {
|
||||
opts.Logger.Err(err).Str("host", h).Str("cmd", c).Send()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// func executeUserCommands() []string {
|
||||
|
||||
// }
|
||||
|
||||
// // parseRemoteSources parses source and validates fields using sourceType
|
||||
// func (c *Command) parseRemoteSources(source, sourceType string) {
|
||||
// switch sourceType {
|
||||
|
||||
// }
|
||||
// }
|
||||
|
680
pkg/backy/config.go
Normal file
680
pkg/backy/config.go
Normal file
@ -0,0 +1,680 @@
|
||||
package backy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/remotefetcher"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/usermanager"
|
||||
vault "github.com/hashicorp/vault/api"
|
||||
"github.com/knadh/koanf/parsers/yaml"
|
||||
"github.com/knadh/koanf/providers/rawbytes"
|
||||
"github.com/knadh/koanf/v2"
|
||||
"github.com/mattn/go-isatty"
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
const macroStart string = "%{"
|
||||
const macroEnd string = "}%"
|
||||
const envMacroStart string = "%{env:"
|
||||
const vaultMacroStart string = "%{vault:"
|
||||
|
||||
func (opts *ConfigOpts) InitConfig() {
|
||||
var err error
|
||||
homeConfigDir, err := os.UserConfigDir()
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(err.Error(), 1, nil)
|
||||
}
|
||||
homeCacheDir, err := os.UserCacheDir()
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(err.Error(), 1, nil)
|
||||
}
|
||||
|
||||
backyHomeConfDir := path.Join(homeConfigDir, "backy")
|
||||
configFiles := []string{
|
||||
"./backy.yml", "./backy.yaml",
|
||||
path.Join(backyHomeConfDir, "backy.yml"),
|
||||
path.Join(backyHomeConfDir, "backy.yaml"),
|
||||
}
|
||||
|
||||
backyKoanf := koanf.New(".")
|
||||
opts.ConfigFilePath = strings.TrimSpace(opts.ConfigFilePath)
|
||||
|
||||
// metadataFile := "hashMetadataSample.yml"
|
||||
|
||||
cacheDir := homeCacheDir
|
||||
|
||||
// Load metadata from file
|
||||
opts.CachedData, err = remotefetcher.LoadMetadataFromFile(path.Join(backyHomeConfDir, "cache.yml"))
|
||||
if err != nil {
|
||||
fmt.Println("Error loading metadata:", err)
|
||||
logging.ExitWithMSG(err.Error(), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
// Initialize cache with loaded metadata
|
||||
cache, err := remotefetcher.NewCache(path.Join(backyHomeConfDir, "cache.yml"), cacheDir)
|
||||
if err != nil {
|
||||
fmt.Println("Error initializing cache:", err)
|
||||
logging.ExitWithMSG(err.Error(), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
// Populate cache with loaded metadata
|
||||
for _, data := range opts.CachedData {
|
||||
if err := cache.AddDataToStore(data.Hash, *data); err != nil {
|
||||
logging.ExitWithMSG(err.Error(), 1, &opts.Logger)
|
||||
}
|
||||
}
|
||||
|
||||
opts.Cache, err = remotefetcher.NewCache(path.Join(backyHomeConfDir, "cache.yml"), backyHomeConfDir)
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error initializing cache: %v", err), 1, nil)
|
||||
}
|
||||
// Initialize the fetcher
|
||||
// println("Creating new fetcher for source", opts.ConfigFilePath)
|
||||
fetcher, err := remotefetcher.NewRemoteFetcher(opts.ConfigFilePath, opts.Cache)
|
||||
// println("Created new fetcher for source", opts.ConfigFilePath)
|
||||
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error initializing config fetcher: %v", err), 1, nil)
|
||||
}
|
||||
|
||||
if opts.ConfigFilePath != "" {
|
||||
loadConfigFile(fetcher, opts.ConfigFilePath, backyKoanf, opts)
|
||||
} else {
|
||||
loadDefaultConfigFiles(fetcher, configFiles, backyKoanf, opts)
|
||||
}
|
||||
|
||||
opts.koanf = backyKoanf
|
||||
}
|
||||
|
||||
func loadConfigFile(fetcher remotefetcher.RemoteFetcher, filePath string, k *koanf.Koanf, opts *ConfigOpts) {
|
||||
data, err := fetcher.Fetch(filePath)
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("Could not fetch config file %s: %v", filePath, err), 1, nil)
|
||||
}
|
||||
|
||||
if err := k.Load(rawbytes.Provider(data), yaml.Parser()); err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error loading config: %v", err), 1, &opts.Logger)
|
||||
}
|
||||
}
|
||||
|
||||
func loadDefaultConfigFiles(fetcher remotefetcher.RemoteFetcher, configFiles []string, k *koanf.Koanf, opts *ConfigOpts) {
|
||||
cFileFailures := 0
|
||||
for _, c := range configFiles {
|
||||
data, err := fetcher.Fetch(c)
|
||||
if err != nil {
|
||||
cFileFailures++
|
||||
continue
|
||||
}
|
||||
|
||||
if err := k.Load(rawbytes.Provider(data), yaml.Parser()); err != nil {
|
||||
cFileFailures++
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
if cFileFailures == len(configFiles) {
|
||||
logging.ExitWithMSG("Could not find any valid config file", 1, nil)
|
||||
}
|
||||
}
|
||||
|
||||
func (opts *ConfigOpts) ReadConfig() *ConfigOpts {
|
||||
setTerminalEnv()
|
||||
|
||||
backyKoanf := opts.koanf
|
||||
|
||||
opts.loadEnv()
|
||||
|
||||
if backyKoanf.Bool(getNestedConfig("logging", "cmd-std-out")) {
|
||||
os.Setenv("BACKY_STDOUT", "enabled")
|
||||
}
|
||||
|
||||
CheckConfigValues(backyKoanf, opts.ConfigFilePath)
|
||||
|
||||
validateCommands(backyKoanf, opts)
|
||||
|
||||
setLoggingOptions(backyKoanf, opts)
|
||||
|
||||
log := setupLogger(opts)
|
||||
opts.Logger = log
|
||||
|
||||
log.Info().Str("config file", opts.ConfigFilePath).Send()
|
||||
|
||||
unmarshalConfig(backyKoanf, "commands", &opts.Cmds, opts.Logger)
|
||||
|
||||
validateCommandEnvironments(opts)
|
||||
|
||||
unmarshalConfig(backyKoanf, "hosts", &opts.Hosts, opts.Logger)
|
||||
|
||||
resolveHostConfigs(opts)
|
||||
|
||||
loadCommandLists(opts, backyKoanf)
|
||||
|
||||
validateCommandLists(opts)
|
||||
|
||||
if opts.cronEnabled && len(opts.CmdConfigLists) == 0 {
|
||||
logging.ExitWithMSG("No cron fields detected in any command lists", 1, nil)
|
||||
}
|
||||
|
||||
if err := processCmds(opts); err != nil {
|
||||
logging.ExitWithMSG(err.Error(), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
filterExecuteLists(opts)
|
||||
|
||||
if backyKoanf.Exists("notifications") {
|
||||
unmarshalConfig(backyKoanf, "notifications", &opts.NotificationConf, opts.Logger)
|
||||
}
|
||||
|
||||
opts.SetupNotify()
|
||||
|
||||
if err := opts.setupVault(); err != nil {
|
||||
log.Err(err).Send()
|
||||
}
|
||||
|
||||
return opts
|
||||
}
|
||||
|
||||
func setTerminalEnv() {
|
||||
if isatty.IsTerminal(os.Stdout.Fd()) || isatty.IsCygwinTerminal(os.Stdout.Fd()) {
|
||||
os.Setenv("BACKY_TERM", "enabled")
|
||||
} else {
|
||||
os.Setenv("BACKY_TERM", "disabled")
|
||||
}
|
||||
}
|
||||
|
||||
func validateCommands(k *koanf.Koanf, opts *ConfigOpts) {
|
||||
for _, c := range opts.executeCmds {
|
||||
if !k.Exists(getCmdFromConfig(c)) {
|
||||
logging.ExitWithMSG(fmt.Sprintf("command %s is not in config file %s", c, opts.ConfigFilePath), 1, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func setLoggingOptions(k *koanf.Koanf, opts *ConfigOpts) {
|
||||
isLoggingVerbose := k.Bool(getLoggingKeyFromConfig("verbose"))
|
||||
|
||||
// if log file is set in config file and not set on command line, use "./backy.log"
|
||||
logFile := "./backy.log"
|
||||
if opts.LogFilePath == "" && k.Exists(getLoggingKeyFromConfig("file")) {
|
||||
logFile = k.String(getLoggingKeyFromConfig("file"))
|
||||
opts.LogFilePath = logFile
|
||||
}
|
||||
|
||||
zerolog.SetGlobalLevel(zerolog.InfoLevel)
|
||||
if isLoggingVerbose {
|
||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||
os.Setenv("BACKY_LOGLEVEL", fmt.Sprintf("%v", zerolog.GlobalLevel()))
|
||||
}
|
||||
|
||||
if k.Bool(getLoggingKeyFromConfig("console-disabled")) {
|
||||
os.Setenv("BACKY_CONSOLE_LOGGING", "")
|
||||
} else {
|
||||
os.Setenv("BACKY_CONSOLE_LOGGING", "enabled")
|
||||
}
|
||||
}
|
||||
|
||||
func setupLogger(opts *ConfigOpts) zerolog.Logger {
|
||||
writers := logging.SetLoggingWriters(opts.LogFilePath)
|
||||
return zerolog.New(writers).With().Timestamp().Logger()
|
||||
}
|
||||
|
||||
func unmarshalConfig(k *koanf.Koanf, key string, target interface{}, log zerolog.Logger) {
|
||||
if err := k.UnmarshalWithConf(key, target, koanf.UnmarshalConf{Tag: "yaml"}); err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error unmarshalling %s struct: %v", key, err), 1, &log)
|
||||
}
|
||||
}
|
||||
|
||||
func validateCommandEnvironments(opts *ConfigOpts) {
|
||||
for cmdName, cmdConf := range opts.Cmds {
|
||||
if err := testFile(cmdConf.Env); err != nil {
|
||||
opts.Logger.Info().Str("cmd", cmdName).Err(err).Send()
|
||||
os.Exit(1)
|
||||
}
|
||||
expandEnvVars(opts.backyEnv, cmdConf.Environment)
|
||||
}
|
||||
}
|
||||
|
||||
func resolveHostConfigs(opts *ConfigOpts) {
|
||||
for hostConfigName, host := range opts.Hosts {
|
||||
if host.Host == "" {
|
||||
host.Host = hostConfigName
|
||||
}
|
||||
if host.ProxyJump != "" {
|
||||
resolveProxyHosts(host, opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func resolveProxyHosts(host *Host, opts *ConfigOpts) {
|
||||
proxyHosts := strings.Split(host.ProxyJump, ",")
|
||||
for _, h := range proxyHosts {
|
||||
proxyHost, defined := opts.Hosts[h]
|
||||
if !defined {
|
||||
proxyHost = &Host{Host: h}
|
||||
opts.Hosts[h] = proxyHost
|
||||
}
|
||||
host.ProxyHost = append(host.ProxyHost, proxyHost)
|
||||
}
|
||||
}
|
||||
|
||||
func loadCommandLists(opts *ConfigOpts, backyKoanf *koanf.Koanf) {
|
||||
var backyConfigFileDir string
|
||||
var listConfigFiles []string
|
||||
var u *url.URL
|
||||
// if config file is remote, use the directory of the remote file
|
||||
if isRemoteURL(opts.ConfigFilePath) {
|
||||
_, u = getRemoteDir(opts.ConfigFilePath)
|
||||
listConfigFiles = []string{u.JoinPath("lists.yml").String(), u.JoinPath("lists.yaml").String()}
|
||||
} else {
|
||||
backyConfigFileDir = path.Dir(opts.ConfigFilePath)
|
||||
listConfigFiles = []string{
|
||||
path.Join(backyConfigFileDir, "lists.yml"),
|
||||
path.Join(backyConfigFileDir, "lists.yaml"),
|
||||
}
|
||||
}
|
||||
|
||||
listsConfig := koanf.New(".")
|
||||
|
||||
for _, l := range listConfigFiles {
|
||||
if loadListConfigFile(l, listsConfig, opts) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if backyKoanf.Exists("cmd-lists") {
|
||||
unmarshalConfig(backyKoanf, "cmd-lists", &opts.CmdConfigLists, opts.Logger)
|
||||
if backyKoanf.Exists("cmd-lists.file") {
|
||||
loadCmdListsFile(backyKoanf, listsConfig, opts)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func isRemoteURL(filePath string) bool {
|
||||
return strings.HasPrefix(filePath, "http://") || strings.HasPrefix(filePath, "https://") || strings.HasPrefix(filePath, "s3://")
|
||||
}
|
||||
|
||||
func getRemoteDir(filePath string) (string, *url.URL) {
|
||||
u, err := url.Parse(filePath)
|
||||
if err != nil {
|
||||
return "", nil
|
||||
}
|
||||
// u.Path is the path to the file, stripped of scheme and hostname
|
||||
u.Path = path.Dir(u.Path)
|
||||
|
||||
return u.String(), u
|
||||
}
|
||||
|
||||
func loadListConfigFile(filePath string, k *koanf.Koanf, opts *ConfigOpts) bool {
|
||||
fetcher, err := remotefetcher.NewRemoteFetcher(filePath, opts.Cache, remotefetcher.IgnoreFileNotFound())
|
||||
if err != nil {
|
||||
// if file not found, ignore
|
||||
if errors.Is(err, remotefetcher.ErrIgnoreFileNotFound) {
|
||||
return true
|
||||
}
|
||||
|
||||
logging.ExitWithMSG(fmt.Sprintf("error initializing config fetcher: %v", err), 1, nil)
|
||||
}
|
||||
|
||||
data, err := fetcher.Fetch(filePath)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if err := k.Load(rawbytes.Provider(data), yaml.Parser()); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
opts.CmdListFile = filePath
|
||||
return true
|
||||
}
|
||||
|
||||
func loadCmdListsFile(backyKoanf *koanf.Koanf, listsConfig *koanf.Koanf, opts *ConfigOpts) {
|
||||
opts.CmdListFile = strings.TrimSpace(backyKoanf.String("cmd-lists.file"))
|
||||
if !path.IsAbs(opts.CmdListFile) {
|
||||
opts.CmdListFile = path.Join(path.Dir(opts.ConfigFilePath), opts.CmdListFile)
|
||||
}
|
||||
|
||||
fetcher, err := remotefetcher.NewRemoteFetcher(opts.CmdListFile, opts.Cache)
|
||||
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error initializing config fetcher: %v", err), 1, nil)
|
||||
}
|
||||
|
||||
data, err := fetcher.Fetch(opts.CmdListFile)
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("Could not fetch config file %s: %v", opts.CmdListFile, err), 1, nil)
|
||||
}
|
||||
|
||||
if err := listsConfig.Load(rawbytes.Provider(data), yaml.Parser()); err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error loading config: %v", err), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
unmarshalConfig(listsConfig, "cmd-lists", &opts.CmdConfigLists, opts.Logger)
|
||||
opts.Logger.Info().Str("using lists config file", opts.CmdListFile).Send()
|
||||
}
|
||||
|
||||
func validateCommandLists(opts *ConfigOpts) {
|
||||
var cmdNotFoundSliceErr []error
|
||||
for cmdListName, cmdList := range opts.CmdConfigLists {
|
||||
if opts.cronEnabled && strings.TrimSpace(cmdList.Cron) == "" {
|
||||
delete(opts.CmdConfigLists, cmdListName)
|
||||
continue
|
||||
}
|
||||
for _, cmdInList := range cmdList.Order {
|
||||
if _, cmdNameFound := opts.Cmds[cmdInList]; !cmdNameFound {
|
||||
cmdNotFoundSliceErr = append(cmdNotFoundSliceErr, fmt.Errorf("command %s in list %s is not defined in commands section in config file", cmdInList, cmdListName))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if len(cmdNotFoundSliceErr) > 0 {
|
||||
opts.Logger.Fatal().Errs("commands not found", cmdNotFoundSliceErr).Send()
|
||||
}
|
||||
}
|
||||
|
||||
func filterExecuteLists(opts *ConfigOpts) {
|
||||
if len(opts.executeLists) > 0 {
|
||||
for l := range opts.CmdConfigLists {
|
||||
if !contains(opts.executeLists, l) {
|
||||
delete(opts.CmdConfigLists, l)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
func getNestedConfig(nestedConfig, key string) string {
|
||||
return fmt.Sprintf("%s.%s", nestedConfig, key)
|
||||
}
|
||||
|
||||
func getCmdFromConfig(key string) string {
|
||||
return fmt.Sprintf("commands.%s", key)
|
||||
}
|
||||
|
||||
func getLoggingKeyFromConfig(key string) string {
|
||||
if key == "" {
|
||||
return "logging"
|
||||
}
|
||||
return fmt.Sprintf("logging.%s", key)
|
||||
}
|
||||
|
||||
func getCmdListFromConfig(list string) string {
|
||||
return fmt.Sprintf("cmd-lists.%s", list)
|
||||
}
|
||||
|
||||
func (opts *ConfigOpts) setupVault() error {
|
||||
if !opts.koanf.Bool("vault.enabled") {
|
||||
return nil
|
||||
}
|
||||
config := vault.DefaultConfig()
|
||||
|
||||
config.Address = opts.koanf.String("vault.address")
|
||||
if strings.TrimSpace(config.Address) == "" {
|
||||
config.Address = os.Getenv("VAULT_ADDR")
|
||||
}
|
||||
|
||||
client, err := vault.NewClient(config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
token := opts.koanf.String("vault.token")
|
||||
if strings.TrimSpace(token) == "" {
|
||||
token = os.Getenv("VAULT_TOKEN")
|
||||
}
|
||||
if strings.TrimSpace(token) == "" {
|
||||
return fmt.Errorf("no token found, but one was required. \n\nSet the config key vault.token or the environment variable VAULT_TOKEN")
|
||||
}
|
||||
|
||||
client.SetToken(token)
|
||||
|
||||
unmarshalErr := opts.koanf.UnmarshalWithConf("vault.keys", &opts.VaultKeys, koanf.UnmarshalConf{Tag: "yaml"})
|
||||
if unmarshalErr != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error unmarshalling vault.keys into struct: %v", unmarshalErr), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
opts.vaultClient = client
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func getVaultSecret(vaultClient *vault.Client, key *VaultKey) (string, error) {
|
||||
var (
|
||||
secret *vault.KVSecret
|
||||
err error
|
||||
)
|
||||
|
||||
if key.ValueType == "KVv2" {
|
||||
secret, err = vaultClient.KVv2(key.MountPath).Get(context.Background(), key.Path)
|
||||
} else if key.ValueType == "KVv1" {
|
||||
secret, err = vaultClient.KVv1(key.MountPath).Get(context.Background(), key.Path)
|
||||
} else if key.ValueType != "" {
|
||||
return "", fmt.Errorf("type %s for key %s not known. Valid types are KVv1 or KVv2", key.ValueType, key.Name)
|
||||
} else {
|
||||
return "", fmt.Errorf("type for key %s must be specified. Valid types are KVv1 or KVv2", key.Name)
|
||||
|
||||
}
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("unable to read secret: %v", err)
|
||||
}
|
||||
|
||||
value, ok := secret.Data[key.Name].(string)
|
||||
if !ok {
|
||||
return "", fmt.Errorf("value type assertion failed: %T %#v", secret.Data[key.Name], secret.Data[key.Name])
|
||||
}
|
||||
|
||||
return value, nil
|
||||
}
|
||||
|
||||
func isVaultKey(str string) (string, bool) {
|
||||
str = strings.TrimSpace(str)
|
||||
return strings.TrimPrefix(str, "vault:"), strings.HasPrefix(str, "vault:")
|
||||
}
|
||||
|
||||
func parseVaultKey(str string, keys []*VaultKey) (*VaultKey, error) {
|
||||
keyName, isKey := isVaultKey(str)
|
||||
if !isKey {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
for _, k := range keys {
|
||||
if k.Name == keyName {
|
||||
return k, nil
|
||||
}
|
||||
}
|
||||
return nil, fmt.Errorf("key %s not found in vault keys", keyName)
|
||||
}
|
||||
|
||||
func GetVaultKey(str string, opts *ConfigOpts, log zerolog.Logger) string {
|
||||
key, err := parseVaultKey(str, opts.VaultKeys)
|
||||
if key == nil && err == nil {
|
||||
return str
|
||||
}
|
||||
if err != nil && key == nil {
|
||||
log.Err(err).Send()
|
||||
return ""
|
||||
}
|
||||
|
||||
value, secretErr := getVaultSecret(opts.vaultClient, key)
|
||||
if secretErr != nil {
|
||||
log.Err(secretErr).Send()
|
||||
return value
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
func processCmds(opts *ConfigOpts) error {
|
||||
|
||||
// process commands
|
||||
for cmdName, cmd := range opts.Cmds {
|
||||
|
||||
if cmd.Name == "" {
|
||||
cmd.Name = cmdName
|
||||
}
|
||||
// println("Cmd.Name = " + cmd.Name)
|
||||
hooks := cmd.Hooks
|
||||
// resolve hooks
|
||||
if hooks != nil {
|
||||
|
||||
processHookSuccess := processHooks(cmd, hooks.Error, opts, "error")
|
||||
if processHookSuccess != nil {
|
||||
return processHookSuccess
|
||||
}
|
||||
processHookSuccess = processHooks(cmd, hooks.Success, opts, "success")
|
||||
if processHookSuccess != nil {
|
||||
return processHookSuccess
|
||||
}
|
||||
processHookSuccess = processHooks(cmd, hooks.Final, opts, "final")
|
||||
if processHookSuccess != nil {
|
||||
return processHookSuccess
|
||||
}
|
||||
}
|
||||
|
||||
// resolve hosts
|
||||
if cmd.Host != nil {
|
||||
host, hostFound := opts.Hosts[*cmd.Host]
|
||||
if hostFound {
|
||||
cmd.RemoteHost = host
|
||||
cmd.RemoteHost.Host = host.Host
|
||||
if host.HostName != "" {
|
||||
cmd.RemoteHost.HostName = host.HostName
|
||||
}
|
||||
} else {
|
||||
opts.Hosts[*cmd.Host] = &Host{Host: *cmd.Host}
|
||||
cmd.RemoteHost = &Host{Host: *cmd.Host}
|
||||
}
|
||||
}
|
||||
|
||||
// Parse package commands
|
||||
if cmd.Type == "package" {
|
||||
if cmd.PackageManager == "" {
|
||||
return fmt.Errorf("package manager is required for package command %s", cmd.PackageName)
|
||||
}
|
||||
if cmd.PackageOperation == "" {
|
||||
return fmt.Errorf("package operation is required for package command %s", cmd.PackageName)
|
||||
}
|
||||
if cmd.PackageName == "" {
|
||||
return fmt.Errorf("package name is required for package command %s", cmd.PackageName)
|
||||
}
|
||||
var err error
|
||||
|
||||
// Validate the operation
|
||||
switch cmd.PackageOperation {
|
||||
case "install", "remove", "upgrade", "checkVersion":
|
||||
cmd.pkgMan, err = pkgman.PackageManagerFactory(cmd.PackageManager, pkgman.WithoutAuth())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported package operation %s for command %s", cmd.PackageOperation, cmd.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// Parse user commands
|
||||
if cmd.Type == "user" {
|
||||
if cmd.Username == "" {
|
||||
return fmt.Errorf("username is required for user command %s", cmd.Name)
|
||||
}
|
||||
|
||||
detectOSType(cmd, opts)
|
||||
var err error
|
||||
|
||||
// Validate the operation
|
||||
switch cmd.UserOperation {
|
||||
case "add", "remove", "modify", "checkIfExists", "delete", "password":
|
||||
cmd.userMan, err = usermanager.NewUserManager(cmd.OS)
|
||||
if cmd.Host != nil {
|
||||
host, ok := opts.Hosts[*cmd.Host]
|
||||
if ok {
|
||||
cmd.userMan, err = usermanager.NewUserManager(host.OS)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported user operation %s for command %s", cmd.UserOperation, cmd.Name)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if cmd.Type == "remoteScript" {
|
||||
if !isRemoteURL(cmd.Cmd) {
|
||||
return fmt.Errorf("remoteScript command %s must be a remote resource", cmdName)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// processHooks evaluates if hooks are valid Commands
|
||||
//
|
||||
// The cmd.hookRefs[hookType] is created with any hooks found.
|
||||
//
|
||||
// Returns an error, if any, if the hook command is not found
|
||||
func processHooks(cmd *Command, hooks []string, opts *ConfigOpts, hookType string) error {
|
||||
|
||||
// initialize hook type
|
||||
var hookCmdFound bool
|
||||
cmd.hookRefs = map[string]map[string]*Command{}
|
||||
cmd.hookRefs[hookType] = map[string]*Command{}
|
||||
|
||||
for _, hook := range hooks {
|
||||
|
||||
var hookCmd *Command
|
||||
// TODO: match by Command.Name
|
||||
|
||||
hookCmd, hookCmdFound = opts.Cmds[hook]
|
||||
|
||||
if !hookCmdFound {
|
||||
return fmt.Errorf("error in command %s hook %s list: command %s not found", cmd.Name, hookType, hook)
|
||||
}
|
||||
|
||||
cmd.hookRefs[hookType][hook] = hookCmd
|
||||
|
||||
// Recursive, decide if this is good
|
||||
// if hookCmd.hookRefs == nil {
|
||||
// }
|
||||
// hookRef[hookType][h] = hookCmd
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func detectOSType(cmd *Command, opts *ConfigOpts) error {
|
||||
if cmd.Host == nil {
|
||||
if runtime.GOOS == "linux" { // also can be specified to FreeBSD
|
||||
cmd.OS = "linux"
|
||||
opts.Logger.Info().Msg("Unix/Linux type OS detected")
|
||||
}
|
||||
}
|
||||
host, ok := opts.Hosts[*cmd.Host]
|
||||
if ok {
|
||||
if host.OS != "" {
|
||||
return nil
|
||||
}
|
||||
|
||||
os, err := host.DetectOS(opts)
|
||||
os = strings.TrimSpace(os)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if os == "" {
|
||||
return fmt.Errorf("error detecting os for command %s: empty string", cmd.Name)
|
||||
}
|
||||
if strings.Contains(os, "linux") {
|
||||
os = "linux"
|
||||
}
|
||||
host.OS = os
|
||||
}
|
||||
return nil
|
||||
}
|
38
pkg/backy/cron.go
Normal file
38
pkg/backy/cron.go
Normal file
@ -0,0 +1,38 @@
|
||||
// cron.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package backy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"github.com/go-co-op/gocron"
|
||||
)
|
||||
|
||||
func (opts *ConfigOpts) Cron() {
|
||||
s := gocron.NewScheduler(time.Local)
|
||||
s.TagsUnique()
|
||||
cmdLists := opts.CmdConfigLists
|
||||
for listName, config := range cmdLists {
|
||||
if config.Name == "" {
|
||||
config.Name = listName
|
||||
}
|
||||
|
||||
cron := strings.TrimSpace(config.Cron)
|
||||
if cron != "" {
|
||||
opts.Logger.Info().Str("Scheduling cron list", config.Name).Str("Time", cron).Send()
|
||||
_, err := s.CronWithSeconds(cron).Tag(config.Name).Do(func(cron string) {
|
||||
opts.RunListConfig(cron)
|
||||
}, cron)
|
||||
if err != nil {
|
||||
logging.ExitWithMSG(fmt.Sprintf("error: %v", err), 1, &opts.Logger)
|
||||
}
|
||||
}
|
||||
}
|
||||
opts.Logger.Info().Msg("Starting cron mode...")
|
||||
s.StartBlocking()
|
||||
}
|
68
pkg/backy/list.go
Normal file
68
pkg/backy/list.go
Normal file
@ -0,0 +1,68 @@
|
||||
package backy
|
||||
|
||||
import "fmt"
|
||||
|
||||
/*
|
||||
Command: command [args...]
|
||||
Host: Local or remote (list the name)
|
||||
|
||||
List: name
|
||||
Commands:
|
||||
flags: list commands
|
||||
if listcommands: (use list command)
|
||||
Command: command [args...]
|
||||
Host: Local or remote (list the name)
|
||||
|
||||
*/
|
||||
|
||||
// ListCommand searches the commands in the file to find one
|
||||
func (opts *ConfigOpts) ListCommand(cmd string) {
|
||||
// bool for commands not found
|
||||
// gets set to false if a command is not found
|
||||
// set to true if the command is found
|
||||
var cmdFound bool = false
|
||||
var cmdInfo *Command
|
||||
// check commands in file against cmd
|
||||
for _, cmdInFile := range opts.executeCmds {
|
||||
print(cmdInFile)
|
||||
cmdFound = false
|
||||
|
||||
if cmd == cmdInFile {
|
||||
cmdFound = true
|
||||
cmdInfo = opts.Cmds[cmd]
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// print the command's information
|
||||
if cmdFound {
|
||||
|
||||
print("Command: ")
|
||||
|
||||
print(cmdInfo.Cmd)
|
||||
if len(cmdInfo.Args) >= 0 {
|
||||
|
||||
for _, v := range cmdInfo.Args {
|
||||
print(" ") // print space between command and args
|
||||
print(v) // print command arg
|
||||
}
|
||||
}
|
||||
|
||||
// is is remote or local
|
||||
if cmdInfo.Host != nil {
|
||||
|
||||
print("Host: ", cmdInfo.Host)
|
||||
|
||||
} else {
|
||||
|
||||
print("Host: Runs on Local Machine\n\n")
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
fmt.Printf("Command %s not found. Check spelling.\n", cmd)
|
||||
|
||||
}
|
||||
|
||||
}
|
101
pkg/backy/notification.go
Normal file
101
pkg/backy/notification.go
Normal file
@ -0,0 +1,101 @@
|
||||
// notification.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
package backy
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"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 `yaml:"homeserver"`
|
||||
Roomid id.RoomID `yaml:"room-id"`
|
||||
AccessToken string `yaml:"access-token"`
|
||||
UserId id.UserID `yaml:"user-id"`
|
||||
}
|
||||
|
||||
type MailConfig struct {
|
||||
Host string `yaml:"host"`
|
||||
Port string `yaml:"port"`
|
||||
Username string `yaml:"username"`
|
||||
SenderAddress string `yaml:"senderaddress"`
|
||||
To []string `yaml:"to"`
|
||||
Password string `yaml:"password"`
|
||||
}
|
||||
|
||||
// SetupNotify sets up notify instances for each command list.
|
||||
func (opts *ConfigOpts) SetupNotify() {
|
||||
|
||||
// check if we have individual commands instead of lists to execute
|
||||
if len(opts.executeCmds) != 0 {
|
||||
return
|
||||
}
|
||||
|
||||
for confName, cmdConfig := range opts.CmdConfigLists {
|
||||
|
||||
var services []notify.Notifier
|
||||
for _, id := range cmdConfig.Notifications {
|
||||
if !strings.Contains(id, ".") {
|
||||
opts.Logger.Info().Str("id", id).Str("list", cmdConfig.Name).Msg("key does not contain a \".\" Make sure to follow the docs: https://backy.cybershell.xyz/config/notifications/")
|
||||
logging.ExitWithMSG(fmt.Sprintf("notification id %s in cmd list %s does not contain a \".\" \nMake sure to follow the docs: https://backy.cybershell.xyz/config/notifications/", id, cmdConfig.Name), 1, &opts.Logger)
|
||||
}
|
||||
|
||||
confSplit := strings.Split(id, ".")
|
||||
confType := confSplit[0]
|
||||
confId := confSplit[1]
|
||||
switch confType {
|
||||
|
||||
case "mail":
|
||||
conf, ok := opts.NotificationConf.MailConfig[confId]
|
||||
if !ok {
|
||||
opts.Logger.Info().Err(fmt.Errorf("error: ID %s not found in mail object", confId)).Str("list", confName).Send()
|
||||
continue
|
||||
}
|
||||
mailConf := setupMail(conf)
|
||||
services = append(services, mailConf)
|
||||
case "matrix":
|
||||
conf, ok := opts.NotificationConf.MatrixConfig[confId]
|
||||
if !ok {
|
||||
opts.Logger.Info().Err(fmt.Errorf("error: ID %s not found in matrix object", confId)).Str("list", confName).Send()
|
||||
continue
|
||||
}
|
||||
mtrxConf, mtrxErr := setupMatrix(conf)
|
||||
if mtrxErr != nil {
|
||||
opts.Logger.Info().Str("list", confName).Err(fmt.Errorf("error: configuring matrix id %s failed during setup: %w", id, mtrxErr))
|
||||
continue
|
||||
}
|
||||
// append the services
|
||||
services = append(services, mtrxConf)
|
||||
// service is not recognized
|
||||
default:
|
||||
opts.Logger.Info().Err(fmt.Errorf("id %s not found", id)).Str("list", confName).Send()
|
||||
}
|
||||
}
|
||||
cmdConfig.NotifyConfig = notify.NewWithServices(services...)
|
||||
}
|
||||
|
||||
// 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 {
|
||||
return nil, 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...)
|
||||
mailClient.BodyFormat(mail.PlainText)
|
||||
return mailClient
|
||||
}
|
836
pkg/backy/ssh.go
836
pkg/backy/ssh.go
@ -1,156 +1,768 @@
|
||||
// ssh.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package backy
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"io"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/kevinburke/ssh_config"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"golang.org/x/crypto/ssh/knownhosts"
|
||||
)
|
||||
|
||||
type SshConfig struct {
|
||||
// Config file to open
|
||||
configFile string
|
||||
var PrivateKeyExtraInfoErr = errors.New("Private key may be encrypted. \nIf encrypted, make sure the password is specified correctly in the correct section. This may be done in one of three ways: \n privatekeypassword: env:PR_KEY_PASS \n privatekeypassword: file:/path/to/password-file \n privatekeypassword: password (not recommended). \n ")
|
||||
var TS = strings.TrimSpace
|
||||
|
||||
// Private key path
|
||||
privateKey string
|
||||
// ConnectToHost connects to a host by looking up the config values in the file ~/.ssh/config
|
||||
// It uses any set values and looks up an unset values in the config files
|
||||
// remoteConfig is modified directly. The *ssh.Client is returned as part of remoteConfig,
|
||||
// If configFile is empty, any required configuration is looked up in the default config files
|
||||
// If any value is not found, defaults are used
|
||||
func (remoteConfig *Host) ConnectToHost(opts *ConfigOpts) error {
|
||||
|
||||
// Port to connect to
|
||||
port uint16
|
||||
|
||||
// host to check
|
||||
host string
|
||||
|
||||
// host name to connect to
|
||||
hostName []string
|
||||
|
||||
user string
|
||||
}
|
||||
|
||||
func (config SshConfig) GetSSHConfig() (SshConfig, error) {
|
||||
hostNames := ssh_config.GetAll(config.host, "HostName")
|
||||
if hostNames == nil {
|
||||
return SshConfig{}, errors.New("hostname not found")
|
||||
}
|
||||
config.hostName = hostNames
|
||||
privKey, err := ssh_config.GetStrict(config.host, "IdentityFile")
|
||||
if err != nil {
|
||||
return SshConfig{}, err
|
||||
}
|
||||
config.privateKey = privKey
|
||||
User := ssh_config.Get(config.host, "User")
|
||||
if User == "" {
|
||||
return SshConfig{}, errors.New("user not found")
|
||||
}
|
||||
return config, nil
|
||||
}
|
||||
|
||||
func (remoteConfig *Host) ConnectToSSHHost() (*ssh.Client, error) {
|
||||
|
||||
var sshClient *ssh.Client
|
||||
var connectErr error
|
||||
|
||||
f, _ := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "config"))
|
||||
cfg, _ := ssh_config.Decode(f)
|
||||
for _, host := range cfg.Hosts {
|
||||
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:])
|
||||
if TS(remoteConfig.ConfigFilePath) == "" {
|
||||
remoteConfig.useDefaultConfig = true
|
||||
}
|
||||
remoteConfig.PrivateKeyPath = filepath.Join(identityFile)
|
||||
|
||||
khPathErr := remoteConfig.GetKnownHosts()
|
||||
|
||||
if khPathErr != nil {
|
||||
return khPathErr
|
||||
}
|
||||
remoteConfig.HostName, _ = cfg.GetAll(remoteConfig.Host, "HostName")
|
||||
if remoteConfig.HostName == nil {
|
||||
port, _ := cfg.Get(remoteConfig.Host, "Port")
|
||||
if port == "" {
|
||||
port = "22"
|
||||
|
||||
if remoteConfig.ClientConfig == nil {
|
||||
remoteConfig.ClientConfig = &ssh.ClientConfig{}
|
||||
}
|
||||
|
||||
var configFile *os.File
|
||||
|
||||
var sshConfigFileOpenErr error
|
||||
|
||||
if !remoteConfig.useDefaultConfig {
|
||||
var err error
|
||||
remoteConfig.ConfigFilePath, err = resolveDir(remoteConfig.ConfigFilePath)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
configFile, sshConfigFileOpenErr = os.Open(remoteConfig.ConfigFilePath)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
remoteConfig.HostName[0] = remoteConfig.Host + ":" + port
|
||||
} else {
|
||||
for index, hostName := range remoteConfig.HostName {
|
||||
port, _ := cfg.Get(remoteConfig.Host, "Port")
|
||||
defaultConfig, _ := resolveDir("~/.ssh/config")
|
||||
configFile, sshConfigFileOpenErr = os.Open(defaultConfig)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
}
|
||||
remoteConfig.SSHConfigFile = &sshConfigFile{}
|
||||
remoteConfig.SSHConfigFile.DefaultUserSettings = ssh_config.DefaultUserSettings
|
||||
var decodeErr error
|
||||
remoteConfig.SSHConfigFile.SshConfigFile, decodeErr = ssh_config.Decode(configFile)
|
||||
if decodeErr != nil {
|
||||
return decodeErr
|
||||
}
|
||||
|
||||
err := remoteConfig.GetProxyJumpFromConfig(opts.Hosts)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if remoteConfig.ProxyHost != nil {
|
||||
for _, proxyHost := range remoteConfig.ProxyHost {
|
||||
err := proxyHost.GetProxyJumpConfig(opts.Hosts, opts)
|
||||
opts.Logger.Info().Msgf("Proxy host: %s", proxyHost.Host)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
remoteConfig.ClientConfig.Timeout = time.Second * 30
|
||||
|
||||
remoteConfig.GetPrivateKeyFileFromConfig()
|
||||
|
||||
remoteConfig.GetPort()
|
||||
|
||||
remoteConfig.GetHostName()
|
||||
|
||||
remoteConfig.CombineHostNameWithPort()
|
||||
|
||||
remoteConfig.GetSshUserFromConfig()
|
||||
|
||||
if remoteConfig.HostName == "" {
|
||||
return errors.Errorf("No hostname found or specified for host %s", remoteConfig.Host)
|
||||
}
|
||||
|
||||
err = remoteConfig.GetAuthMethods(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hostKeyCallback, err := knownhosts.New(remoteConfig.KnownHostsFile)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "could not create hostkeycallback function")
|
||||
}
|
||||
remoteConfig.ClientConfig.HostKeyCallback = hostKeyCallback
|
||||
// opts.Logger.Info().Str("user", remoteConfig.ClientConfig.User).Send()
|
||||
|
||||
remoteConfig.SshClient, connectErr = remoteConfig.ConnectThroughBastion(opts.Logger)
|
||||
if connectErr != nil {
|
||||
return connectErr
|
||||
}
|
||||
if remoteConfig.SshClient != nil {
|
||||
opts.Hosts[remoteConfig.Host] = remoteConfig
|
||||
return nil
|
||||
}
|
||||
|
||||
opts.Logger.Info().Msgf("Connecting to host %s", remoteConfig.HostName)
|
||||
remoteConfig.SshClient, connectErr = ssh.Dial("tcp", remoteConfig.HostName, remoteConfig.ClientConfig)
|
||||
if connectErr != nil {
|
||||
return connectErr
|
||||
}
|
||||
|
||||
opts.Hosts[remoteConfig.Host] = remoteConfig
|
||||
return nil
|
||||
}
|
||||
|
||||
func (remoteHost *Host) GetSshUserFromConfig() {
|
||||
|
||||
if TS(remoteHost.User) == "" {
|
||||
|
||||
remoteHost.User, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "User")
|
||||
|
||||
if TS(remoteHost.User) == "" {
|
||||
|
||||
remoteHost.User = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "User")
|
||||
|
||||
if TS(remoteHost.User) == "" {
|
||||
|
||||
currentUser, _ := user.Current()
|
||||
|
||||
remoteHost.User = currentUser.Username
|
||||
}
|
||||
}
|
||||
}
|
||||
remoteHost.ClientConfig.User = remoteHost.User
|
||||
}
|
||||
|
||||
func (remoteHost *Host) GetAuthMethods(opts *ConfigOpts) error {
|
||||
var signer ssh.Signer
|
||||
var err error
|
||||
var privateKey []byte
|
||||
|
||||
remoteHost.Password = strings.TrimSpace(remoteHost.Password)
|
||||
|
||||
remoteHost.PrivateKeyPassword = strings.TrimSpace(remoteHost.PrivateKeyPassword)
|
||||
|
||||
remoteHost.PrivateKeyPath = strings.TrimSpace(remoteHost.PrivateKeyPath)
|
||||
|
||||
if remoteHost.PrivateKeyPath != "" {
|
||||
|
||||
privateKey, err = os.ReadFile(remoteHost.PrivateKeyPath)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
remoteHost.PrivateKeyPassword, err = GetPrivateKeyPassword(remoteHost.PrivateKeyPassword, opts, opts.Logger)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if remoteHost.PrivateKeyPassword == "" {
|
||||
|
||||
signer, err = ssh.ParsePrivateKey(privateKey)
|
||||
|
||||
if err != nil {
|
||||
return errors.Errorf("Failed to open private key file %s: %v \n\n %v", remoteHost.PrivateKeyPath, err, PrivateKeyExtraInfoErr)
|
||||
}
|
||||
|
||||
remoteHost.ClientConfig.Auth = []ssh.AuthMethod{ssh.PublicKeys(signer)}
|
||||
} else {
|
||||
|
||||
signer, err = ssh.ParsePrivateKeyWithPassphrase(privateKey, []byte(remoteHost.PrivateKeyPassword))
|
||||
|
||||
if err != nil {
|
||||
return errors.Errorf("Failed to open private key file %s: %v \n\n %v", remoteHost.PrivateKeyPath, err, PrivateKeyExtraInfoErr)
|
||||
}
|
||||
|
||||
remoteHost.ClientConfig.Auth = []ssh.AuthMethod{ssh.PublicKeys(signer)}
|
||||
}
|
||||
}
|
||||
|
||||
if remoteHost.Password == "" {
|
||||
|
||||
remoteHost.Password, err = GetPassword(remoteHost.Password, opts, opts.Logger)
|
||||
|
||||
if err != nil {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
remoteHost.ClientConfig.Auth = append(remoteHost.ClientConfig.Auth, ssh.Password(remoteHost.Password))
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetPrivateKeyFromConfig checks to see if the privateKeyPath is empty.
|
||||
// If not, it keeps the value.
|
||||
// If empty, the key is looked for in the specified config file.
|
||||
// If that path is empty, the default config file is searched.
|
||||
// If not found in the default file, the privateKeyPath is set to ~/.ssh/id_rsa
|
||||
func (remoteHost *Host) GetPrivateKeyFileFromConfig() {
|
||||
var identityFile string
|
||||
if remoteHost.PrivateKeyPath == "" {
|
||||
identityFile, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "IdentityFile")
|
||||
if identityFile == "" {
|
||||
identityFile, _ = remoteHost.SSHConfigFile.DefaultUserSettings.GetStrict(remoteHost.Host, "IdentityFile")
|
||||
if identityFile == "" {
|
||||
identityFile = "~/.ssh/id_rsa"
|
||||
}
|
||||
}
|
||||
}
|
||||
if identityFile == "" {
|
||||
identityFile = remoteHost.PrivateKeyPath
|
||||
}
|
||||
|
||||
remoteHost.PrivateKeyPath, _ = resolveDir(identityFile)
|
||||
}
|
||||
|
||||
// GetPort checks if the port from the config file is 0
|
||||
// If it is the port is searched in the SSH config file(s)
|
||||
func (remoteHost *Host) GetPort() {
|
||||
port := fmt.Sprintf("%d", remoteHost.Port)
|
||||
// port specifed?
|
||||
// port will be 0 if missing from backy config
|
||||
if port == "0" {
|
||||
// get port from specified SSH config file
|
||||
port, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "Port")
|
||||
|
||||
if port == "" {
|
||||
|
||||
// get port from default SSH config file
|
||||
port = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "Port")
|
||||
|
||||
// set port to be default
|
||||
if port == "" {
|
||||
port = "22"
|
||||
}
|
||||
remoteConfig.HostName[index] = hostName + ":" + port
|
||||
println("HostName: " + remoteConfig.HostName[0])
|
||||
}
|
||||
}
|
||||
hostKey := getHostKey(remoteConfig.Host)
|
||||
|
||||
privateKey, err := os.ReadFile(remoteConfig.PrivateKeyPath)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read private key error: %w", err)
|
||||
}
|
||||
signer, err := ssh.ParsePrivateKey(privateKey)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("parse private key error: %w", err)
|
||||
}
|
||||
sshConfig := &ssh.ClientConfig{
|
||||
User: remoteConfig.User,
|
||||
Auth: []ssh.AuthMethod{ssh.PublicKeys(signer)},
|
||||
HostKeyCallback: ssh.FixedHostKey(hostKey),
|
||||
}
|
||||
for _, host := range remoteConfig.HostName {
|
||||
println("Connecting to " + host)
|
||||
sshClient, connectErr = ssh.Dial("tcp", host, sshConfig)
|
||||
if connectErr != nil {
|
||||
continue
|
||||
// panic(fmt.Errorf("error when connecting to host %s: %w", host, connectErr))
|
||||
}
|
||||
}
|
||||
break
|
||||
portNum, _ := strconv.ParseUint(port, 10, 16)
|
||||
remoteHost.Port = uint16(portNum)
|
||||
}
|
||||
|
||||
}
|
||||
return sshClient, connectErr
|
||||
func (remoteHost *Host) CombineHostNameWithPort() {
|
||||
|
||||
// if the port is already in the HostName, leave it
|
||||
if strings.HasSuffix(remoteHost.HostName, fmt.Sprintf(":%d", remoteHost.Port)) {
|
||||
return
|
||||
}
|
||||
|
||||
func getHostKey(host string) ssh.PublicKey {
|
||||
// parse OpenSSH known_hosts file
|
||||
// ssh or use ssh-keyscan to get initial key
|
||||
file, err := os.Open(filepath.Join(os.Getenv("HOME"), ".ssh", "known_hosts"))
|
||||
remoteHost.HostName = fmt.Sprintf("%s:%d", remoteHost.HostName, remoteHost.Port)
|
||||
}
|
||||
|
||||
func (remoteHost *Host) GetHostName() {
|
||||
|
||||
if remoteHost.HostName == "" {
|
||||
remoteHost.HostName, _ = remoteHost.SSHConfigFile.SshConfigFile.Get(remoteHost.Host, "HostName")
|
||||
if remoteHost.HostName == "" {
|
||||
remoteHost.HostName = remoteHost.SSHConfigFile.DefaultUserSettings.Get(remoteHost.Host, "HostName")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (remoteHost *Host) ConnectThroughBastion(log zerolog.Logger) (*ssh.Client, error) {
|
||||
if remoteHost.ProxyHost == nil {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Info().Msgf("Connecting to proxy host %s", remoteHost.ProxyHost[0].HostName)
|
||||
|
||||
// connect to the bastion host
|
||||
bClient, err := ssh.Dial("tcp", remoteHost.ProxyHost[0].HostName, remoteHost.ProxyHost[0].ClientConfig)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return nil, err
|
||||
}
|
||||
remoteHost.ProxyHost[0].SshClient = bClient
|
||||
|
||||
// Dial a connection to the service host, from the bastion
|
||||
conn, err := bClient.Dial("tcp", remoteHost.HostName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
log.Info().Msgf("Connecting to host %s", remoteHost.HostName)
|
||||
ncc, chans, reqs, err := ssh.NewClientConn(conn, remoteHost.HostName, remoteHost.ClientConfig)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// sClient is an ssh client connected to the service host, through the bastion host.
|
||||
sClient := ssh.NewClient(ncc, chans, reqs)
|
||||
|
||||
return sClient, nil
|
||||
}
|
||||
|
||||
// GetKnownHosts resolves the host's KnownHosts file if it is defined
|
||||
// if not defined, the default location for this file is used
|
||||
func (remotehHost *Host) GetKnownHosts() error {
|
||||
var knownHostsFileErr error
|
||||
if TS(remotehHost.KnownHostsFile) != "" {
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = resolveDir(remotehHost.KnownHostsFile)
|
||||
return knownHostsFileErr
|
||||
}
|
||||
remotehHost.KnownHostsFile, knownHostsFileErr = resolveDir("~/.ssh/known_hosts")
|
||||
return knownHostsFileErr
|
||||
}
|
||||
|
||||
func GetPrivateKeyPassword(key string, opts *ConfigOpts, log zerolog.Logger) (string, error) {
|
||||
|
||||
var prKeyPassword string
|
||||
if strings.HasPrefix(key, "file:") {
|
||||
privKeyPassFilePath := strings.TrimPrefix(key, "file:")
|
||||
privKeyPassFilePath, _ = resolveDir(privKeyPassFilePath)
|
||||
keyFile, keyFileErr := os.Open(privKeyPassFilePath)
|
||||
if keyFileErr != nil {
|
||||
return "", errors.Errorf("Private key password file %s failed to open. \n Make sure it is accessible and correct.", privKeyPassFilePath)
|
||||
}
|
||||
passwordScanner := bufio.NewScanner(keyFile)
|
||||
for passwordScanner.Scan() {
|
||||
prKeyPassword = passwordScanner.Text()
|
||||
}
|
||||
} else if strings.HasPrefix(key, "env:") {
|
||||
privKey := strings.TrimPrefix(key, "env:")
|
||||
privKey = strings.TrimPrefix(privKey, "${")
|
||||
privKey = strings.TrimSuffix(privKey, "}")
|
||||
privKey = strings.TrimPrefix(privKey, "$")
|
||||
prKeyPassword = os.Getenv(privKey)
|
||||
} else {
|
||||
prKeyPassword = key
|
||||
}
|
||||
prKeyPassword = GetVaultKey(prKeyPassword, opts, opts.Logger)
|
||||
return prKeyPassword, nil
|
||||
}
|
||||
|
||||
// GetPassword gets any password
|
||||
func GetPassword(pass string, opts *ConfigOpts, log zerolog.Logger) (string, error) {
|
||||
|
||||
pass = strings.TrimSpace(pass)
|
||||
if pass == "" {
|
||||
return "", nil
|
||||
}
|
||||
var password string
|
||||
if strings.HasPrefix(pass, "file:") {
|
||||
passFilePath := strings.TrimPrefix(pass, "file:")
|
||||
passFilePath, _ = resolveDir(passFilePath)
|
||||
keyFile, keyFileErr := os.Open(passFilePath)
|
||||
if keyFileErr != nil {
|
||||
return "", errors.New("Password file failed to open")
|
||||
}
|
||||
passwordScanner := bufio.NewScanner(keyFile)
|
||||
for passwordScanner.Scan() {
|
||||
password = passwordScanner.Text()
|
||||
}
|
||||
} else if strings.HasPrefix(pass, "env:") {
|
||||
passEnv := strings.TrimPrefix(pass, "env:")
|
||||
passEnv = strings.TrimPrefix(passEnv, "${")
|
||||
passEnv = strings.TrimSuffix(passEnv, "}")
|
||||
passEnv = strings.TrimPrefix(passEnv, "$")
|
||||
password = os.Getenv(passEnv)
|
||||
} else {
|
||||
password = pass
|
||||
}
|
||||
password = GetVaultKey(password, opts, opts.Logger)
|
||||
|
||||
return password, nil
|
||||
}
|
||||
|
||||
func (remoteConfig *Host) GetProxyJumpFromConfig(hosts map[string]*Host) error {
|
||||
|
||||
proxyJump, _ := remoteConfig.SSHConfigFile.SshConfigFile.Get(remoteConfig.Host, "ProxyJump")
|
||||
if proxyJump == "" {
|
||||
proxyJump = remoteConfig.SSHConfigFile.DefaultUserSettings.Get(remoteConfig.Host, "ProxyJump")
|
||||
}
|
||||
if remoteConfig.ProxyJump == "" && proxyJump != "" {
|
||||
remoteConfig.ProxyJump = proxyJump
|
||||
}
|
||||
proxyJumpHosts := strings.Split(remoteConfig.ProxyJump, ",")
|
||||
if remoteConfig.ProxyHost == nil && len(proxyJumpHosts) == 1 {
|
||||
remoteConfig.ProxyJump = proxyJump
|
||||
proxyHost, proxyHostFound := hosts[proxyJump]
|
||||
if proxyHostFound {
|
||||
remoteConfig.ProxyHost = append(remoteConfig.ProxyHost, proxyHost)
|
||||
} else {
|
||||
if proxyJump != "" {
|
||||
newProxy := &Host{Host: proxyJump}
|
||||
remoteConfig.ProxyHost = append(remoteConfig.ProxyHost, newProxy)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (remoteConfig *Host) GetProxyJumpConfig(hosts map[string]*Host, opts *ConfigOpts) error {
|
||||
|
||||
if TS(remoteConfig.ConfigFilePath) == "" {
|
||||
remoteConfig.useDefaultConfig = true
|
||||
}
|
||||
|
||||
khPathErr := remoteConfig.GetKnownHosts()
|
||||
|
||||
if khPathErr != nil {
|
||||
return khPathErr
|
||||
}
|
||||
if remoteConfig.ClientConfig == nil {
|
||||
remoteConfig.ClientConfig = &ssh.ClientConfig{}
|
||||
}
|
||||
var configFile *os.File
|
||||
var sshConfigFileOpenErr error
|
||||
if !remoteConfig.useDefaultConfig {
|
||||
|
||||
configFile, sshConfigFileOpenErr = os.Open(remoteConfig.ConfigFilePath)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
} else {
|
||||
defaultConfig, _ := resolveDir("~/.ssh/config")
|
||||
configFile, sshConfigFileOpenErr = os.Open(defaultConfig)
|
||||
if sshConfigFileOpenErr != nil {
|
||||
return sshConfigFileOpenErr
|
||||
}
|
||||
}
|
||||
remoteConfig.SSHConfigFile = &sshConfigFile{}
|
||||
remoteConfig.SSHConfigFile.DefaultUserSettings = ssh_config.DefaultUserSettings
|
||||
var decodeErr error
|
||||
remoteConfig.SSHConfigFile.SshConfigFile, decodeErr = ssh_config.Decode(configFile)
|
||||
if decodeErr != nil {
|
||||
return decodeErr
|
||||
}
|
||||
remoteConfig.GetPrivateKeyFileFromConfig()
|
||||
remoteConfig.GetPort()
|
||||
remoteConfig.GetHostName()
|
||||
remoteConfig.CombineHostNameWithPort()
|
||||
remoteConfig.GetSshUserFromConfig()
|
||||
remoteConfig.isProxyHost = true
|
||||
if remoteConfig.HostName == "" {
|
||||
return errors.Errorf("No hostname found or specified for host %s", remoteConfig.Host)
|
||||
}
|
||||
err := remoteConfig.GetAuthMethods(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: Add value/option to config for host key and add bool to check for host key
|
||||
hostKeyCallback, err := knownhosts.New(remoteConfig.KnownHostsFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("could not create hostkeycallback function: %v", err)
|
||||
}
|
||||
remoteConfig.ClientConfig.HostKeyCallback = hostKeyCallback
|
||||
hosts[remoteConfig.Host] = remoteConfig
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RunCmdSSH runs commands over SSH.
|
||||
func (command *Command) RunCmdSSH(cmdCtxLogger zerolog.Logger, opts *ConfigOpts) ([]string, error) {
|
||||
var (
|
||||
ArgsStr string
|
||||
cmdOutBuf bytes.Buffer
|
||||
cmdOutWriters io.Writer
|
||||
|
||||
envVars = environmentVars{
|
||||
file: command.Env,
|
||||
env: command.Environment,
|
||||
}
|
||||
)
|
||||
// Get the command type
|
||||
// This must be done before concatenating the arguments
|
||||
command.Type = strings.TrimSpace(command.Type)
|
||||
command = getCommandType(command)
|
||||
|
||||
// Prepare command arguments
|
||||
for _, v := range command.Args {
|
||||
ArgsStr += fmt.Sprintf(" %s", v)
|
||||
}
|
||||
|
||||
cmdCtxLogger.Info().
|
||||
Str("Command", command.Name).
|
||||
Str("Host", *command.Host).
|
||||
Msgf("Running %s on host %s", getCommandTypeLabel(command.Type), *command.Host)
|
||||
|
||||
// cmdCtxLogger.Debug().Str("cmd", command.Cmd).Strs("args", command.Args).Send()
|
||||
|
||||
// Ensure SSH client is connected
|
||||
if command.RemoteHost.SshClient == nil {
|
||||
if err := command.RemoteHost.ConnectToHost(opts); err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to host: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
// Create new SSH session
|
||||
commandSession, err := command.RemoteHost.createSSHSession(opts)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create SSH session: %w", err)
|
||||
}
|
||||
defer commandSession.Close()
|
||||
|
||||
// Inject environment variables
|
||||
injectEnvIntoSSH(envVars, commandSession, opts, cmdCtxLogger)
|
||||
|
||||
// Set output writers
|
||||
cmdOutWriters = io.MultiWriter(&cmdOutBuf)
|
||||
if IsCmdStdOutEnabled() {
|
||||
cmdOutWriters = io.MultiWriter(os.Stdout, &cmdOutBuf)
|
||||
}
|
||||
commandSession.Stdout = cmdOutWriters
|
||||
commandSession.Stderr = cmdOutWriters
|
||||
|
||||
// Handle command execution based on type
|
||||
switch command.Type {
|
||||
case "script":
|
||||
return command.runScript(commandSession, cmdCtxLogger, &cmdOutBuf)
|
||||
case "scriptFile":
|
||||
return command.runScriptFile(commandSession, cmdCtxLogger, &cmdOutBuf)
|
||||
case "package":
|
||||
if command.PackageOperation == "checkVersion" {
|
||||
commandSession.Stderr = nil
|
||||
// Execute the package version command remotely
|
||||
// Parse the output of package version command
|
||||
// Compare versions
|
||||
// Check if a specific version is specified
|
||||
commandSession.Stdout = nil
|
||||
return checkPackageVersion(cmdCtxLogger, command, commandSession, cmdOutBuf)
|
||||
} else {
|
||||
if command.Shell != "" {
|
||||
ArgsStr = fmt.Sprintf("%s -c '%s %s'", command.Shell, command.Cmd, ArgsStr)
|
||||
} else {
|
||||
ArgsStr = fmt.Sprintf("%s %s", command.Cmd, ArgsStr)
|
||||
}
|
||||
cmdCtxLogger.Debug().Str("cmd + args", ArgsStr).Send()
|
||||
// Run simple command
|
||||
if err := commandSession.Run(ArgsStr); err != nil {
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, true), fmt.Errorf("error running command: %w", err)
|
||||
}
|
||||
}
|
||||
default:
|
||||
if command.Shell != "" {
|
||||
ArgsStr = fmt.Sprintf("%s -c '%s %s'", command.Shell, command.Cmd, ArgsStr)
|
||||
} else {
|
||||
ArgsStr = fmt.Sprintf("%s %s", command.Cmd, ArgsStr)
|
||||
}
|
||||
cmdCtxLogger.Debug().Str("cmd + args", ArgsStr).Send()
|
||||
// Run simple command
|
||||
if err := commandSession.Run(ArgsStr); err != nil {
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, command.GetOutput), fmt.Errorf("error running command: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, true), nil
|
||||
}
|
||||
|
||||
func checkPackageVersion(cmdCtxLogger zerolog.Logger, command *Command, commandSession *ssh.Session, cmdOutBuf bytes.Buffer) ([]string, error) {
|
||||
cmdCtxLogger.Info().Str("package", command.PackageName).Msg("Checking package versions")
|
||||
// Prepare command arguments
|
||||
ArgsStr := command.Cmd
|
||||
for _, v := range command.Args {
|
||||
ArgsStr += fmt.Sprintf(" %s", v)
|
||||
}
|
||||
|
||||
var err error
|
||||
var cmdOut []byte
|
||||
|
||||
if cmdOut, err = commandSession.CombinedOutput(ArgsStr); err != nil {
|
||||
cmdOutBuf.Write(cmdOut)
|
||||
|
||||
_, parseErr := parsePackageVersion(string(cmdOut), cmdCtxLogger, command, cmdOutBuf)
|
||||
if parseErr != nil {
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, command.GetOutput), fmt.Errorf("error: package %s not listed: %w", command.PackageName, err)
|
||||
}
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, command.GetOutput), fmt.Errorf("error running %s: %w", ArgsStr, err)
|
||||
}
|
||||
|
||||
return parsePackageVersion(string(cmdOut), cmdCtxLogger, command, cmdOutBuf)
|
||||
}
|
||||
|
||||
// getCommandTypeLabel returns a human-readable label for the command type.
|
||||
func getCommandTypeLabel(commandType string) string {
|
||||
if commandType == "" {
|
||||
return "command"
|
||||
}
|
||||
return fmt.Sprintf("%s command", commandType)
|
||||
}
|
||||
|
||||
// runScript handles the execution of inline scripts.
|
||||
func (command *Command) runScript(session *ssh.Session, cmdCtxLogger zerolog.Logger, outputBuf *bytes.Buffer) ([]string, error) {
|
||||
script, err := command.prepareScriptBuffer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
session.Stdin = script
|
||||
|
||||
if err := session.Shell(); err != nil {
|
||||
return nil, fmt.Errorf("error starting shell: %w", err)
|
||||
}
|
||||
|
||||
if err := session.Wait(); err != nil {
|
||||
return collectOutput(outputBuf, command.Name, cmdCtxLogger, true), fmt.Errorf("error waiting for shell: %w", err)
|
||||
}
|
||||
|
||||
return collectOutput(outputBuf, command.Name, cmdCtxLogger, command.GetOutput), nil
|
||||
}
|
||||
|
||||
// runScriptFile handles the execution of script files.
|
||||
func (command *Command) runScriptFile(session *ssh.Session, cmdCtxLogger zerolog.Logger, outputBuf *bytes.Buffer) ([]string, error) {
|
||||
script, err := command.prepareScriptFileBuffer()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
session.Stdin = script
|
||||
|
||||
if err := session.Shell(); err != nil {
|
||||
return nil, fmt.Errorf("error starting shell: %w", err)
|
||||
}
|
||||
|
||||
if err := session.Wait(); err != nil {
|
||||
return collectOutput(outputBuf, command.Name, cmdCtxLogger, true), fmt.Errorf("error waiting for shell: %w", err)
|
||||
}
|
||||
|
||||
return collectOutput(outputBuf, command.Name, cmdCtxLogger, true), nil
|
||||
}
|
||||
|
||||
// prepareScriptBuffer prepares a buffer for inline scripts.
|
||||
func (command *Command) prepareScriptBuffer() (*bytes.Buffer, error) {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
if command.ScriptEnvFile != "" {
|
||||
envBuffer, err := readFileToBuffer(command.ScriptEnvFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buffer.Write(envBuffer.Bytes())
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
buffer.WriteString(command.Cmd + "\n")
|
||||
return &buffer, nil
|
||||
}
|
||||
|
||||
// prepareScriptFileBuffer prepares a buffer for script files.
|
||||
func (command *Command) prepareScriptFileBuffer() (*bytes.Buffer, error) {
|
||||
var buffer bytes.Buffer
|
||||
|
||||
// Handle script environment file
|
||||
if command.ScriptEnvFile != "" {
|
||||
envBuffer, err := readFileToBuffer(command.ScriptEnvFile)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buffer.Write(envBuffer.Bytes())
|
||||
buffer.WriteByte('\n')
|
||||
}
|
||||
|
||||
// Handle script file
|
||||
scriptBuffer, err := readFileToBuffer(command.Cmd)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
buffer.Write(scriptBuffer.Bytes())
|
||||
|
||||
return &buffer, nil
|
||||
}
|
||||
|
||||
// readFileToBuffer reads a file into a buffer.
|
||||
func readFileToBuffer(filePath string) (*bytes.Buffer, error) {
|
||||
resolvedPath, err := resolveDir(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
file, err := os.Open(resolvedPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
var hostKey ssh.PublicKey
|
||||
var buffer bytes.Buffer
|
||||
if _, err := io.Copy(&buffer, file); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &buffer, nil
|
||||
}
|
||||
|
||||
// collectOutput collects output from a buffer and logs it.
|
||||
func collectOutput(buf *bytes.Buffer, commandName string, logger zerolog.Logger, wantOutput bool) []string {
|
||||
var outputArr []string
|
||||
scanner := bufio.NewScanner(buf)
|
||||
for scanner.Scan() {
|
||||
fields := strings.Split(scanner.Text(), " ")
|
||||
if len(fields) != 3 {
|
||||
continue
|
||||
line := scanner.Text()
|
||||
outputArr = append(outputArr, line)
|
||||
if wantOutput {
|
||||
logger.Info().Str("cmd", commandName).Str("output", line).Send()
|
||||
}
|
||||
if strings.Contains(fields[0], host) {
|
||||
var err error
|
||||
hostKey, _, _, _, err = ssh.ParseAuthorizedKey(scanner.Bytes())
|
||||
}
|
||||
return outputArr
|
||||
}
|
||||
|
||||
// createSSHSession attempts to create a new SSH session and retries on failure.
|
||||
func (h *Host) createSSHSession(opts *ConfigOpts) (*ssh.Session, error) {
|
||||
session, err := h.SshClient.NewSession()
|
||||
if err == nil {
|
||||
return session, nil
|
||||
}
|
||||
|
||||
// Retry connection and session creation
|
||||
if connErr := h.ConnectToHost(opts); connErr != nil {
|
||||
return nil, fmt.Errorf("session creation failed: %v, connection retry failed: %v", err, connErr)
|
||||
}
|
||||
return h.SshClient.NewSession()
|
||||
}
|
||||
|
||||
func (h *Host) DetectOS(opts *ConfigOpts) (string, error) {
|
||||
err := h.ConnectToHost(opts)
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("error parsing %q: %v", fields[2], err)
|
||||
return "", err
|
||||
}
|
||||
break
|
||||
var session *ssh.Session
|
||||
session, err = h.createSSHSession(opts)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
// Execute the "uname -a" command on the remote machine
|
||||
output, err := session.CombinedOutput("uname")
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("failed to execute OS detection command: %v", err)
|
||||
}
|
||||
|
||||
if hostKey == nil {
|
||||
log.Fatalf("no hostkey found for %s", host)
|
||||
// Parse the output to determine the OS
|
||||
osName := string(output)
|
||||
return osName, nil
|
||||
}
|
||||
|
||||
return hostKey
|
||||
func CheckIfHostHasHostName(host string) (bool, string) {
|
||||
HostName, err := ssh_config.DefaultUserSettings.GetStrict(host, "HostName")
|
||||
if err != nil {
|
||||
return false, ""
|
||||
}
|
||||
println(HostName)
|
||||
return HostName != "", HostName
|
||||
}
|
||||
|
22
pkg/backy/templates/error.txt
Normal file
22
pkg/backy/templates/error.txt
Normal file
@ -0,0 +1,22 @@
|
||||
Command list {{.listName }} failed.
|
||||
|
||||
The command run was {{.CmdName}}.
|
||||
|
||||
The command executed was {{.Command}} {{ if .Args }} {{- range .Args}} {{.}} {{end}} {{end}}
|
||||
|
||||
{{ if .Err }} The error was {{ .Err }}{{ end }}
|
||||
|
||||
{{ if .Output }} The output was: {{- range .Output}} {{.}} {{end}} {{end}}
|
||||
|
||||
{{ if .CmdsRan }}
|
||||
The following commands ran:
|
||||
{{- range .CmdsRan}}
|
||||
- {{. -}}
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
||||
{{ if .CmdOutput }}{{- range .CmdOutput }}{{ printf "\n"}}Command output for {{ .CmdName }}:
|
||||
{{- range .Output}}
|
||||
{{ . }}
|
||||
{{ end }}{{ end }}
|
||||
{{ end }}
|
12
pkg/backy/templates/success.txt
Normal file
12
pkg/backy/templates/success.txt
Normal file
@ -0,0 +1,12 @@
|
||||
Command list {{ .listName }} completed successfully.
|
||||
|
||||
The following commands ran:
|
||||
{{- range .CmdsRan}}
|
||||
- {{. -}}
|
||||
{{end}}
|
||||
|
||||
{{ if .CmdOutput }}{{- range .CmdOutput }}{{ printf "\n"}}Command output for {{ .CmdName }}:
|
||||
{{- range .Output}}
|
||||
{{ . }}
|
||||
{{ end }}{{ end }}
|
||||
{{ end }}
|
291
pkg/backy/types.go
Normal file
291
pkg/backy/types.go
Normal file
@ -0,0 +1,291 @@
|
||||
package backy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"text/template"
|
||||
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/remotefetcher"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/usermanager"
|
||||
vaultapi "github.com/hashicorp/vault/api"
|
||||
"github.com/kevinburke/ssh_config"
|
||||
"github.com/knadh/koanf/v2"
|
||||
"github.com/nikoksr/notify"
|
||||
"github.com/rs/zerolog"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
type (
|
||||
|
||||
// Host defines a host to which to connect.
|
||||
// If not provided, the values will be looked up in the default ssh config files
|
||||
Host struct {
|
||||
OS string `yaml:"OS,omitempty"`
|
||||
ConfigFilePath string `yaml:"config,omitempty"`
|
||||
Host string `yaml:"host,omitempty"`
|
||||
HostName string `yaml:"hostname,omitempty"`
|
||||
KnownHostsFile string `yaml:"knownhostsfile,omitempty"`
|
||||
ClientConfig *ssh.ClientConfig
|
||||
SSHConfigFile *sshConfigFile
|
||||
SshClient *ssh.Client
|
||||
Port uint16 `yaml:"port,omitempty"`
|
||||
ProxyJump string `yaml:"proxyjump,omitempty"`
|
||||
Password string `yaml:"password,omitempty"`
|
||||
PrivateKeyPath string `yaml:"privatekeypath,omitempty"`
|
||||
PrivateKeyPassword string `yaml:"privatekeypassword,omitempty"`
|
||||
useDefaultConfig bool
|
||||
User string `yaml:"user,omitempty"`
|
||||
isProxyHost bool
|
||||
// ProxyHost holds the configuration for a ProxyJump host
|
||||
ProxyHost []*Host
|
||||
// CertPath string `yaml:"cert_path,omitempty"`
|
||||
}
|
||||
|
||||
sshConfigFile struct {
|
||||
SshConfigFile *ssh_config.Config
|
||||
DefaultUserSettings *ssh_config.UserSettings
|
||||
}
|
||||
|
||||
Command struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
|
||||
// command to run
|
||||
Cmd string `yaml:"cmd"`
|
||||
|
||||
// Possible values: script, scriptFile
|
||||
// If blank, it is regular command.
|
||||
Type string `yaml:"type,omitempty"`
|
||||
|
||||
// host on which to run cmd
|
||||
Host *string `yaml:"host,omitempty"`
|
||||
|
||||
// Hooks are for running commands on certain events
|
||||
Hooks *Hooks `yaml:"hooks,omitempty"`
|
||||
|
||||
// hook refs are internal references of commands for each hook type
|
||||
hookRefs map[string]map[string]*Command
|
||||
|
||||
// Shell specifies which shell to run the command in, if any.
|
||||
Shell string `yaml:"shell,omitempty"`
|
||||
|
||||
RemoteHost *Host `yaml:"-"`
|
||||
|
||||
// Args is an array that holds the arguments to cmd
|
||||
Args []string `yaml:"args,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"`
|
||||
|
||||
// Output determines if output is requested.
|
||||
//
|
||||
// Only for when command is in a list.
|
||||
GetOutput bool `yaml:"getOutput,omitempty"`
|
||||
|
||||
ScriptEnvFile string `yaml:"scriptEnvFile"`
|
||||
|
||||
// BEGIN PACKAGE COMMAND FIELDS
|
||||
|
||||
PackageManager string `yaml:"packageManager,omitempty"`
|
||||
|
||||
PackageName string `yaml:"packageName,omitempty"`
|
||||
|
||||
// Version specifies the desired version for package execution
|
||||
PackageVersion string `yaml:"packageVersion,omitempty"`
|
||||
|
||||
// PackageOperation specifies the action for package-related commands (e.g., "install" or "remove")
|
||||
PackageOperation string `yaml:"packageOperation,omitempty"`
|
||||
|
||||
pkgMan pkgman.PackageManager
|
||||
|
||||
packageCmdSet bool
|
||||
// END PACKAGE COMMAND FIELDS
|
||||
|
||||
// RemoteSource specifies a URL to fetch the command or configuration remotely
|
||||
RemoteSource string `yaml:"remoteSource,omitempty"`
|
||||
|
||||
// FetchBeforeExecution determines if the remoteSource should be fetched before running
|
||||
FetchBeforeExecution bool `yaml:"fetchBeforeExecution,omitempty"`
|
||||
|
||||
// BEGIN USER COMMAND FIELDS
|
||||
|
||||
// Username specifies the username for user creation or related operations
|
||||
Username string `yaml:"userName,omitempty"`
|
||||
|
||||
UserID string `yaml:"userID,omitempty"`
|
||||
|
||||
// UserGroups specifies the groups to add the user to
|
||||
UserGroups []string `yaml:"userGroups,omitempty"`
|
||||
|
||||
// UserHome specifies the home directory for the user
|
||||
UserHome string `yaml:"userHome,omitempty"`
|
||||
|
||||
// UserShell specifies the shell for the user
|
||||
UserShell string `yaml:"userShell,omitempty"`
|
||||
|
||||
// SystemUser specifies whether the user is a system account
|
||||
SystemUser bool `yaml:"systemUser,omitempty"`
|
||||
|
||||
// UserPassword specifies the password for the user (can be file: or plain text)
|
||||
UserPassword string `yaml:"userPassword,omitempty"`
|
||||
|
||||
userMan usermanager.UserManager
|
||||
|
||||
// OS for the command, only used when type is user
|
||||
OS string `yaml:"OS,omitempty"`
|
||||
|
||||
// UserOperation specifies the action for user-related commands (e.g., "create" or "remove")
|
||||
UserOperation string `yaml:"userOperation,omitempty"`
|
||||
|
||||
userCmdSet bool
|
||||
|
||||
// stdin only for userOperation = password (for now)
|
||||
stdin *strings.Reader
|
||||
|
||||
// END USER STRUCT FIELDS
|
||||
}
|
||||
|
||||
RemoteSource struct {
|
||||
URL string `yaml:"url"`
|
||||
Type string `yaml:"type"` // e.g., s3, http
|
||||
Auth struct {
|
||||
AccessKey string `yaml:"accessKey"`
|
||||
SecretKey string `yaml:"secretKey"`
|
||||
} `yaml:"auth"`
|
||||
}
|
||||
|
||||
BackyOptionFunc func(*ConfigOpts)
|
||||
|
||||
CmdList struct {
|
||||
Name string `yaml:"name,omitempty"`
|
||||
Cron string `yaml:"cron,omitempty"`
|
||||
RunCmdOnFailure string `yaml:"runCmdOnFailure,omitempty"`
|
||||
Order []string `yaml:"order,omitempty"`
|
||||
Notifications []string `yaml:"notifications,omitempty"`
|
||||
GetOutput bool `yaml:"getOutput,omitempty"`
|
||||
NotifyOnSuccess bool `yaml:"notifyOnSuccess,omitempty"`
|
||||
|
||||
NotifyConfig *notify.Notify
|
||||
Source string `yaml:"source"` // URL to fetch remote commands
|
||||
Type string `yaml:"type"`
|
||||
}
|
||||
|
||||
ConfigOpts struct {
|
||||
// Cmds holds the commands for a list.
|
||||
// Key is the name of the command,
|
||||
Cmds map[string]*Command `yaml:"commands"`
|
||||
|
||||
// CmdConfigLists holds the lists of commands to be run in order.
|
||||
// Key is the command list name.
|
||||
CmdConfigLists map[string]*CmdList `yaml:"cmd-lists"`
|
||||
|
||||
// Hosts holds the Host config.
|
||||
// key is the host.
|
||||
Hosts map[string]*Host `yaml:"hosts"`
|
||||
|
||||
Logger zerolog.Logger
|
||||
|
||||
// Global log level
|
||||
BackyLogLvl *string
|
||||
|
||||
// Holds config file
|
||||
ConfigFilePath string
|
||||
|
||||
// Holds log file
|
||||
LogFilePath string
|
||||
|
||||
// for command list file
|
||||
CmdListFile string
|
||||
|
||||
// use command lists using cron
|
||||
cronEnabled bool
|
||||
// Holds commands to execute for the exec command
|
||||
executeCmds []string
|
||||
// Holds lists to execute for the backup command
|
||||
executeLists []string
|
||||
|
||||
// Holds env vars from .env file
|
||||
backyEnv map[string]string
|
||||
|
||||
vaultClient *vaultapi.Client
|
||||
|
||||
List ListConfig
|
||||
|
||||
VaultKeys []*VaultKey `yaml:"keys"`
|
||||
|
||||
koanf *koanf.Koanf
|
||||
|
||||
NotificationConf *Notifications `yaml:"notifications"`
|
||||
|
||||
Cache *remotefetcher.Cache
|
||||
CachedData []*remotefetcher.CacheData
|
||||
}
|
||||
|
||||
outStruct struct {
|
||||
CmdName string
|
||||
CmdExecuted string
|
||||
Output []string
|
||||
}
|
||||
|
||||
VaultKey struct {
|
||||
Name string `yaml:"name"`
|
||||
Path string `yaml:"path"`
|
||||
ValueType string `yaml:"type"`
|
||||
MountPath string `yaml:"mountpath"`
|
||||
}
|
||||
|
||||
VaultConfig struct {
|
||||
Token string `yaml:"token"`
|
||||
Address string `yaml:"address"`
|
||||
Enabled string `yaml:"enabled"`
|
||||
Keys []*VaultKey `yaml:"keys"`
|
||||
}
|
||||
|
||||
Notifications struct {
|
||||
MailConfig map[string]MailConfig `yaml:"mail,omitempty"`
|
||||
MatrixConfig map[string]MatrixStruct `yaml:"matrix,omitempty"`
|
||||
}
|
||||
|
||||
CmdOutput struct {
|
||||
Err error
|
||||
Output bytes.Buffer
|
||||
}
|
||||
|
||||
environmentVars struct {
|
||||
file string
|
||||
env []string
|
||||
}
|
||||
|
||||
msgTemplates struct {
|
||||
success *template.Template
|
||||
err *template.Template
|
||||
}
|
||||
|
||||
ListConfig struct {
|
||||
Lists []string
|
||||
Commands []string
|
||||
Hosts []string
|
||||
}
|
||||
|
||||
Hooks struct {
|
||||
Error []string `yaml:"error,omitempty"`
|
||||
Success []string `yaml:"success,omitempty"`
|
||||
Final []string `yaml:"final,omitempty"`
|
||||
}
|
||||
|
||||
CmdResult struct {
|
||||
CmdName string // Name of the command executed
|
||||
ListName string // Name of the command list
|
||||
Error error // Error encountered, if any
|
||||
}
|
||||
)
|
324
pkg/backy/utils.go
Normal file
324
pkg/backy/utils.go
Normal file
@ -0,0 +1,324 @@
|
||||
// utils.go
|
||||
// Copyright (C) Andrew Woodlee 2023
|
||||
// License: Apache-2.0
|
||||
|
||||
package backy
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/logging"
|
||||
"github.com/joho/godotenv"
|
||||
"github.com/knadh/koanf/v2"
|
||||
"github.com/rs/zerolog"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"mvdan.cc/sh/v3/shell"
|
||||
)
|
||||
|
||||
func (c *ConfigOpts) LogLvl(level string) BackyOptionFunc {
|
||||
|
||||
return func(bco *ConfigOpts) {
|
||||
c.BackyLogLvl = &level
|
||||
}
|
||||
}
|
||||
|
||||
// AddCommands adds commands to ConfigOpts
|
||||
func AddCommands(commands []string) BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.executeCmds = append(bco.executeCmds, commands...)
|
||||
}
|
||||
}
|
||||
|
||||
// AddCommandLists adds lists to ConfigOpts
|
||||
func AddCommandLists(lists []string) BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.executeLists = append(bco.executeLists, lists...)
|
||||
}
|
||||
}
|
||||
|
||||
// SetListsToSearch adds lists to search
|
||||
func SetListsToSearch(lists []string) BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.List.Lists = append(bco.List.Lists, lists...)
|
||||
}
|
||||
}
|
||||
|
||||
// AddPrintLists adds lists to print out
|
||||
func SetCmdsToSearch(cmds []string) BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.List.Commands = append(bco.List.Commands, cmds...)
|
||||
}
|
||||
}
|
||||
|
||||
// SetLogFile sets the path to the log file
|
||||
func SetLogFile(logFile string) BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.LogFilePath = logFile
|
||||
}
|
||||
}
|
||||
|
||||
// EnableCron enables the execution of command lists at specified times
|
||||
func EnableCron() BackyOptionFunc {
|
||||
return func(bco *ConfigOpts) {
|
||||
bco.cronEnabled = true
|
||||
}
|
||||
}
|
||||
|
||||
func NewOpts(configFilePath string, opts ...BackyOptionFunc) *ConfigOpts {
|
||||
b := &ConfigOpts{}
|
||||
b.ConfigFilePath = configFilePath
|
||||
for _, opt := range opts {
|
||||
if opt != nil {
|
||||
opt(b)
|
||||
}
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func injectEnvIntoSSH(envVarsToInject environmentVars, process *ssh.Session, opts *ConfigOpts, log zerolog.Logger) {
|
||||
if envVarsToInject.file != "" {
|
||||
envPath, envPathErr := resolveDir(envVarsToInject.file)
|
||||
if envPathErr != nil {
|
||||
log.Fatal().Str("envFile", envPath).Err(envPathErr).Send()
|
||||
}
|
||||
file, err := os.Open(envPath)
|
||||
if err != nil {
|
||||
log.Fatal().Str("envFile", envPath).Err(err).Send()
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
envMap, err := godotenv.Parse(file)
|
||||
if err != nil {
|
||||
log.Error().Str("envFile", envPath).Err(err).Send()
|
||||
goto errEnvFile
|
||||
}
|
||||
for key, val := range envMap {
|
||||
process.Setenv(key, GetVaultKey(val, opts, log))
|
||||
}
|
||||
}
|
||||
|
||||
errEnvFile:
|
||||
// fmt.Printf("%v", envVarsToInject.env)
|
||||
for _, envVal := range envVarsToInject.env {
|
||||
// don't append env Vars for Backy
|
||||
if strings.Contains(envVal, "=") {
|
||||
envVarArr := strings.Split(envVal, "=")
|
||||
|
||||
process.Setenv(envVarArr[0], GetVaultKey(envVarArr[1], opts, log))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func injectEnvIntoLocalCMD(envVarsToInject environmentVars, process *exec.Cmd, log zerolog.Logger) {
|
||||
if envVarsToInject.file != "" {
|
||||
envPath, _ := resolveDir(envVarsToInject.file)
|
||||
|
||||
file, fileErr := os.Open(envPath)
|
||||
if fileErr != nil {
|
||||
log.Error().Str("envFile", envPath).Err(fileErr).Send()
|
||||
goto errEnvFile
|
||||
}
|
||||
defer file.Close()
|
||||
envMap, err := godotenv.Parse(file)
|
||||
if err != nil {
|
||||
log.Error().Str("envFile", envPath).Err(err).Send()
|
||||
goto errEnvFile
|
||||
}
|
||||
for key, val := range envMap {
|
||||
process.Env = append(process.Env, fmt.Sprintf("%s=%s", key, val))
|
||||
}
|
||||
|
||||
}
|
||||
errEnvFile:
|
||||
|
||||
for _, envVal := range envVarsToInject.env {
|
||||
if strings.Contains(envVal, "=") {
|
||||
process.Env = append(process.Env, envVal)
|
||||
}
|
||||
}
|
||||
process.Env = append(process.Env, os.Environ()...)
|
||||
}
|
||||
|
||||
func contains(s []string, e string) bool {
|
||||
for _, a := range s {
|
||||
if a == e {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func CheckConfigValues(config *koanf.Koanf, file string) {
|
||||
|
||||
for _, key := range requiredKeys {
|
||||
isKeySet := config.Exists(key)
|
||||
if !isKeySet {
|
||||
logging.ExitWithMSG(Sprintf("Config key %s is not defined in %s. Please make sure this value is set and has the appropriate keys set.", key, file), 1, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testFile(c string) error {
|
||||
if strings.TrimSpace(c) != "" {
|
||||
file, fileOpenErr := os.Open(c)
|
||||
file.Close()
|
||||
if errors.Is(fileOpenErr, os.ErrNotExist) {
|
||||
return fileOpenErr
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func IsTerminalActive() bool {
|
||||
return os.Getenv("BACKY_TERM") == "enabled"
|
||||
}
|
||||
|
||||
func IsCmdStdOutEnabled() bool {
|
||||
return os.Getenv("BACKY_STDOUT") == "enabled"
|
||||
}
|
||||
|
||||
func resolveDir(path string) (string, error) {
|
||||
if path == "~" {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return path, err
|
||||
}
|
||||
// In case of "~", which won't be caught by the "else if"
|
||||
path = homeDir
|
||||
} else if strings.HasPrefix(path, "~/") {
|
||||
homeDir, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return path, err
|
||||
}
|
||||
// Use strings.HasPrefix so we don't match paths like
|
||||
// "/something/~/something/"
|
||||
path = filepath.Join(homeDir, path[2:])
|
||||
}
|
||||
return path, nil
|
||||
}
|
||||
|
||||
// loadEnv loads a .env file from the config file directory
|
||||
func (opts *ConfigOpts) loadEnv() {
|
||||
envFileInConfigDir := fmt.Sprintf("%s/.env", path.Dir(opts.ConfigFilePath))
|
||||
var backyEnv map[string]string
|
||||
backyEnv, envFileErr := godotenv.Read(envFileInConfigDir)
|
||||
if envFileErr != nil {
|
||||
return
|
||||
}
|
||||
|
||||
opts.backyEnv = backyEnv
|
||||
}
|
||||
|
||||
// expandEnvVars expands environment variables with the env used in the config
|
||||
func expandEnvVars(backyEnv map[string]string, envVars []string) {
|
||||
|
||||
env := func(name string) string {
|
||||
name = strings.ToUpper(name)
|
||||
envVar, found := backyEnv[name]
|
||||
if found {
|
||||
return envVar
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// parse env variables using new macros
|
||||
for indx, v := range envVars {
|
||||
if strings.HasPrefix(v, macroStart) && strings.HasSuffix(v, macroEnd) {
|
||||
if strings.HasPrefix(v, envMacroStart) {
|
||||
v = strings.TrimPrefix(v, envMacroStart)
|
||||
v = strings.TrimRight(v, macroEnd)
|
||||
out, _ := shell.Expand(v, env)
|
||||
envVars[indx] = out
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// getCommandType checks for command type and if the command has already been set
|
||||
// Checks for types package and user
|
||||
// Returns the modified Command with the package- or userManager command as Cmd and the package- or userOperation as args, plus any additional Args
|
||||
func getCommandType(command *Command) *Command {
|
||||
|
||||
if command.Type == "package" && !command.packageCmdSet {
|
||||
command.packageCmdSet = true
|
||||
switch command.PackageOperation {
|
||||
case "install":
|
||||
command.Cmd, command.Args = command.pkgMan.Install(command.PackageName, command.PackageVersion, command.Args)
|
||||
case "remove":
|
||||
command.Cmd, command.Args = command.pkgMan.Remove(command.PackageName, command.Args)
|
||||
case "upgrade":
|
||||
command.Cmd, command.Args = command.pkgMan.Upgrade(command.PackageName, command.PackageVersion)
|
||||
case "checkVersion":
|
||||
command.Cmd, command.Args = command.pkgMan.CheckVersion(command.PackageName, command.PackageVersion)
|
||||
}
|
||||
}
|
||||
|
||||
if command.Type == "user" && !command.userCmdSet {
|
||||
command.userCmdSet = true
|
||||
switch command.UserOperation {
|
||||
case "add":
|
||||
command.Cmd, command.Args = command.userMan.AddUser(
|
||||
command.Username,
|
||||
command.UserHome,
|
||||
command.UserShell,
|
||||
command.SystemUser,
|
||||
command.UserGroups,
|
||||
command.Args)
|
||||
case "modify":
|
||||
command.Cmd, command.Args = command.userMan.ModifyUser(
|
||||
command.Username,
|
||||
command.UserHome,
|
||||
command.UserShell,
|
||||
command.UserGroups)
|
||||
case "checkIfExists":
|
||||
command.Cmd, command.Args = command.userMan.UserExists(command.Username)
|
||||
case "delete":
|
||||
command.Cmd, command.Args = command.userMan.RemoveUser(command.Username)
|
||||
case "password":
|
||||
command.Cmd, command.stdin, command.UserPassword = command.userMan.ModifyPassword(command.Username, command.UserPassword)
|
||||
}
|
||||
}
|
||||
|
||||
return command
|
||||
}
|
||||
|
||||
func parsePackageVersion(output string, cmdCtxLogger zerolog.Logger, command *Command, cmdOutBuf bytes.Buffer) ([]string, error) {
|
||||
|
||||
var err error
|
||||
pkgVersion, err := command.pkgMan.Parse(output)
|
||||
// println(output)
|
||||
if err != nil {
|
||||
cmdCtxLogger.Error().Err(err).Str("package", command.PackageName).Msg("Error parsing package version output")
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, command.GetOutput), err
|
||||
}
|
||||
|
||||
cmdCtxLogger.Info().
|
||||
Str("Installed", pkgVersion.Installed).
|
||||
Str("Candidate", pkgVersion.Candidate).
|
||||
Msg("Package version comparison")
|
||||
|
||||
if command.PackageVersion != "" {
|
||||
if pkgVersion.Installed == command.PackageVersion {
|
||||
cmdCtxLogger.Info().Msgf("Installed version matches specified version: %s", command.PackageVersion)
|
||||
} else {
|
||||
cmdCtxLogger.Info().Msgf("Installed version does not match specified version: %s", command.PackageVersion)
|
||||
err = fmt.Errorf("Installed version does not match specified version: %s", command.PackageVersion)
|
||||
}
|
||||
} else {
|
||||
if pkgVersion.Installed == pkgVersion.Candidate {
|
||||
cmdCtxLogger.Info().Msg("Installed and Candidate versions match")
|
||||
} else {
|
||||
cmdCtxLogger.Info().Msg("Installed and Candidate versions differ")
|
||||
err = errors.New("Installed and Candidate versions differ")
|
||||
}
|
||||
}
|
||||
return collectOutput(&cmdOutBuf, command.Name, cmdCtxLogger, false), err
|
||||
}
|
@ -1,85 +0,0 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/backy"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func ReadConfig(Config *viper.Viper) (*viper.Viper, error) {
|
||||
|
||||
backyViper := viper.New()
|
||||
|
||||
// Check for existing config, if none exists, return new one
|
||||
if Config == nil {
|
||||
|
||||
backyViper.AddConfigPath(".")
|
||||
// name of config file (without extension)
|
||||
backyViper.SetConfigName("backy")
|
||||
// REQUIRED if the config file does not have the extension in the name
|
||||
backyViper.SetConfigType("yaml")
|
||||
|
||||
if err := backyViper.ReadInConfig(); err != nil {
|
||||
if configFileNotFound, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
return nil, configFileNotFound
|
||||
// Config file not found; ignore error if desired
|
||||
} else {
|
||||
// Config file was found but another error was produced
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Config exists, try to read config file
|
||||
if err := Config.ReadInConfig(); err != nil {
|
||||
if _, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
|
||||
backyViper.AddConfigPath(".")
|
||||
// name of config file (without extension)
|
||||
backyViper.SetConfigName("backy")
|
||||
// REQUIRED if the config file does not have the extension in the name
|
||||
backyViper.SetConfigType("yaml")
|
||||
|
||||
if err := backyViper.ReadInConfig(); err != nil {
|
||||
if configFileNotFound, ok := err.(viper.ConfigFileNotFoundError); ok {
|
||||
return nil, configFileNotFound
|
||||
} else {
|
||||
// Config file was found but another error was produced
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Config file was found but another error was produced
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return backyViper, nil
|
||||
}
|
||||
|
||||
func unmarshallConfig(backup string, config *viper.Viper) (*viper.Viper, error) {
|
||||
err := viper.ReadInConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
yamlConfigPath := "backup." + backup
|
||||
conf := config.Sub(yamlConfigPath)
|
||||
|
||||
backupConfig := config.Unmarshal(&conf)
|
||||
if backupConfig == nil {
|
||||
return nil, backupConfig
|
||||
}
|
||||
|
||||
return conf, nil
|
||||
}
|
||||
|
||||
// CreateConfig creates a configuration
|
||||
// pass Name-level (i.e. "backups."+configName) to function
|
||||
func CreateConfig(backup backy.BackupConfig) backy.BackupConfig {
|
||||
newBackupConfig := backy.BackupConfig{
|
||||
Name: backup.Name,
|
||||
BackupType: backup.BackupType,
|
||||
|
||||
ConfigPath: backup.ConfigPath,
|
||||
}
|
||||
|
||||
return newBackupConfig
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
package notification
|
||||
|
||||
func GetConfig() {
|
||||
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
package logging
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"log/syslog"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
"github.com/rs/zerolog"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
type Logging struct {
|
||||
@ -18,27 +19,57 @@ type Logfile struct {
|
||||
LogfilePath string
|
||||
}
|
||||
|
||||
func OpenLogFile(config *viper.Viper) (interface{}, error) {
|
||||
var logFile *os.File
|
||||
var syslogWriter *syslog.Writer
|
||||
var err error
|
||||
logType := config.GetString("global.logging.type")
|
||||
if logType != "" {
|
||||
func ExitWithMSG(msg string, code int, log *zerolog.Logger) {
|
||||
fmt.Printf("%s\n", msg)
|
||||
os.Exit(code)
|
||||
}
|
||||
|
||||
switch logType {
|
||||
case "file":
|
||||
logFile, err = os.OpenFile(config.GetString("global.logging.file"), os.O_WRONLY|os.O_APPEND|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
func SetLoggingWriters(logFile string) (writers zerolog.LevelWriter) {
|
||||
|
||||
console := zerolog.ConsoleWriter{}
|
||||
if IsConsoleLoggingEnabled() {
|
||||
|
||||
console = zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.RFC1123}
|
||||
console.FormatLevel = func(i interface{}) string {
|
||||
return strings.ToUpper(fmt.Sprintf("| %-6s|", i))
|
||||
}
|
||||
return logFile, nil
|
||||
case "syslog":
|
||||
syslogWriter, err = syslog.New(syslog.LOG_SYSLOG, "Backy")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Unable to set logfile: " + err.Error())
|
||||
console.FormatMessage = func(i any) string {
|
||||
if i == nil {
|
||||
return ""
|
||||
}
|
||||
return syslogWriter, nil
|
||||
return fmt.Sprintf("MSG: %s", i)
|
||||
}
|
||||
console.FormatFieldName = func(i interface{}) string {
|
||||
return fmt.Sprintf("%s: ", i)
|
||||
}
|
||||
console.FormatFieldValue = func(i interface{}) string {
|
||||
return fmt.Sprintf("%s", i)
|
||||
// return strings.ToUpper(fmt.Sprintf("%s", i))
|
||||
}
|
||||
}
|
||||
return nil, errors.New("log type not specified; Please set global.logging.type in your config file")
|
||||
|
||||
fileLogger := &lumberjack.Logger{
|
||||
MaxSize: 50, // megabytes
|
||||
MaxBackups: 3,
|
||||
MaxAge: 28, //days
|
||||
Compress: true, // disabled by default
|
||||
}
|
||||
fileLogger.Filename = logFile
|
||||
// UNIX Time is faster and smaller than most timestamps
|
||||
zerolog.TimeFieldFormat = zerolog.TimeFormatUnix
|
||||
// zerolog.TimeFieldFormat = time.RFC1123
|
||||
writers = zerolog.MultiLevelWriter(fileLogger)
|
||||
|
||||
if IsConsoleLoggingEnabled() {
|
||||
writers = zerolog.MultiLevelWriter(console, fileLogger)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func IsConsoleLoggingEnabled() bool {
|
||||
return os.Getenv("BACKY_CONSOLE_LOGGING") == "enabled"
|
||||
}
|
||||
|
||||
// func IsTerminal() bool {
|
||||
// return os.Getenv("BACKY_TERM") == "enabled"
|
||||
// }
|
||||
|
@ -1,5 +0,0 @@
|
||||
package notifications
|
||||
|
||||
func SetupNotify() error {
|
||||
return nil
|
||||
}
|
130
pkg/pkgman/apt/apt.go
Normal file
130
pkg/pkgman/apt/apt.go
Normal file
@ -0,0 +1,130 @@
|
||||
package apt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/pkgcommon"
|
||||
)
|
||||
|
||||
// AptManager implements PackageManager for systems using APT.
|
||||
type AptManager struct {
|
||||
useAuth bool // Whether to use an authentication command
|
||||
authCommand string // The authentication command, e.g., "sudo"
|
||||
Parser pkgcommon.PackageParser
|
||||
}
|
||||
|
||||
// DefaultAuthCommand is the default command used for authentication.
|
||||
const DefaultAuthCommand = "sudo"
|
||||
|
||||
const DefaultPackageCommand = "apt-get"
|
||||
|
||||
// NewAptManager creates a new AptManager with default settings.
|
||||
func NewAptManager() *AptManager {
|
||||
return &AptManager{
|
||||
useAuth: true,
|
||||
authCommand: DefaultAuthCommand,
|
||||
}
|
||||
}
|
||||
|
||||
// Install returns the command and arguments for installing a package.
|
||||
func (a *AptManager) Install(pkg, version string, args []string) (string, []string) {
|
||||
baseCmd := a.prependAuthCommand(DefaultPackageCommand)
|
||||
baseArgs := []string{"update", "&&", baseCmd, "install", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s=%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Remove returns the command and arguments for removing a package.
|
||||
func (a *AptManager) Remove(pkg string, args []string) (string, []string) {
|
||||
baseCmd := a.prependAuthCommand(DefaultPackageCommand)
|
||||
baseArgs := []string{"remove", "-y", pkg}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Upgrade returns the command and arguments for upgrading a specific package.
|
||||
func (a *AptManager) Upgrade(pkg, version string) (string, []string) {
|
||||
baseCmd := a.prependAuthCommand(DefaultPackageCommand)
|
||||
baseArgs := []string{"update", "&&", baseCmd, "install", "--only-upgrade", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s=%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// CheckVersion returns the command and arguments for checking the info of a specific package.
|
||||
func (a *AptManager) CheckVersion(pkg, version string) (string, []string) {
|
||||
baseCmd := a.prependAuthCommand("apt-cache")
|
||||
baseArgs := []string{"policy", pkg}
|
||||
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// UpgradeAll returns the command and arguments for upgrading all packages.
|
||||
func (a *AptManager) UpgradeAll() (string, []string) {
|
||||
baseCmd := a.prependAuthCommand(DefaultPackageCommand)
|
||||
baseArgs := []string{"update", "&&", baseCmd, "upgrade", "-y"}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Configure applies functional options to customize the package manager.
|
||||
func (a *AptManager) Configure(options ...pkgcommon.PackageManagerOption) {
|
||||
for _, opt := range options {
|
||||
opt(a)
|
||||
}
|
||||
}
|
||||
|
||||
// prependAuthCommand prepends the authentication command if UseAuth is true.
|
||||
func (a *AptManager) prependAuthCommand(baseCmd string) string {
|
||||
if a.useAuth {
|
||||
return a.authCommand + " " + baseCmd
|
||||
}
|
||||
return baseCmd
|
||||
}
|
||||
|
||||
// SetUseAuth enables or disables authentication.
|
||||
func (a *AptManager) SetUseAuth(useAuth bool) {
|
||||
a.useAuth = useAuth
|
||||
}
|
||||
|
||||
// SetAuthCommand sets the authentication command.
|
||||
func (a *AptManager) SetAuthCommand(authCommand string) {
|
||||
a.authCommand = authCommand
|
||||
}
|
||||
|
||||
// Parse parses the apt-cache policy output to extract Installed and Candidate versions.
|
||||
func (a *AptManager) Parse(output string) (*pkgcommon.PackageVersion, error) {
|
||||
// Check for error message in the output
|
||||
if strings.Contains(output, "Unable to locate package") {
|
||||
return nil, fmt.Errorf("error: %s", strings.TrimSpace(output))
|
||||
}
|
||||
|
||||
reInstalled := regexp.MustCompile(`Installed:\s*([^\s]+)`)
|
||||
reCandidate := regexp.MustCompile(`Candidate:\s*([^\s]+)`)
|
||||
|
||||
installedMatch := reInstalled.FindStringSubmatch(output)
|
||||
candidateMatch := reCandidate.FindStringSubmatch(output)
|
||||
|
||||
if len(installedMatch) < 2 || len(candidateMatch) < 2 {
|
||||
return nil, fmt.Errorf("failed to parse Installed or Candidate versions from apt output. check package name")
|
||||
}
|
||||
|
||||
return &pkgcommon.PackageVersion{
|
||||
Installed: strings.TrimSpace(installedMatch[1]),
|
||||
Candidate: strings.TrimSpace(candidateMatch[1]),
|
||||
Match: installedMatch[1] == candidateMatch[1],
|
||||
}, nil
|
||||
}
|
139
pkg/pkgman/dnf/dnf.go
Normal file
139
pkg/pkgman/dnf/dnf.go
Normal file
@ -0,0 +1,139 @@
|
||||
package dnf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/pkgcommon"
|
||||
)
|
||||
|
||||
// DnfManager implements PackageManager for systems using YUM.
|
||||
type DnfManager struct {
|
||||
useAuth bool // Whether to use an authentication command
|
||||
authCommand string // The authentication command, e.g., "sudo"
|
||||
}
|
||||
|
||||
// DefaultAuthCommand is the default command used for authentication.
|
||||
const DefaultAuthCommand = "sudo"
|
||||
|
||||
// NewDnfManager creates a new DnfManager with default settings.
|
||||
func NewDnfManager() *DnfManager {
|
||||
return &DnfManager{
|
||||
useAuth: true,
|
||||
authCommand: DefaultAuthCommand,
|
||||
}
|
||||
}
|
||||
|
||||
// Configure applies functional options to customize the package manager.
|
||||
func (y *DnfManager) Configure(options ...pkgcommon.PackageManagerOption) {
|
||||
for _, opt := range options {
|
||||
opt(y)
|
||||
}
|
||||
}
|
||||
|
||||
// Install returns the command and arguments for installing a package.
|
||||
func (y *DnfManager) Install(pkg, version string, args []string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("dnf")
|
||||
baseArgs := []string{"install", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s-%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Remove returns the command and arguments for removing a package.
|
||||
func (y *DnfManager) Remove(pkg string, args []string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("dnf")
|
||||
baseArgs := []string{"remove", "-y", pkg}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Upgrade returns the command and arguments for upgrading a specific package.
|
||||
func (y *DnfManager) Upgrade(pkg, version string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("dnf")
|
||||
baseArgs := []string{"update", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s-%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// UpgradeAll returns the command and arguments for upgrading all packages.
|
||||
func (y *DnfManager) UpgradeAll() (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("dnf")
|
||||
baseArgs := []string{"update", "-y"}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// CheckVersion returns the command and arguments for checking the info of a specific package.
|
||||
func (d *DnfManager) CheckVersion(pkg, version string) (string, []string) {
|
||||
baseCmd := d.prependAuthCommand("dnf")
|
||||
baseArgs := []string{"info", pkg}
|
||||
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Parse parses the dnf info output to extract Installed and Candidate versions.
|
||||
func (d DnfManager) Parse(output string) (*pkgcommon.PackageVersion, error) {
|
||||
|
||||
// Check for error message in the output
|
||||
if strings.Contains(output, "No matching packages to list") {
|
||||
return nil, fmt.Errorf("error: package not listed")
|
||||
}
|
||||
|
||||
// Define regular expressions to capture installed and available versions
|
||||
reInstalled := regexp.MustCompile(`(?m)^Installed packages\s*Name\s*:\s*\S+\s*Epoch\s*:\s*\S+\s*Version\s*:\s*([^\s]+)\s*Release\s*:\s*([^\s]+)`)
|
||||
reAvailable := regexp.MustCompile(`(?m)^Available packages\s*Name\s*:\s*\S+\s*Epoch\s*:\s*\S+\s*Version\s*:\s*([^\s]+)\s*Release\s*:\s*([^\s]+)`)
|
||||
|
||||
installedMatch := reInstalled.FindStringSubmatch(output)
|
||||
candidateMatch := reAvailable.FindStringSubmatch(output)
|
||||
|
||||
installedVersion := ""
|
||||
candidateVersion := ""
|
||||
|
||||
if len(installedMatch) >= 3 {
|
||||
installedVersion = fmt.Sprintf("%s-%s", installedMatch[1], installedMatch[2])
|
||||
}
|
||||
|
||||
if len(candidateMatch) >= 3 {
|
||||
candidateVersion = fmt.Sprintf("%s-%s", candidateMatch[1], candidateMatch[2])
|
||||
}
|
||||
|
||||
if installedVersion == "" && candidateVersion == "" {
|
||||
return nil, fmt.Errorf("failed to parse versions from dnf output")
|
||||
}
|
||||
|
||||
return &pkgcommon.PackageVersion{
|
||||
Installed: installedVersion,
|
||||
Candidate: candidateVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// prependAuthCommand prepends the authentication command if UseAuth is true.
|
||||
func (y *DnfManager) prependAuthCommand(baseCmd string) string {
|
||||
if y.useAuth {
|
||||
return y.authCommand + " " + baseCmd
|
||||
}
|
||||
return baseCmd
|
||||
}
|
||||
|
||||
// SetUseAuth enables or disables authentication.
|
||||
func (y *DnfManager) SetUseAuth(useAuth bool) {
|
||||
y.useAuth = useAuth
|
||||
}
|
||||
|
||||
// SetAuthCommand sets the authentication command.
|
||||
func (y *DnfManager) SetAuthCommand(authCommand string) {
|
||||
y.authCommand = authCommand
|
||||
}
|
17
pkg/pkgman/pkgcommon/options.go
Normal file
17
pkg/pkgman/pkgcommon/options.go
Normal file
@ -0,0 +1,17 @@
|
||||
package pkgcommon
|
||||
|
||||
// PackageManagerOption defines a functional option for configuring a PackageManager.
|
||||
type PackageManagerOption func(interface{})
|
||||
|
||||
// PackageParser defines an interface for parsing package version information.
|
||||
type PackageParser interface {
|
||||
Parse(output string) (*PackageVersion, error)
|
||||
}
|
||||
|
||||
// PackageVersion represents the installed and candidate versions of a package.
|
||||
type PackageVersion struct {
|
||||
Installed string
|
||||
Candidate string
|
||||
Match bool
|
||||
Message string
|
||||
}
|
75
pkg/pkgman/pkgman.go
Normal file
75
pkg/pkgman/pkgman.go
Normal file
@ -0,0 +1,75 @@
|
||||
package pkgman
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/apt"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/dnf"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/pkgcommon"
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/yum"
|
||||
)
|
||||
|
||||
// PackageManager is an interface used to define common package commands. This shall be implemented by every package.
|
||||
type PackageManager interface {
|
||||
Install(pkg, version string, args []string) (string, []string)
|
||||
Remove(pkg string, args []string) (string, []string)
|
||||
Upgrade(pkg, version string) (string, []string) // Upgrade a specific package
|
||||
UpgradeAll() (string, []string)
|
||||
CheckVersion(pkg, version string) (string, []string)
|
||||
Parse(output string) (*pkgcommon.PackageVersion, error)
|
||||
// Configure applies functional options to customize the package manager.
|
||||
Configure(options ...pkgcommon.PackageManagerOption)
|
||||
}
|
||||
|
||||
// PackageManagerFactory returns the appropriate PackageManager based on the package tool.
|
||||
// Takes variable number of options.
|
||||
func PackageManagerFactory(managerType string, options ...pkgcommon.PackageManagerOption) (PackageManager, error) {
|
||||
var manager PackageManager
|
||||
|
||||
switch managerType {
|
||||
case "apt":
|
||||
manager = apt.NewAptManager()
|
||||
case "yum":
|
||||
manager = yum.NewYumManager()
|
||||
case "dnf":
|
||||
manager = dnf.NewDnfManager()
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported package manager: %s", managerType)
|
||||
}
|
||||
|
||||
// Apply options to the manager
|
||||
manager.Configure(options...)
|
||||
return manager, nil
|
||||
}
|
||||
|
||||
// WithAuth enables authentication and sets the authentication command.
|
||||
func WithAuth(authCommand string) pkgcommon.PackageManagerOption {
|
||||
return func(manager interface{}) {
|
||||
if configurable, ok := manager.(interface {
|
||||
SetUseAuth(bool)
|
||||
SetAuthCommand(string)
|
||||
}); ok {
|
||||
configurable.SetUseAuth(true)
|
||||
configurable.SetAuthCommand(authCommand)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// WithoutAuth disables authentication.
|
||||
func WithoutAuth() pkgcommon.PackageManagerOption {
|
||||
return func(manager interface{}) {
|
||||
if configurable, ok := manager.(interface {
|
||||
SetUseAuth(bool)
|
||||
}); ok {
|
||||
configurable.SetUseAuth(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ConfigurablePackageManager defines methods for setting configuration options.
|
||||
type ConfigurablePackageManager interface {
|
||||
pkgcommon.PackageParser
|
||||
SetUseAuth(useAuth bool)
|
||||
SetAuthCommand(authCommand string)
|
||||
SetPackageParser(parser pkgcommon.PackageParser)
|
||||
}
|
131
pkg/pkgman/yum/yum.go
Normal file
131
pkg/pkgman/yum/yum.go
Normal file
@ -0,0 +1,131 @@
|
||||
package yum
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/pkgman/pkgcommon"
|
||||
)
|
||||
|
||||
// YumManager implements PackageManager for systems using YUM.
|
||||
type YumManager struct {
|
||||
useAuth bool // Whether to use an authentication command
|
||||
authCommand string // The authentication command, e.g., "sudo"
|
||||
}
|
||||
|
||||
// DefaultAuthCommand is the default command used for authentication.
|
||||
const DefaultAuthCommand = "sudo"
|
||||
|
||||
// NewYumManager creates a new YumManager with default settings.
|
||||
func NewYumManager() *YumManager {
|
||||
return &YumManager{
|
||||
useAuth: true,
|
||||
authCommand: DefaultAuthCommand,
|
||||
}
|
||||
}
|
||||
|
||||
// Configure applies functional options to customize the package manager.
|
||||
func (y *YumManager) Configure(options ...pkgcommon.PackageManagerOption) {
|
||||
for _, opt := range options {
|
||||
opt(y)
|
||||
}
|
||||
}
|
||||
|
||||
// Install returns the command and arguments for installing a package.
|
||||
func (y *YumManager) Install(pkg, version string, args []string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("yum")
|
||||
baseArgs := []string{"install", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s-%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Remove returns the command and arguments for removing a package.
|
||||
func (y *YumManager) Remove(pkg string, args []string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("yum")
|
||||
baseArgs := []string{"remove", "-y", pkg}
|
||||
if args != nil {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Upgrade returns the command and arguments for upgrading a specific package.
|
||||
func (y *YumManager) Upgrade(pkg, version string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("yum")
|
||||
baseArgs := []string{"update", "-y"}
|
||||
if version != "" {
|
||||
baseArgs = append(baseArgs, fmt.Sprintf("%s-%s", pkg, version))
|
||||
} else {
|
||||
baseArgs = append(baseArgs, pkg)
|
||||
}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// UpgradeAll returns the command and arguments for upgrading all packages.
|
||||
func (y *YumManager) UpgradeAll() (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("yum")
|
||||
baseArgs := []string{"update", "-y"}
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// CheckVersion returns the command and arguments for checking the info of a specific package.
|
||||
func (y *YumManager) CheckVersion(pkg, version string) (string, []string) {
|
||||
baseCmd := y.prependAuthCommand("yum")
|
||||
baseArgs := []string{"info", pkg}
|
||||
|
||||
return baseCmd, baseArgs
|
||||
}
|
||||
|
||||
// Parse parses the dnf info output to extract Installed and Candidate versions.
|
||||
func (y YumManager) Parse(output string) (*pkgcommon.PackageVersion, error) {
|
||||
reInstalled := regexp.MustCompile(`(?m)^Installed Packages\s*Name\s*:\s*\S+\s*Version\s*:\s*([^\s]+)\s*Release\s*:\s*([^\s]+)`)
|
||||
reAvailable := regexp.MustCompile(`(?m)^Available Packages\s*Name\s*:\s*\S+\s*Version\s*:\s*([^\s]+)\s*Release\s*:\s*([^\s]+)`)
|
||||
|
||||
installedMatch := reInstalled.FindStringSubmatch(output)
|
||||
candidateMatch := reAvailable.FindStringSubmatch(output)
|
||||
|
||||
installedVersion := ""
|
||||
candidateVersion := ""
|
||||
|
||||
if len(installedMatch) >= 3 {
|
||||
installedVersion = fmt.Sprintf("%s-%s", installedMatch[1], installedMatch[2])
|
||||
}
|
||||
|
||||
if len(candidateMatch) >= 3 {
|
||||
candidateVersion = fmt.Sprintf("%s-%s", candidateMatch[1], candidateMatch[2])
|
||||
}
|
||||
|
||||
if installedVersion == "" && candidateVersion == "" {
|
||||
return nil, fmt.Errorf("failed to parse versions from dnf output")
|
||||
}
|
||||
|
||||
return &pkgcommon.PackageVersion{
|
||||
Installed: installedVersion,
|
||||
Candidate: candidateVersion,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// prependAuthCommand prepends the authentication command if UseAuth is true.
|
||||
func (y *YumManager) prependAuthCommand(baseCmd string) string {
|
||||
if y.useAuth {
|
||||
return y.authCommand + " " + baseCmd
|
||||
}
|
||||
return baseCmd
|
||||
}
|
||||
|
||||
// SetUseAuth enables or disables authentication.
|
||||
func (y *YumManager) SetUseAuth(useAuth bool) {
|
||||
y.useAuth = useAuth
|
||||
}
|
||||
|
||||
// SetAuthCommand sets the authentication command.
|
||||
func (y *YumManager) SetAuthCommand(authCommand string) {
|
||||
y.authCommand = authCommand
|
||||
}
|
186
pkg/remotefetcher/cache.go
Normal file
186
pkg/remotefetcher/cache.go
Normal file
@ -0,0 +1,186 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type CacheData struct {
|
||||
Hash string `yaml:"hash"`
|
||||
Path string `yaml:"path"`
|
||||
Type string `yaml:"type"`
|
||||
}
|
||||
|
||||
type Cache struct {
|
||||
mu sync.Mutex
|
||||
store map[string]CacheData
|
||||
file string
|
||||
dir string
|
||||
}
|
||||
|
||||
func NewCache(file, dir string) (*Cache, error) {
|
||||
cache := &Cache{
|
||||
store: make(map[string]CacheData),
|
||||
file: file,
|
||||
dir: dir,
|
||||
}
|
||||
err := cache.loadFromFile()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cache, nil
|
||||
}
|
||||
|
||||
func (c *Cache) loadFromFile() error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if _, err := os.Stat(c.file); os.IsNotExist(err) {
|
||||
return nil
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(c.file)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var cacheData []CacheData
|
||||
err = yaml.Unmarshal(data, &cacheData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for _, item := range cacheData {
|
||||
c.store[item.Hash] = item
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cache) saveToFile() error {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
var cacheData []CacheData
|
||||
for _, data := range c.store {
|
||||
cacheData = append(cacheData, data)
|
||||
}
|
||||
|
||||
data, err := yaml.Marshal(cacheData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return os.WriteFile(c.file, data, 0644)
|
||||
}
|
||||
|
||||
func (c *Cache) Get(hash string) ([]byte, CacheData, bool) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
cacheData, exists := c.store[hash]
|
||||
if !exists {
|
||||
return nil, CacheData{}, false
|
||||
}
|
||||
|
||||
data, err := os.ReadFile(cacheData.Path)
|
||||
if err != nil {
|
||||
return nil, CacheData{}, false
|
||||
}
|
||||
|
||||
return data, cacheData, true
|
||||
}
|
||||
|
||||
func (c *Cache) AddDataToStore(hash string, cacheData CacheData) error {
|
||||
c.store[hash] = cacheData
|
||||
return c.saveToFile()
|
||||
}
|
||||
|
||||
func (c *Cache) Set(source, hash string, data []byte, dataType string) (CacheData, error) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
fileName := filepath.Base(source)
|
||||
|
||||
path := filepath.Join(c.dir, fmt.Sprintf("%s-%s", fileName, hash))
|
||||
|
||||
if _, err := os.Stat(path); os.IsNotExist(err) {
|
||||
os.MkdirAll(c.dir, 0700)
|
||||
}
|
||||
|
||||
err := os.WriteFile(path, data, 0644)
|
||||
if err != nil {
|
||||
return CacheData{}, err
|
||||
}
|
||||
|
||||
cacheData := CacheData{
|
||||
Hash: hash,
|
||||
Path: path,
|
||||
Type: dataType,
|
||||
}
|
||||
|
||||
c.store[hash] = cacheData
|
||||
|
||||
// Unlock before calling saveToFile to avoid double-locking
|
||||
c.mu.Unlock()
|
||||
err = c.saveToFile()
|
||||
c.mu.Lock()
|
||||
if err != nil {
|
||||
return CacheData{}, err
|
||||
}
|
||||
|
||||
// fmt.Printf("Cache data: %v", cacheData)
|
||||
return cacheData, nil
|
||||
}
|
||||
|
||||
type CachedFetcher struct {
|
||||
data []byte
|
||||
path string
|
||||
dataType string
|
||||
}
|
||||
|
||||
func (cf *CachedFetcher) Fetch(source string) ([]byte, error) {
|
||||
return cf.data, nil
|
||||
}
|
||||
|
||||
func (cf *CachedFetcher) Parse(data []byte, target interface{}) error {
|
||||
if cf.dataType == "yaml" {
|
||||
return yaml.Unmarshal(data, target)
|
||||
}
|
||||
return errors.New("parse not supported on cached fetcher for scripts")
|
||||
}
|
||||
|
||||
func (cf *CachedFetcher) Hash(data []byte) string {
|
||||
hash := sha256.Sum256(data)
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
|
||||
// Function to read and parse the metadata file
|
||||
func LoadMetadataFromFile(filePath string) ([]*CacheData, error) {
|
||||
if _, err := os.Stat(filePath); os.IsNotExist(err) {
|
||||
// Create the file if it does not exist
|
||||
emptyData := []byte("[]")
|
||||
err := os.WriteFile(filePath, emptyData, 0644)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
data, err := os.ReadFile(filePath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var cacheData []*CacheData
|
||||
err = yaml.Unmarshal(data, &cacheData)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return cacheData, nil
|
||||
}
|
76
pkg/remotefetcher/configfetcher.go
Normal file
76
pkg/remotefetcher/configfetcher.go
Normal file
@ -0,0 +1,76 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type RemoteFetcher interface {
|
||||
// Fetch retrieves the configuration from the specified URL or source
|
||||
// Returns the raw data as bytes or an error
|
||||
Fetch(source string) ([]byte, error)
|
||||
|
||||
// Parse decodes the raw data into a Go structure (e.g., Commands, CommandLists)
|
||||
// Takes the raw data as input and populates the target interface
|
||||
Parse(data []byte, target interface{}) error
|
||||
|
||||
// Hash returns the hash of the configuration data
|
||||
Hash(data []byte) string
|
||||
}
|
||||
|
||||
// ErrIgnoreFileNotFound is returned when the file is not found and should be ignored
|
||||
var ErrIgnoreFileNotFound = errors.New("remotefetcher: file not found")
|
||||
|
||||
func NewRemoteFetcher(source string, cache *Cache, options ...FetcherOption) (RemoteFetcher, error) {
|
||||
var fetcher RemoteFetcher
|
||||
|
||||
config := FetcherConfig{}
|
||||
for _, option := range options {
|
||||
option(&config)
|
||||
}
|
||||
|
||||
// If FileType is empty (i.e. WithFileType was not called), yaml is the default file type
|
||||
if strings.TrimSpace(config.FileType) == "" {
|
||||
config.FileType = "yaml"
|
||||
}
|
||||
if strings.HasPrefix(source, "http") || strings.HasPrefix(source, "https") {
|
||||
fetcher = NewHTTPFetcher(options...)
|
||||
} else if strings.HasPrefix(source, "s3") {
|
||||
var err error
|
||||
fetcher, err = NewS3Fetcher(source, options...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
} else {
|
||||
fetcher = &LocalFetcher{}
|
||||
|
||||
return fetcher, nil
|
||||
}
|
||||
|
||||
//TODO: should local files be cached?
|
||||
|
||||
data, err := fetcher.Fetch(source)
|
||||
if err != nil {
|
||||
if config.IgnoreFileNotFound && isFileNotFoundError(err) {
|
||||
return nil, ErrIgnoreFileNotFound
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hash := fetcher.Hash(data)
|
||||
if cachedData, cacheMeta, exists := cache.Get(hash); exists {
|
||||
return &CachedFetcher{data: cachedData, path: cacheMeta.Path, dataType: cacheMeta.Type}, nil
|
||||
}
|
||||
|
||||
cacheData, err := cache.Set(source, hash, data, config.FileType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &CachedFetcher{data: data, path: cacheData.Path, dataType: cacheData.Type}, nil
|
||||
}
|
||||
|
||||
func isFileNotFoundError(err error) bool {
|
||||
// Implement logic to check if the error is a "file not found" error
|
||||
// This can be based on the error type or message
|
||||
return strings.Contains(err.Error(), "file not found")
|
||||
}
|
60
pkg/remotefetcher/http.go
Normal file
60
pkg/remotefetcher/http.go
Normal file
@ -0,0 +1,60 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type HTTPFetcher struct {
|
||||
HTTPClient *http.Client
|
||||
config FetcherConfig
|
||||
}
|
||||
|
||||
// NewHTTPFetcher creates a new instance of HTTPFetcher with the provided options.
|
||||
func NewHTTPFetcher(options ...FetcherOption) *HTTPFetcher {
|
||||
cfg := &FetcherConfig{}
|
||||
for _, opt := range options {
|
||||
opt(cfg)
|
||||
}
|
||||
|
||||
// Initialize HTTP client if not provided
|
||||
if cfg.HTTPClient == nil {
|
||||
cfg.HTTPClient = http.DefaultClient
|
||||
}
|
||||
|
||||
return &HTTPFetcher{HTTPClient: cfg.HTTPClient, config: *cfg}
|
||||
}
|
||||
|
||||
// Fetch retrieves the file from the specified source URL
|
||||
func (h *HTTPFetcher) Fetch(source string) ([]byte, error) {
|
||||
resp, err := http.Get(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode == http.StatusNotFound && h.config.IgnoreFileNotFound {
|
||||
return nil, ErrIgnoreFileNotFound
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return nil, errors.New("failed to fetch remote config: " + resp.Status)
|
||||
}
|
||||
|
||||
return io.ReadAll(resp.Body)
|
||||
}
|
||||
|
||||
// Parse decodes the raw data into the provided target structure
|
||||
func (h *HTTPFetcher) Parse(data []byte, target interface{}) error {
|
||||
return yaml.Unmarshal(data, target)
|
||||
}
|
||||
|
||||
func (h *HTTPFetcher) Hash(data []byte) string {
|
||||
hash := sha256.Sum256(data)
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
42
pkg/remotefetcher/local.go
Normal file
42
pkg/remotefetcher/local.go
Normal file
@ -0,0 +1,42 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type LocalFetcher struct {
|
||||
config FetcherConfig
|
||||
}
|
||||
|
||||
// Fetch retrieves the file from the specified local file path
|
||||
func (l *LocalFetcher) Fetch(source string) ([]byte, error) {
|
||||
// Check if the file exists
|
||||
if _, err := os.Stat(source); os.IsNotExist(err) {
|
||||
if l.config.IgnoreFileNotFound {
|
||||
return nil, ErrIgnoreFileNotFound
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
file, err := os.Open(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
return io.ReadAll(file)
|
||||
}
|
||||
|
||||
// Parse decodes the raw data into the provided target structure
|
||||
func (l *LocalFetcher) Parse(data []byte, target interface{}) error {
|
||||
return yaml.Unmarshal(data, target)
|
||||
}
|
||||
|
||||
func (l *LocalFetcher) Hash(data []byte) string {
|
||||
hash := sha256.Sum256(data)
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
49
pkg/remotefetcher/options.go
Normal file
49
pkg/remotefetcher/options.go
Normal file
@ -0,0 +1,49 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/aws/aws-sdk-go-v2/service/s3"
|
||||
)
|
||||
|
||||
// Option is a function that configures a fetcher.
|
||||
type FetcherOption func(*FetcherConfig)
|
||||
|
||||
// FetcherConfig holds the configuration for a fetcher.
|
||||
type FetcherConfig struct {
|
||||
S3Client *s3.Client
|
||||
HTTPClient *http.Client
|
||||
FileType string
|
||||
IgnoreFileNotFound bool
|
||||
}
|
||||
|
||||
// WithS3Client sets the S3 client for the fetcher.
|
||||
func WithS3Client(client *s3.Client) FetcherOption {
|
||||
return func(cfg *FetcherConfig) {
|
||||
cfg.S3Client = client
|
||||
}
|
||||
}
|
||||
|
||||
// WithHTTPClient sets the HTTP client for the fetcher.
|
||||
func WithHTTPClient(client *http.Client) FetcherOption {
|
||||
return func(cfg *FetcherConfig) {
|
||||
cfg.HTTPClient = client
|
||||
}
|
||||
}
|
||||
|
||||
func IgnoreFileNotFound() FetcherOption {
|
||||
return func(cfg *FetcherConfig) {
|
||||
cfg.IgnoreFileNotFound = true
|
||||
}
|
||||
}
|
||||
|
||||
// WithFileType ensures the default FileType will be yaml
|
||||
func WithFileType(fileType string) FetcherOption {
|
||||
return func(cfg *FetcherConfig) {
|
||||
cfg.FileType = fileType
|
||||
if strings.TrimSpace(fileType) == "" {
|
||||
cfg.FileType = "yaml"
|
||||
}
|
||||
}
|
||||
}
|
162
pkg/remotefetcher/s3.go
Normal file
162
pkg/remotefetcher/s3.go
Normal file
@ -0,0 +1,162 @@
|
||||
package remotefetcher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/minio/minio-go/v7"
|
||||
"github.com/minio/minio-go/v7/pkg/credentials"
|
||||
"github.com/mitchellh/go-homedir"
|
||||
"gopkg.in/yaml.v3"
|
||||
)
|
||||
|
||||
type S3Fetcher struct {
|
||||
S3Client *minio.Client
|
||||
config FetcherConfig
|
||||
}
|
||||
|
||||
// NewS3Fetcher creates a new instance of S3Fetcher with the provided options.
|
||||
func NewS3Fetcher(endpoint string, options ...FetcherOption) (*S3Fetcher, error) {
|
||||
cfg := &FetcherConfig{}
|
||||
var s3Client *minio.Client
|
||||
var err error
|
||||
for _, opt := range options {
|
||||
opt(cfg)
|
||||
}
|
||||
|
||||
/*
|
||||
options for S3 urls:
|
||||
1. s3://bucket.region.endpoint.tld/path/to/object
|
||||
2. alias with path and rest is looked up in file - add FetcherOptions
|
||||
|
||||
|
||||
options for S3 credentials:
|
||||
1. from file ($HOME/.aws/credentials)
|
||||
2. env vars (AWS_SECRET_KEY, etc.)
|
||||
*/
|
||||
|
||||
s3Endpoint := os.Getenv("S3_ENDPOINT")
|
||||
creds, err := getS3Credentials("default", s3Endpoint, cfg.HTTPClient)
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
return nil, err
|
||||
}
|
||||
// Initialize S3 client if not provided
|
||||
if cfg.S3Client == nil {
|
||||
s3Client, err = minio.New(s3Endpoint, &minio.Options{
|
||||
Creds: creds,
|
||||
Secure: true,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return &S3Fetcher{S3Client: s3Client, config: *cfg}, nil
|
||||
}
|
||||
|
||||
// Fetch retrieves the configuration from an S3 bucket
|
||||
// Source should be in the format "bucket-name/object-key"
|
||||
func (s *S3Fetcher) Fetch(source string) ([]byte, error) {
|
||||
bucket, object, err := parseS3Source(source)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
doesObjectExist, objErr := objectExists(bucket, object, s.S3Client)
|
||||
if !doesObjectExist {
|
||||
if objErr != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if s.config.IgnoreFileNotFound {
|
||||
return nil, ErrIgnoreFileNotFound
|
||||
}
|
||||
}
|
||||
|
||||
fileObject, err := s.S3Client.GetObject(context.TODO(), bucket, object, minio.GetObjectOptions{})
|
||||
if err != nil {
|
||||
println(err.Error())
|
||||
|
||||
return nil, err
|
||||
}
|
||||
defer fileObject.Close()
|
||||
fileObjectStats, statErr := fileObject.Stat()
|
||||
if statErr != nil {
|
||||
return nil, statErr
|
||||
}
|
||||
buffer := make([]byte, fileObjectStats.Size)
|
||||
|
||||
// Read the object into the buffer
|
||||
_, err = io.ReadFull(fileObject, buffer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return buffer, nil
|
||||
}
|
||||
|
||||
// Parse decodes the raw data into the provided target structure
|
||||
func (s *S3Fetcher) Parse(data []byte, target interface{}) error {
|
||||
return yaml.Unmarshal(data, target)
|
||||
}
|
||||
|
||||
// Helper function to parse S3 source into bucket and key
|
||||
func parseS3Source(source string) (bucket, key string, err error) {
|
||||
parts := strings.SplitN(source, "/", 2)
|
||||
if len(parts) != 2 {
|
||||
return "", "", errors.New("invalid S3 source format, expected bucket-name/object-key")
|
||||
}
|
||||
u, _ := url.Parse(source)
|
||||
u.Path = strings.TrimPrefix(u.Path, "/")
|
||||
return u.Host, u.Path, nil
|
||||
}
|
||||
|
||||
func (s *S3Fetcher) Hash(data []byte) string {
|
||||
hash := sha256.Sum256(data)
|
||||
return hex.EncodeToString(hash[:])
|
||||
}
|
||||
|
||||
func getS3Credentials(profile, host string, httpClient *http.Client) (*credentials.Credentials, error) {
|
||||
// println(s3utils.GetRegionFromURL(*u))
|
||||
homeDir, hdirErr := homedir.Dir()
|
||||
if hdirErr != nil {
|
||||
return nil, hdirErr
|
||||
}
|
||||
s3Creds := credentials.NewFileAWSCredentials(path.Join(homeDir, ".aws", "credentials"), "default")
|
||||
credVals, credErr := s3Creds.GetWithContext(&credentials.CredContext{Endpoint: host, Client: httpClient})
|
||||
if credErr != nil {
|
||||
return nil, credErr
|
||||
}
|
||||
creds := credentials.NewStaticV4(credVals.AccessKeyID, credVals.SecretAccessKey, "")
|
||||
return creds, nil
|
||||
}
|
||||
|
||||
var (
|
||||
doesNotExist = "The specified key does not exist."
|
||||
)
|
||||
|
||||
// objectExists checks for name in bucket using client.
|
||||
// It returns false and nil if the key does not exist
|
||||
func objectExists(bucket, name string, client *minio.Client) (bool, error) {
|
||||
_, err := client.StatObject(context.TODO(), bucket, name, minio.StatObjectOptions{})
|
||||
if err != nil {
|
||||
switch err.Error() {
|
||||
case doesNotExist:
|
||||
return false, nil
|
||||
default:
|
||||
return false, errors.Join(err, errors.New("error stating object"))
|
||||
}
|
||||
}
|
||||
return true, nil
|
||||
}
|
7
pkg/usermanager/common/options.go
Normal file
7
pkg/usermanager/common/options.go
Normal file
@ -0,0 +1,7 @@
|
||||
package common
|
||||
|
||||
// ConfigurablePackageManager defines methods for setting configuration options.
|
||||
type ConfigurableUserManager interface {
|
||||
SetUseAuth(useAuth bool)
|
||||
SetAuthCommand(authCommand string)
|
||||
}
|
90
pkg/usermanager/linux/linux.go
Normal file
90
pkg/usermanager/linux/linux.go
Normal file
@ -0,0 +1,90 @@
|
||||
package linux
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
passGen "github.com/sethvargo/go-password/password"
|
||||
)
|
||||
|
||||
// LinuxUserManager implements UserManager for Linux systems.
|
||||
type LinuxUserManager struct{}
|
||||
|
||||
func (l LinuxUserManager) NewLinuxManager() *LinuxUserManager {
|
||||
return &LinuxUserManager{}
|
||||
}
|
||||
|
||||
// AddUser adds a new user to the system.
|
||||
func (l LinuxUserManager) AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string) {
|
||||
baseArgs := []string{}
|
||||
|
||||
if isSystem {
|
||||
baseArgs = append(baseArgs, "--system")
|
||||
}
|
||||
|
||||
if homeDir != "" {
|
||||
baseArgs = append(baseArgs, "--home", homeDir)
|
||||
}
|
||||
|
||||
if shell != "" {
|
||||
baseArgs = append(baseArgs, "--shell", shell)
|
||||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
baseArgs = append(baseArgs, "--groups", strings.Join(groups, ","))
|
||||
}
|
||||
|
||||
if len(args) > 0 {
|
||||
baseArgs = append(baseArgs, args...)
|
||||
}
|
||||
|
||||
args = append(baseArgs, username)
|
||||
|
||||
cmd := "useradd"
|
||||
return cmd, args
|
||||
}
|
||||
|
||||
func (l LinuxUserManager) ModifyPassword(username, password string) (string, *strings.Reader, string) {
|
||||
cmd := "chpasswd"
|
||||
if password == "" {
|
||||
password = passGen.MustGenerate(20, 5, 5, false, false)
|
||||
}
|
||||
stdin := strings.NewReader(fmt.Sprintf("%s:%s", username, password))
|
||||
return cmd, stdin, password
|
||||
}
|
||||
|
||||
// RemoveUser removes an existing user from the system.
|
||||
func (l LinuxUserManager) RemoveUser(username string) (string, []string) {
|
||||
cmd := "userdel"
|
||||
|
||||
return cmd, []string{username}
|
||||
}
|
||||
|
||||
// ModifyUser modifies an existing user's details.
|
||||
func (l LinuxUserManager) ModifyUser(username, homeDir, shell string, groups []string) (string, []string) {
|
||||
args := []string{}
|
||||
|
||||
if homeDir != "" {
|
||||
args = append(args, "--home", homeDir)
|
||||
}
|
||||
|
||||
if shell != "" {
|
||||
args = append(args, "--shell", shell)
|
||||
}
|
||||
|
||||
if len(groups) > 0 {
|
||||
args = append(args, "--groups", strings.Join(groups, ","))
|
||||
}
|
||||
|
||||
args = append(args, username)
|
||||
|
||||
cmd := "usermod"
|
||||
|
||||
return cmd, args
|
||||
}
|
||||
|
||||
// UserExists checks if a user exists on the system.
|
||||
func (l LinuxUserManager) UserExists(username string) (string, []string) {
|
||||
cmd := "id"
|
||||
return cmd, []string{username}
|
||||
}
|
36
pkg/usermanager/userman.go
Normal file
36
pkg/usermanager/userman.go
Normal file
@ -0,0 +1,36 @@
|
||||
package usermanager
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.andrewnw.xyz/CyberShell/backy/pkg/usermanager/linux"
|
||||
)
|
||||
|
||||
// UserManager defines the interface for user management operations.
|
||||
// All functions but one return a string for the command and any args.
|
||||
type UserManager interface {
|
||||
AddUser(username, homeDir, shell string, isSystem bool, groups, args []string) (string, []string)
|
||||
RemoveUser(username string) (string, []string)
|
||||
ModifyUser(username, homeDir, shell string, groups []string) (string, []string)
|
||||
// Modify password uses chpasswd for Linux systems to build the command to change the password
|
||||
// Should return a password as the last argument
|
||||
// TODO: refactor when adding more systems instead of Linux
|
||||
ModifyPassword(username, password string) (string, *strings.Reader, string)
|
||||
UserExists(username string) (string, []string)
|
||||
}
|
||||
|
||||
// NewUserManager returns a UserManager-compatible struct
|
||||
func NewUserManager(system string) (UserManager, error) {
|
||||
var manager UserManager
|
||||
|
||||
switch system {
|
||||
case "linux", "Linux":
|
||||
manager = linux.LinuxUserManager{}
|
||||
default:
|
||||
return nil, fmt.Errorf("usermanger system %s is not recognized", system)
|
||||
}
|
||||
|
||||
return manager, nil
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user