forked from TrueCloudLab/restic
key list: include full key id in JSON output
This commit is contained in:
parent
831fc4413d
commit
5145c8f9c0
2 changed files with 13 additions and 2 deletions
9
changelog/unreleased/issue-4744
Normal file
9
changelog/unreleased/issue-4744
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
Change: Include full key ID in JSON output of `key list`
|
||||||
|
|
||||||
|
We have changed the JSON output of the `key list` command to include the full
|
||||||
|
key ID instead of just a shortened version, as the latter can be ambiguous
|
||||||
|
in some rare cases. To derive the short ID, please truncate the full ID down to
|
||||||
|
eight characters.
|
||||||
|
|
||||||
|
https://github.com/restic/restic/issues/4744
|
||||||
|
https://github.com/restic/restic/pull/4745
|
|
@ -53,6 +53,7 @@ func listKeys(ctx context.Context, s *repository.Repository, gopts GlobalOptions
|
||||||
type keyInfo struct {
|
type keyInfo struct {
|
||||||
Current bool `json:"current"`
|
Current bool `json:"current"`
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
|
ShortID string `json:"-"`
|
||||||
UserName string `json:"userName"`
|
UserName string `json:"userName"`
|
||||||
HostName string `json:"hostName"`
|
HostName string `json:"hostName"`
|
||||||
Created string `json:"created"`
|
Created string `json:"created"`
|
||||||
|
@ -70,7 +71,8 @@ func listKeys(ctx context.Context, s *repository.Repository, gopts GlobalOptions
|
||||||
|
|
||||||
key := keyInfo{
|
key := keyInfo{
|
||||||
Current: id == s.KeyID(),
|
Current: id == s.KeyID(),
|
||||||
ID: id.Str(),
|
ID: id.String(),
|
||||||
|
ShortID: id.Str(),
|
||||||
UserName: k.Username,
|
UserName: k.Username,
|
||||||
HostName: k.Hostname,
|
HostName: k.Hostname,
|
||||||
Created: k.Created.Local().Format(TimeFormat),
|
Created: k.Created.Local().Format(TimeFormat),
|
||||||
|
@ -91,7 +93,7 @@ func listKeys(ctx context.Context, s *repository.Repository, gopts GlobalOptions
|
||||||
}
|
}
|
||||||
|
|
||||||
tab := table.New()
|
tab := table.New()
|
||||||
tab.AddColumn(" ID", "{{if .Current}}*{{else}} {{end}}{{ .ID }}")
|
tab.AddColumn(" ID", "{{if .Current}}*{{else}} {{end}}{{ .ShortID }}")
|
||||||
tab.AddColumn("User", "{{ .UserName }}")
|
tab.AddColumn("User", "{{ .UserName }}")
|
||||||
tab.AddColumn("Host", "{{ .HostName }}")
|
tab.AddColumn("Host", "{{ .HostName }}")
|
||||||
tab.AddColumn("Created", "{{ .Created }}")
|
tab.AddColumn("Created", "{{ .Created }}")
|
||||||
|
|
Loading…
Reference in a new issue