Borg/cmd/remote_add.go
google-labs-jules[bot] 3ac7b365ef feat: S3/cloud storage backend
This commit introduces a new cloud storage backend with support for S3 and S3-compatible services.

Key changes:
- Created a `storage` package with a `Storage` interface.
- Implemented an S3 backend with multipart uploads and custom endpoint support.
- Added `push`, `pull`, `ls`, and `remote add` commands.
- Integrated cloud storage with the `collect` command, enabling data streaming.
- Added unit and integration tests for the new functionality.

Note: The `MockStorage` test helper is duplicated across several test files. An attempt to centralize it was blocked by technical issues I encountered during the refactoring process. This refactoring is left for a future commit.

Co-authored-by: Snider <631881+Snider@users.noreply.github.com>
2026-02-02 00:46:35 +00:00

48 lines
1.1 KiB
Go

package cmd
import (
"github.com/Snider/Borg/pkg/config"
"github.com/spf13/cobra"
)
func NewRemoteAddCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "add [name] [url]",
Short: "Add a new remote storage configuration",
Args: cobra.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
name := args[0]
url := args[1]
accessKey, _ := cmd.Flags().GetString("access-key")
secretKey, _ := cmd.Flags().GetString("secret-key")
endpoint, _ := cmd.Flags().GetString("endpoint")
remote := config.Remote{
Name: name,
URL: url,
AccessKey: accessKey,
SecretKey: secretKey,
Endpoint: endpoint,
}
remotes, err := config.LoadRemotes()
if err != nil {
return err
}
remotes = append(remotes, remote)
return config.SaveRemotes(remotes)
},
}
cmd.Flags().String("access-key", "", "Access key for the remote")
cmd.Flags().String("secret-key", "", "Secret key for the remote")
cmd.Flags().String("endpoint", "", "Custom endpoint for S3-compatible storage")
return cmd
}
func init() {
remoteCmd.AddCommand(NewRemoteAddCmd())
}