From 03da61e62394b88bc8baa2a4aa2c1efadefd44c8 Mon Sep 17 00:00:00 2001 From: Kayla McKay Date: Wed, 2 Feb 2022 13:22:33 -0600 Subject: [PATCH] Remove plugin.Env, clean unneccesary code --- cmd/vela-email/main.go | 3 --- cmd/vela-email/plugin.go | 8 +------- cmd/vela-email/plugin_test.go | 2 -- version/version.go | 2 +- 4 files changed, 2 insertions(+), 13 deletions(-) diff --git a/cmd/vela-email/main.go b/cmd/vela-email/main.go index 0986517..2251f17 100644 --- a/cmd/vela-email/main.go +++ b/cmd/vela-email/main.go @@ -276,9 +276,6 @@ func run(c *cli.Context) error { return err } - // add vela environment variables - p.Env = p.Environment() - // execute the plugin return p.Exec() } diff --git a/cmd/vela-email/plugin.go b/cmd/vela-email/plugin.go index 4be3bdc..5b11f4e 100644 --- a/cmd/vela-email/plugin.go +++ b/cmd/vela-email/plugin.go @@ -48,8 +48,6 @@ type ( SendType string // Auth arguments loaded for the plugin Auth string - // Env arguments loaded for the plugin - Env map[string]string // Readable build time environment variables BuildEnv *BuildEnv } @@ -246,7 +244,7 @@ func (p *Plugin) injectEnv(str string) (string, error) { // parse string to template t := template.Must(template.New("input").Parse(str)) - err := t.Execute(buffer, p.Env) + err := t.Execute(buffer, p.Environment()) return buffer.String(), err } @@ -255,10 +253,6 @@ func (p *Plugin) injectEnv(str string) (string, error) { func stringToSlice(s []string) []string { var slice []string - if len(s) == 0 { - return s - } - for _, e := range s { if len(e) > 0 { temp := strings.Split(e, ", ") diff --git a/cmd/vela-email/plugin_test.go b/cmd/vela-email/plugin_test.go index f5b780c..7fc69a4 100644 --- a/cmd/vela-email/plugin_test.go +++ b/cmd/vela-email/plugin_test.go @@ -279,7 +279,6 @@ func TestInjectEnvSuccess(t *testing.T) { t.FailNow() } createMockEnv() - test.parameters.Env = test.parameters.Environment() subject, err := test.parameters.injectEnv(test.parameters.Email.Subject) if err != nil { t.Errorf("InjectEnv(subject) should not have raised an error %s", err) @@ -334,7 +333,6 @@ func TestInjectEnvBadVar(t *testing.T) { } createMockEnv() os.Setenv("SOME_OTHER_VARIABLE", "check") - test.parameters.Env = test.parameters.Environment() subject, err := test.parameters.injectEnv(test.parameters.Email.Subject) if err != nil { diff --git a/version/version.go b/version/version.go index 52d281e..b9a3fdf 100644 --- a/version/version.go +++ b/version/version.go @@ -36,7 +36,7 @@ var ( func New() *version.Version { // check if a semantic tag was provided if len(Tag) == 0 { - logrus.Warningf("no semantic tag provided - defaulting to v0.0.0") + logrus.Warning("no semantic tag provided - defaulting to v0.0.0") // set a fallback default for the tag Tag = "v0.0.0"