Skip to content

Commit

Permalink
stub and use unified storage transfer and config interface
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuchard committed Sep 20, 2024
1 parent 31156d3 commit 297c953
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func main() {
log.Print("Vault configuration failed validation")
log.Fatal(err)
}
awsConfig, err := storage.NewAWSConfig(backupConfig.AWSConfig)
storageConfig, err := storage.NewConfig(backupConfig.AWSConfig)
if err != nil {
log.Print("AWS configuration failed validation")
log.Fatal(err)
Expand All @@ -46,7 +46,7 @@ func main() {
}

// upload snapshot to aws s3
_, err = storage.SnapshotS3Upload(awsConfig, snapshotFile.Name(), backupConfig.SnapshotCleanup)
_, err = storage.StorageTransfer(storageConfig, snapshotFile.Name(), backupConfig.SnapshotCleanup)
if err != nil && err.Error() != "snapshot not found" && err.Error() != "snapshot not removed" {
// not an error from failed removal so error is actually fatal
log.Print("S3 upload failed")
Expand Down
7 changes: 7 additions & 0 deletions storage/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package storage

import "github.com/mschuchard/vault-raft-backup/util"

func NewConfig(backupConfig *util.AWSConfig) (*awsConfig, error) {
return NewAWSConfig(backupConfig)
}
7 changes: 7 additions & 0 deletions storage/storage.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package storage

import "github.com/aws/aws-sdk-go/service/s3/s3manager"

func StorageTransfer(config *awsConfig, snapshotPath string, cleanup bool) (*s3manager.UploadOutput, error) {
return SnapshotS3Upload(config, snapshotPath, cleanup)
}

0 comments on commit 297c953

Please sign in to comment.