Commit Graph

57 Commits

Author SHA1 Message Date
Michael Eischer 6d2d297215 pass global context through cobra 2022-10-03 00:19:46 +02:00
Michael Eischer 928914f821 Prepare for context bound to lock lifetime 2022-10-03 00:19:46 +02:00
Michael Eischer 985722b102 Remove ctx from globalOptions
Previously the global context was either accessed via gopts.ctx,
stored in a local variable and then used within that function or
sometimes both. This makes it very hard to follow which ctx or a wrapped
version of it reaches which method.

Thus just drop the context from the globalOptions struct and pass it
explicitly to every command line handler method.
2022-10-03 00:19:46 +02:00
Michael Eischer ab819b2344 key: Cleanup method signatures 2022-10-03 00:19:46 +02:00
Michael Eischer d0668b695d Remove unnecessary context.WithCancel calls
The gopts.ctx is cancelled when the main() method of restic exits.
2022-10-03 00:19:46 +02:00
Michael Eischer 6add186867 key: Check that a new key file actually works 2021-06-12 23:09:19 +02:00
Michael Eischer 0c9efa9c2a Pass context to lockRepo 2020-10-09 22:39:06 +02:00
Michael Eischer c458e114d4 pass context to Find / FindSnapshot
This allows proper interruption of restic while it searches for
snapshots or key files.
2020-10-09 22:37:56 +02:00
Leo R. Lundgren 311ad2d2d0 Improve wording for --password-file and related options 2020-09-19 15:47:32 +02:00
Jason Cox 2447f3f110 Update usage strings to put flags before args
The standard UNIX-style ordering of command-line arguments places
optional flags before other positional arguments. All of restic's
commands support this ordering, but some of the usage strings showed the
flags after the positional arguments (which restic also parses just
fine). This change updates the doc strings to reflect the standard
ordering.

