From 3026baea0762a2245a4d5c1743188ca9c6b1ba95 Mon Sep 17 00:00:00 2001 From: Gabriel Kabbe Date: Mon, 27 Nov 2023 21:04:24 +0100 Subject: [PATCH] rewrite: Add structs for tracking metadata changes Adds * snapshotMetadataArgs, which holds the new metadata as strings parsed from the command line * snapshotMetadata, which holds the new metadata converted to the correct types --- cmd/restic/cmd_rewrite.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/restic/cmd_rewrite.go b/cmd/restic/cmd_rewrite.go index 2d5c5716d..183df9a09 100644 --- a/cmd/restic/cmd_rewrite.go +++ b/cmd/restic/cmd_rewrite.go @@ -3,6 +3,7 @@ package main import ( "context" "fmt" + "time" "github.com/spf13/cobra" "golang.org/x/sync/errgroup" @@ -46,16 +47,28 @@ Exit status is 0 if the command was successful, and non-zero if there was any er }, } +type snapshotMetadata struct { + Hostname string + Time *time.Time +} + +type SnapshotMetadataArgs struct { + Hostname string + Time string +} + // RewriteOptions collects all options for the rewrite command. type RewriteOptions struct { - Forget bool - DryRun bool + Forget bool + DryRun bool + Metadata *SnapshotMetadataArgs restic.SnapshotFilter excludePatternOptions } var rewriteOptions RewriteOptions +var metadataOptions SnapshotMetadataArgs func init() { cmdRoot.AddCommand(cmdRewrite)