Skip to content

Commit

Permalink
refactor: refactor codebase and update GitHub workflow
Browse files Browse the repository at this point in the history
###
- Update golangci-lint-action from v4 to v6 in GitHub workflow
- Refactor long usage strings in main.go for better readability
- Rename function parameter from `Environment` to `envs` in plugin.go
- Add nolint directive to Exec function in plugin.go to suppress gocyclo lint warning

Signed-off-by: appleboy <[email protected]>
###
  • Loading branch information
appleboy committed May 19, 2024
1 parent 82e3499 commit 416677e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup golangci-lint
uses: golangci/golangci-lint-action@v4
uses: golangci/golangci-lint-action@v6
with:
version: latest
args: --verbose
Expand Down
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ func main() {
EnvVars: []string{"PLUGIN_REVERSION_ID", "REVERSION_ID", "INPUT_REVERSION_ID"},
},
&cli.StringFlag{
Name: "s3-bucket",
Usage: "An Amazon S3 bucket in the same AWS Region as your function. The bucket can be in a different AWS account.",
Name: "s3-bucket",
Usage: "An Amazon S3 bucket in the same AWS Region as your function. " +
"The bucket can be in a different AWS account.",
EnvVars: []string{"PLUGIN_S3_BUCKET", "S3_BUCKET", "INPUT_S3_BUCKET"},
},
&cli.StringFlag{
Expand All @@ -97,8 +98,9 @@ func main() {
EnvVars: []string{"PLUGIN_SOURCE", "SOURCE", "INPUT_SOURCE"},
},
&cli.BoolFlag{
Name: "dry-run",
Usage: "Set to true to validate the request parameters and access permissions without modifying the function code.",
Name: "dry-run",
Usage: "Set to true to validate the request parameters and " +
"access permissions without modifying the function code.",
EnvVars: []string{"PLUGIN_DRY_RUN", "DRY_RUN", "INPUT_DRY_RUN"},
},
&cli.BoolFlag{
Expand All @@ -112,13 +114,16 @@ func main() {
EnvVars: []string{"PLUGIN_PUBLISH", "PUBLISH", "INPUT_PUBLISH"},
},
&cli.Int64Flag{
Name: "memory-size",
Usage: "The amount of memory that your function has access to. Increasing the function's memory also increases its CPU allocation. The default value is 128 MB. The value must be a multiple of 64 MB.",
Name: "memory-size",
Usage: "The amount of memory that your function has access to. " +
"Increasing the function's memory also increases its CPU allocation. " +
"The default value is 128 MB. The value must be a multiple of 64 MB.",
EnvVars: []string{"PLUGIN_MEMORY_SIZE", "MEMORY_SIZE", "INPUT_MEMORY_SIZE"},
},
&cli.Int64Flag{
Name: "timeout",
Usage: "The amount of time that Lambda allows a function to run before stopping it. The default is 3 seconds. The maximum allowed value is 900 seconds.",
Name: "timeout",
Usage: "The amount of time that Lambda allows a function to run before stopping it. " +
"The default is 3 seconds. The maximum allowed value is 900 seconds.",
EnvVars: []string{"PLUGIN_TIMEOUT", "TIMEOUT", "INPUT_TIMEOUT"},
},
&cli.StringFlag{
Expand Down
6 changes: 3 additions & 3 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ type (
}
)

func getEnvironment(Environment []string) map[string]string {
func getEnvironment(envs []string) map[string]string {
output := make(map[string]string)
for _, e := range Environment {
for _, e := range envs {
pair := strings.SplitN(e, "=", 2)
if len(pair) != 2 {
continue
Expand All @@ -83,7 +83,7 @@ func (p Plugin) loadEnvironment(envs []string) *lambda.Environment {
}

// Exec executes the plugin.
func (p Plugin) Exec() error {
func (p Plugin) Exec() error { //nolint:gocyclo
p.dump(p.Config)

if p.Config.FunctionName == "" {
Expand Down

0 comments on commit 416677e

Please sign in to comment.