Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove env argument of addons #3100

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions docs/docs/30-administration/75-addons/20-creating-addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ An addon consists of two variables/functions in Go.

1. The `Type` variable. Specifies the type of the addon and must be directly accessed from `shared/addons/types/types.go`.
2. The `Addon` function which is the main point of your addon.
This function takes two arguments:

1. The zerolog logger you should use to log errors, warnings etc.
2. A slice of strings with the environment variables used as configuration.
This function takes the zerolog logger you should use to log errors, warnings etc. as argument.

It returns two values:

Expand Down Expand Up @@ -79,7 +76,7 @@ import (

var Type = addon_types.TypeForge

func Addon(logger zerolog.Logger, env []string) (forge.Forge, error) {
func Addon(logger zerolog.Logger) (forge.Forge, error) {
logger.Info().Msg("hello world from addon")
return &config{l: logger}, nil
}
Expand Down
5 changes: 2 additions & 3 deletions shared/addon/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package addon

import (
"errors"
"os"
"plugin"

"github.com/rs/zerolog"
Expand Down Expand Up @@ -42,14 +41,14 @@ func Load[T any](files []string, t types.Type) (*Addon[T], error) {
if err != nil {
return nil, err
}
main, is := mainLookup.(func(zerolog.Logger, []string) (T, error))
main, is := mainLookup.(func(zerolog.Logger) (T, error))
if !is {
return nil, errors.New("addon main function has incorrect type")
}

logger := log.Logger.With().Str("addon", file).Logger()

mainOut, err := main(logger, os.Environ())
mainOut, err := main(logger)
if err != nil {
return nil, err
}
Expand Down