mirror of
https://github.com/jkaninda/go-storage.git
synced 2025-12-06 16:49:39 +01:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0a70da956f | ||
|
|
1b147ebea5 | ||
|
|
d314c3854b | ||
|
|
2339db673d |
6
.github/dependabot.yml
vendored
Normal file
6
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: gomod
|
||||
directory: /
|
||||
schedule:
|
||||
interval: weekly
|
||||
@@ -56,7 +56,7 @@ if err != nil {
|
||||
```go
|
||||
sshStorage, err := ssh.NewStorage(ssh.Config{
|
||||
Host: "",
|
||||
Port: 22,
|
||||
Port: "",
|
||||
User: "",
|
||||
Password: "",
|
||||
RemotePath: "",
|
||||
@@ -80,7 +80,7 @@ log.Fatalf("Error copying file, error %v", err)
|
||||
```go
|
||||
ftpStorage, err := ftp.NewStorage(ftp.Config{
|
||||
Host: "",
|
||||
Port: 21,
|
||||
Port: "",
|
||||
User: "",
|
||||
Password: "",
|
||||
RemotePath: "",
|
||||
|
||||
@@ -44,14 +44,14 @@ type Config struct {
|
||||
Host string
|
||||
User string
|
||||
Password string
|
||||
Port int
|
||||
Port string
|
||||
LocalPath string
|
||||
RemotePath string
|
||||
}
|
||||
|
||||
// createClient creates FTP Client
|
||||
func createClient(conf Config) (*ftp.ServerConn, error) {
|
||||
ftpClient, err := ftp.Dial(fmt.Sprintf("%s:%d", conf.Host, conf.Port), ftp.DialWithTimeout(5*time.Second))
|
||||
ftpClient, err := ftp.Dial(fmt.Sprintf("%s:%s", conf.Host, conf.Port), ftp.DialWithTimeout(5*time.Second))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to connect to FTP: %w", err)
|
||||
}
|
||||
|
||||
@@ -178,16 +178,16 @@ func (s s3Storage) Prune(retentionDays int) error {
|
||||
Key: object.Key,
|
||||
})
|
||||
if err != nil {
|
||||
fmt.Printf("failed to delete object %s: %v\n", *object.Key, err)
|
||||
fmt.Printf("failed to delete object %s: %v", *object.Key, err)
|
||||
} else {
|
||||
fmt.Printf("Deleted object %s\n", *object.Key)
|
||||
fmt.Printf("Deleted object %s", *object.Key)
|
||||
}
|
||||
}
|
||||
}
|
||||
return !lastPage
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to list objects: %v\n", err)
|
||||
return fmt.Errorf("failed to list objects: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
@@ -46,7 +46,7 @@ type Config struct {
|
||||
Host string
|
||||
User string
|
||||
Password string
|
||||
Port int
|
||||
Port string
|
||||
IdentifyFile string
|
||||
LocalPath string
|
||||
RemotePath string
|
||||
@@ -54,15 +54,15 @@ type Config struct {
|
||||
|
||||
// createClient creates SSH Client
|
||||
func createClient(conf Config) (scp.Client, error) {
|
||||
if _, err := os.Stat(conf.IdentifyFile); !os.IsNotExist(err) {
|
||||
if _, err := os.Stat(conf.IdentifyFile); os.IsNotExist(err) {
|
||||
clientConfig, err := auth.PrivateKey(conf.User, conf.IdentifyFile, ssh.InsecureIgnoreHostKey())
|
||||
return scp.NewClient(fmt.Sprintf("%s:%d", conf.Host, conf.Port), &clientConfig), err
|
||||
return scp.NewClient(fmt.Sprintf("%s:%s", conf.Host, conf.Port), &clientConfig), err
|
||||
} else {
|
||||
if conf.Password == "" {
|
||||
return scp.Client{}, errors.New("ssh password required")
|
||||
}
|
||||
clientConfig, err := auth.PasswordKey(conf.User, conf.Password, ssh.InsecureIgnoreHostKey())
|
||||
return scp.NewClient(fmt.Sprintf("%s:%d", conf.Host, conf.Port), &clientConfig), err
|
||||
return scp.NewClient(fmt.Sprintf("%s:%s", conf.Host, conf.Port), &clientConfig), err
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
package ssh
|
||||
Reference in New Issue
Block a user