Skip to content

Commit 104a483

Browse files
authored
STAC-24338: Fix stackgraph restore --latest when S3 prefix is set (#16)
1 parent a833df2 commit 104a483

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

cmd/stackgraph/restore.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"fmt"
66
"sort"
77
"strconv"
8+
"strings"
89
"time"
910

1011
"github.com/aws/aws-sdk-go-v2/aws"
@@ -187,8 +188,8 @@ func getLatestBackup(k8sClient *k8s.Client, namespace string, config *config.Con
187188
sort.Slice(filteredObjects, func(i, j int) bool {
188189
return filteredObjects[i].LastModified.After(filteredObjects[j].LastModified)
189190
})
190-
191-
return filteredObjects[0].Key, nil
191+
latestBackup := strings.TrimPrefix(filteredObjects[0].Key, prefix)
192+
return latestBackup, nil
192193
}
193194

194195
// buildPVCSpec builds a PVCSpec from configuration

0 commit comments

Comments
 (0)