Because the `restic help` command comes directly from Cobra, there does
not appear to be a way to update the argument ordering in its usage
string, so it maintains the non-standard ordering (positional arguments
before optional flags).
2020-08-28 02:16:22 +00:00
Bruce Dillahunty fe69b83074
Update key password prompt (#2847) 2020-08-19 21:42:08 +02:00
Peter Schultz 90fc639a67 Allow specifying user and host when adding keys
The username and hostname for new keys can be specified with the new
--user and --host flags, respectively. The flags are used only by the
`key add` command and are otherwise ignored.

This allows adding keys with for a desired user and host without having
to run restic as that particular user on that particular host, making
automated key management easier.

Co-authored-by: James TD Smith <ahktenzero@mohorovi.cc>
2020-03-23 13:11:10 +01:00
Erik Rigtorp 94f4f13388 Add documentation on exit status codes to man pages
This is step one to start defining useful exit codes for all the commands.
2020-02-12 23:09:26 +01:00
Alexander Neumann c012fccd22 Display local time for all commands 2018-11-02 20:36:15 +01:00
Alexander Neumann 76387b6cd0 Remove old text table implementation 2018-08-20 22:00:23 +02:00
Steve Kriss 5088905502 add JSON output support for restic key list cmd
Signed-off-by: Steve Kriss <steve@heptio.com>
2018-06-18 15:26:26 -07:00
Matthew Holt c5829e9ffc key: Add flag for non-interactive password changes 2018-04-20 14:29:39 +02:00
Alexander Neumann b0c6e53241 Fix calls to repo/backend.List() everywhere 2018-01-21 21:15:09 +01:00
George Armhold 1695c8ed55 use global context for check, debug, dump, find, forget, init, key,
list, mount, tag, unlock commands

gh-1434
2017-12-06 07:02:55 -05:00
Shayne Holmes 9eb39cef05 Capitalize short help commands
Unify existing Cobra help command, and git-help's style.
2017-09-11 09:32:44 -07:00
Ricardo Seriani 62ed776a8c Change key rm command to key remove
Change key rm command to key remove, to follow manual and other commands
2017-08-17 11:03:26 -03:00
Alexander Neumann 6bc43a4198 manpage: Remove auto gen tag from man page 2017-08-06 21:31:01 +02:00
Pauline Middelink d5615a67c8 Refactor password resolving.
Instead of determining the password lazily during ReadPassword(), do so now in
cobra.PersistentPreRunE() so we can store the result in the globalOptions and
reuse/override when applicable without having to worry about the environment
or flag options interfering.
2017-07-24 23:05:37 +02:00
Pauline Middelink d9b9bbd4a8 Force restic to ask the password when adding a key.
As `restic key add` uses the same `ReadPasswordTwice()` as the
rest of restic, it is sensitive to the environment variable
RESTIC_PASSWORD or --password-file= override.

When asking for the new key, temporary remove these 2 overrides, forcing
the password to be asked.
2017-07-24 22:00:44 +02:00
Alexander Neumann 23c903074c Move restic package to internal/restic 2017-07-24 17:43:32 +02:00
Alexander Neumann 6caeff2408 Run goimports 2017-07-23 14:21:03 +02:00
Alexander Neumann 83d1a46526 Moves files 2017-07-23 14:19:13 +02:00
Alexander Neumann b63399d606 Move things around for gb
This moves all restic source files to src/, and all vendored
dependencies to vendor/src.
2016-02-20 17:31:20 +01:00
Alexander Neumann 47212dde8c cmd/restic: Do not require exclusive lock for listing keys 2015-06-28 13:52:22 +02:00
Alexander Neumann 13e9a35f96 cmd/restic: Add lock handling, interrupt cleanup 2015-06-28 13:52:22 +02:00
Alexander Neumann 65a0def949 cmd/restic: Add locks to commands 2015-06-28 13:52:22 +02:00
Alexander Neumann 7d2699b429 cmd/restic: Rename variable, no functional changes 2015-06-28 13:52:22 +02:00
Alexander Neumann cfaf8ab8a6 Add integration test for key handling 2015-06-21 17:40:22 +02:00
Alexander Neumann a99a460b32 Fix integration tests 2015-06-21 17:40:22 +02:00
Alexander Neumann 4388474cdc Restructure `cmd/restic`, no functional changes 2015-06-21 17:40:22 +02:00
Alexander Neumann f5537e7a0e Refactor configuration of cache dir and repository 2015-06-07 18:15:03 +02:00
Alexander Neumann af381c2ab0 Remove Repository.Remove() 2015-05-17 20:58:22 +02:00
Alexander Neumann 6e38a8a033 Move FindSnapshot, make Repository.List() return IDs 2015-05-17 20:58:22 +02:00
Alexander Neumann 95536e8a21 Rename 'Repo' -> 'Repository' 2015-05-09 23:59:58 +02:00
Alexander Neumann 232c472836 Move package 'repo' to package 'repository' 2015-05-09 23:52:03 +02:00
Alexander Neumann ae21938f3e Rename 'Repository' -> Repo 2015-05-09 17:41:28 +02:00
Alexander Neumann d9b5832034 Rename variables 2015-05-09 13:47:21 +02:00
Alexander Neumann 87ebf12945 Rename 'Server' to 'Repository' 2015-05-09 13:25:52 +02:00
Alexander Neumann 8be9e95d20 Rename package 'server' to 'repo' 2015-05-09 13:24:15 +02:00
Alexander Neumann 1213d87b1a server: Only save crypto.Key
At the moment, the server doesn't need the full server.Key (master and
user key), just the master key.
2015-05-03 18:56:20 +02:00
Alexander Neumann d19b23d4f1 Move Server and Key to new sub-package 2015-04-26 14:46:15 +02:00
Alexander Neumann 87a1946417 Merge remote-tracking branch 'fw42/rename_change_to_passwd' 2015-04-25 11:11:27 +02:00
Florian Weingarten dead2b7e93 rename "change" to "passwd" 2015-04-25 02:44:26 -04:00
Florian Weingarten ebae478631 Prefer mixedCaps over underscore 2015-04-24 19:39:32 -04:00
Alexander Neumann 5e69788eac Refactor backends 2015-03-28 14:36:50 +01:00