Skip to content

Commit 3f05fc6

Browse files
authored
refactor: refactor code and improve function signatures (#22)
- Remove unused code related to commit metadata - Simplify `loadEnvironment` function signature fix appleboy/lambda-action#25
1 parent 534563d commit 3f05fc6

1 file changed

Lines changed: 4 additions & 17 deletions

File tree

plugin.go

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,10 @@ func getEnvironment(Environment []string) map[string]string {
7171
return output
7272
}
7373

74-
func (p Plugin) loadEnvironment(envs []string) (*lambda.Environment, error) {
75-
m := aws.StringMap(getEnvironment(envs))
76-
if p.Commit.Sha != "" {
77-
m["DRONE_COMMIT"] = &p.Commit.Sha
78-
}
79-
if p.Commit.Author != "" {
80-
m["DRONE_AUTHOR"] = &p.Commit.Author
81-
}
82-
74+
func (p Plugin) loadEnvironment(envs []string) *lambda.Environment {
8375
return &lambda.Environment{
84-
Variables: m,
85-
}, nil
76+
Variables: aws.StringMap(getEnvironment(envs)),
77+
}
8678
}
8779

8880
// Exec executes the plugin.
@@ -204,13 +196,8 @@ func (p Plugin) Exec() error {
204196

205197
envs := trimValues(p.Config.Environment)
206198
if len(envs) > 0 {
207-
// load environment
208-
env, err := p.loadEnvironment(envs)
209-
if err != nil {
210-
return err
211-
}
212199
isUpdateConfig = true
213-
cfg.SetEnvironment(env)
200+
cfg.SetEnvironment(p.loadEnvironment(envs))
214201
}
215202

216203
subnets := trimValues(p.Config.Subnets)

0 commit comments

Comments
 (0)