mirror of
https://github.com/thegeeklab/wp-s3-action.git
synced 2024-11-28 09:20:36 +00:00
using int instead of string
This commit is contained in:
parent
c0496f588c
commit
364ee8f5db
6
main.go
6
main.go
@ -116,10 +116,10 @@ func main() {
|
||||
Name: "env-file",
|
||||
Usage: "source env file",
|
||||
},
|
||||
cli.StringFlag{
|
||||
cli.IntFlag{
|
||||
Name: "max-concurrency",
|
||||
Usage: "customize number concurrent files to process",
|
||||
Value: "100",
|
||||
Value: 100,
|
||||
EnvVar: "PLUGIN_MAX_CONCURRENCY",
|
||||
|
||||
},
|
||||
@ -152,7 +152,7 @@ func run(c *cli.Context) error {
|
||||
Redirects: c.Generic("redirects").(*MapFlag).Get(),
|
||||
CloudFrontDistribution: c.String("cloudfront-distribution"),
|
||||
DryRun: c.Bool("dry-run"),
|
||||
MaxConcurrency: c.String("max-concurrency"),
|
||||
MaxConcurrency: c.Int("max-concurrency"),
|
||||
}
|
||||
|
||||
return plugin.Exec()
|
||||
|
11
plugin.go
11
plugin.go
@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Plugin struct {
|
||||
@ -29,7 +28,7 @@ type Plugin struct {
|
||||
PathStyle bool
|
||||
client AWS
|
||||
jobs []job
|
||||
MaxConcurrency string
|
||||
MaxConcurrency int
|
||||
}
|
||||
|
||||
type job struct {
|
||||
@ -156,13 +155,7 @@ func (p *Plugin) createInvalidateJob() {
|
||||
|
||||
func (p *Plugin) runJobs() {
|
||||
client := p.client
|
||||
maxConcurrency, err := strconv.Atoi(p.MaxConcurrency)
|
||||
if err != nil {
|
||||
fmt.Printf("ERROR: invalid input for max-concurrency")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
jobChan := make(chan struct{}, maxConcurrency)
|
||||
jobChan := make(chan struct{}, p.MaxConcurrency)
|
||||
results := make(chan *result, len(p.jobs))
|
||||
var invalidateJob *job
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user