Skip to content

Commit

Permalink
refactor: refactor codebase to use plural form 'parameters'
Browse files Browse the repository at this point in the history
- Rename `parameter` to `parameters` in CLI flags and environment variables
- Update function calls to use `parameters` instead of `parameter`
- Change struct field `Parameter` to `Parameters`
- Modify loop variable to iterate over `Parameters` instead of `Parameter`

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Oct 6, 2024
1 parent e60e4b9 commit 626b9e4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ func main() {
EnvVar: "PLUGIN_INSECURE,JENKINS_INSECURE,INPUT_INSECURE",
},
cli.StringSliceFlag{
Name: "parameter,p",
Usage: "jenkins build parameter",
EnvVar: "PLUGIN_PARAMETER,JENKINS_PARAMETER,INPUT_PARAMETER",
Name: "parameters,p",
Usage: "jenkins build parameters",
EnvVar: "PLUGIN_PARAMETERS,JENKINS_PARAMETERS,INPUT_PARAMETERS",
},
}

Expand Down Expand Up @@ -106,12 +106,12 @@ REPOSITORY:

func run(c *cli.Context) error {
plugin := Plugin{
BaseURL: c.String("host"),
Username: c.String("user"),
Token: c.String("token"),
Job: c.StringSlice("job"),
Insecure: c.Bool("insecure"),
Parameter: c.StringSlice("parameter"),
BaseURL: c.String("host"),
Username: c.String("user"),
Token: c.String("token"),
Job: c.StringSlice("job"),
Insecure: c.Bool("insecure"),
Parameters: c.StringSlice("parameters"),
}

return plugin.Exec()
Expand Down
14 changes: 7 additions & 7 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import (
type (
// Plugin values.
Plugin struct {
BaseURL string
Username string
Token string
Job []string
Insecure bool
Parameter []string
BaseURL string
Username string
Token string
Job []string
Insecure bool
Parameters []string
}
)

Expand Down Expand Up @@ -53,7 +53,7 @@ func (p Plugin) Exec() error {
jenkins := NewJenkins(auth, p.BaseURL, p.Insecure)

params := url.Values{}
for _, v := range p.Parameter {
for _, v := range p.Parameters {
kv := strings.Split(v, "=")
if len(kv) == 2 {
params.Add(kv[0], kv[1])
Expand Down

0 comments on commit 626b9e4

Please sign in to comment.