Compare commits

...

7 Commits

Author SHA1 Message Date
Thomas Boerger ce7e9cd1c9 Merge pull request #8 from patrickjahns/fix_checksumming
fixed typo regards to sha checksumming
2018-09-25 21:01:32 +02:00
Patrick Jahns 77d760c2b9 provide legacy fallback option to avoid breaking changes 2018-09-25 19:33:31 +02:00
Patrick Jahns a367d8be06 fixed typo regards to sha checksumming 2018-09-25 16:29:22 +02:00
Thomas Boerger cb10efa30b Merge pull request #7 from patrickjahns/add_header_options
added ability to specify a authorization header
2018-09-25 14:46:33 +02:00
Patrick Jahns 0746c93e6d added ability to specify a authorization header 2018-09-25 13:02:34 +02:00
Thomas Boerger f60fbda48d Merge pull request #6 from appleboy/patch-1
Provide a password using STDIN
2018-09-25 12:58:41 +02:00
Bo-Yi Wu d0e70bf7f1 Provide a password using STDIN 2018-06-30 20:17:54 +08:00
3 changed files with 34 additions and 21 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ deploy_script:
if ( $env:APPVEYOR_PULL_REQUEST_NUMBER ) {
Write-Host Nothing to deploy.
} else {
docker login --username $env:DOCKER_USERNAME --password $env:DOCKER_PASSWORD
echo $env:DOCKER_PASSWORD | docker login --username $env:DOCKER_USERNAME --password-stdin
if ( $env:APPVEYOR_REPO_TAG -eq 'true' ) {
$major,$minor,$patch = $env:APPVEYOR_REPO_TAG_NAME.substring(1).split('.')
+16 -10
View File
@@ -31,6 +31,11 @@ func main() {
Usage: "destination for the download",
EnvVar: "PLUGIN_DESTINATION",
},
cli.StringFlag{
Name: "authorization",
Usage: "value to send in the authorization header",
EnvVar: "PLUGIN_AUTHORIZATION,DOWNLOAD_AUTHORIZATION",
},
cli.StringFlag{
Name: "username",
Usage: "username for basic auth",
@@ -52,9 +57,9 @@ func main() {
EnvVar: "PLUGIN_MD5",
},
cli.StringFlag{
Name: "sha265-checksum",
Usage: "checksum in sha265 format",
EnvVar: "PLUGIN_SHA265",
Name: "sha256-checksum",
Usage: "checksum in sha256 format",
EnvVar: "PLUGIN_SHA256,PLUGIN_SHA265",
},
}
@@ -66,13 +71,14 @@ func main() {
func run(c *cli.Context) error {
plugin := Plugin{
Config: Config{
Source: c.String("source"),
Destination: c.String("destination"),
Username: c.String("username"),
Password: c.String("password"),
SkipVerify: c.Bool("skip-verify"),
MD5: c.String("md5-checksum"),
SHA265: c.String("sha265-checksum"),
Source: c.String("source"),
Destination: c.String("destination"),
Authorization: c.String("authorization"),
Username: c.String("username"),
Password: c.String("password"),
SkipVerify: c.Bool("skip-verify"),
MD5: c.String("md5-checksum"),
SHA256: c.String("sha256-checksum"),
},
}
+17 -10
View File
@@ -19,13 +19,14 @@ import (
type (
Config struct {
Source string
Destination string
Username string
Password string
SkipVerify bool
MD5 string
SHA265 string
Source string
Destination string
Authorization string
Username string
Password string
SkipVerify bool
MD5 string
SHA256 string
}
Plugin struct {
@@ -61,7 +62,9 @@ func (p Plugin) Exec() error {
if p.Config.Username != "" && p.Config.Password != "" {
req.SetBasicAuth(p.Config.Username, p.Config.Password)
}
if p.Config.Authorization != "" {
req.Header.Add("Authorization", p.Config.Authorization)
}
return nil
},
}
@@ -80,6 +83,10 @@ func (p Plugin) Exec() error {
req.SetBasicAuth(p.Config.Username, p.Config.Password)
}
if p.Config.Authorization != "" {
req.Header.Add("Authorization", p.Config.Authorization)
}
resp, err := client.Do(req)
if err != nil {
@@ -114,7 +121,7 @@ func (p Plugin) Exec() error {
}
}
if p.Config.SHA265 != "" {
if p.Config.SHA256 != "" {
h := sha256.New()
if _, err := io.Copy(h, resp.Body); err != nil {
@@ -124,7 +131,7 @@ func (p Plugin) Exec() error {
check := fmt.Sprintf("%x", h.Sum(nil))
if p.Config.MD5 != check {
return fmt.Errorf("checksum doesn't match, got %s and expected %s", check, p.Config.SHA265)
return fmt.Errorf("checksum doesn't match, got %s and expected %s", check, p.Config.SHA256)
}
}