serverless arch

This commit is contained in:
2025-05-11 02:32:33 +02:00
parent 15b1efcc48
commit 30c71cb449
8 changed files with 291 additions and 27 deletions

32
pkg/sync/ssh/ssh.go Normal file
View File

@@ -0,0 +1,32 @@
package ssh
import (
"cloudsave/pkg/remote"
"fmt"
"log"
"os/user"
)
type (
SFTPSyncer struct {
}
)
func (SFTPSyncer) Sync(r remote.Remote) error {
currentUser, err := user.Current()
if err != nil {
log.Fatalf("Failed to get current user: %v", err)
}
cli, err := remote.ConnectWithKey(r.URL, currentUser.Username)
if err != nil {
cli, err = remote.ConnectWithPassword(r.URL, currentUser.Username)
if err != nil {
return fmt.Errorf("failed to connect to host: %w", err)
}
}
defer cli.Close()
return nil
}