From 626b9e4bfa5fd687baca0186f82a9a6d53c7c0bf Mon Sep 17 00:00:00 2001 From: appleboy Date: Sun, 6 Oct 2024 08:34:10 +0800 Subject: [PATCH] refactor: refactor codebase to use plural form 'parameters' - 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 --- main.go | 18 +++++++++--------- plugin.go | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/main.go b/main.go index c77e809..25cc7bf 100644 --- a/main.go +++ b/main.go @@ -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", }, } @@ -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() diff --git a/plugin.go b/plugin.go index f2b8caa..3f5ad8e 100644 --- a/plugin.go +++ b/plugin.go @@ -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 } ) @@ -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])