diff --git a/README.md b/README.md index f2db096..90cc752 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ if err != nil { ```go sshStorage, err := ssh.NewStorage(ssh.Config{ Host: "", - Port: "", + Port: 22, User: "", Password: "", RemotePath: "", @@ -80,7 +80,7 @@ log.Fatalf("Error copying file, error %v", err) ```go ftpStorage, err := ftp.NewStorage(ftp.Config{ Host: "", - Port: "", + Port: 22, User: "", Password: "", RemotePath: "", diff --git a/pkg/ftp/ftp.go b/pkg/ftp/ftp.go index f8cb165..1b84e29 100644 --- a/pkg/ftp/ftp.go +++ b/pkg/ftp/ftp.go @@ -44,14 +44,14 @@ type Config struct { Host string User string Password string - Port string + Port int LocalPath string RemotePath string } // createClient creates FTP Client func createClient(conf Config) (*ftp.ServerConn, error) { - ftpClient, err := ftp.Dial(fmt.Sprintf("%s:%s", conf.Host, conf.Port), ftp.DialWithTimeout(5*time.Second)) + ftpClient, err := ftp.Dial(fmt.Sprintf("%s:%d", conf.Host, conf.Port), ftp.DialWithTimeout(5*time.Second)) if err != nil { return nil, fmt.Errorf("failed to connect to FTP: %w", err) } diff --git a/pkg/s3/s3.go b/pkg/s3/s3.go index 3695372..c4f0b10 100644 --- a/pkg/s3/s3.go +++ b/pkg/s3/s3.go @@ -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", *object.Key, err) + fmt.Printf("failed to delete object %s: %v\n", *object.Key, err) } else { - fmt.Printf("Deleted object %s", *object.Key) + fmt.Printf("Deleted object %s\n", *object.Key) } } } return !lastPage }) if err != nil { - return fmt.Errorf("failed to list objects: %v", err) + return fmt.Errorf("failed to list objects: %v\n", err) } return nil diff --git a/pkg/ssh/ssh.go b/pkg/ssh/ssh.go index 367d9bd..6328e1d 100644 --- a/pkg/ssh/ssh.go +++ b/pkg/ssh/ssh.go @@ -46,7 +46,7 @@ type Config struct { Host string User string Password string - Port string + Port int 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:%s", conf.Host, conf.Port), &clientConfig), err + return scp.NewClient(fmt.Sprintf("%s:%d", 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:%s", conf.Host, conf.Port), &clientConfig), err + return scp.NewClient(fmt.Sprintf("%s:%d", conf.Host, conf.Port), &clientConfig), err } } diff --git a/pkg/ssh/ssh_test.go b/pkg/ssh/ssh_test.go new file mode 100644 index 0000000..8104872 --- /dev/null +++ b/pkg/ssh/ssh_test.go @@ -0,0 +1 @@ +package ssh