mirror of
https://github.com/appleboy/drone-scp.git
synced 2026-06-04 18:23:59 +08:00
ea5edea0d6
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
71 lines
1.0 KiB
Go
71 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"errors"
|
|
"log"
|
|
"strings"
|
|
)
|
|
|
|
type (
|
|
// Repo information.
|
|
Repo struct {
|
|
Owner string
|
|
Name string
|
|
}
|
|
|
|
// Build information.
|
|
Build struct {
|
|
Event string
|
|
Number int
|
|
Commit string
|
|
Message string
|
|
Branch string
|
|
Author string
|
|
Status string
|
|
Link string
|
|
}
|
|
|
|
// Config for the plugin.
|
|
Config struct {
|
|
Host string
|
|
Port string
|
|
Username string
|
|
Password string
|
|
Path string
|
|
File []string
|
|
}
|
|
|
|
// Plugin values.
|
|
Plugin struct {
|
|
Repo Repo
|
|
Build Build
|
|
Config Config
|
|
}
|
|
)
|
|
|
|
func trimElement(keys []string) []string {
|
|
var newKeys []string
|
|
|
|
for _, value := range keys {
|
|
value = strings.Trim(value, " ")
|
|
if len(value) == 0 {
|
|
continue
|
|
}
|
|
newKeys = append(newKeys, value)
|
|
}
|
|
|
|
return newKeys
|
|
}
|
|
|
|
// Exec executes the plugin.
|
|
func (p Plugin) Exec() error {
|
|
|
|
if len(p.Config.Host) == 0 || len(p.Config.Username) == 0 || len(p.Config.Password) == 0 {
|
|
log.Println("missing sftp config")
|
|
|
|
return errors.New("missing sftp config")
|
|
}
|
|
|
|
return nil
|
|
}
|