Closed superewald closed 10 months ago
Hey @superewald, thank you for this elaborate feature request and proof of concept. ☺️
The idea behind using a shared config between all hooks plugins was to keep the config file as simple as possible. Additionally, the very generic map[string]string
type allows the plugins to take care of stronger type validation (e.g. as you suggest, they could use a library like mapstruct
).
When two plugins use the same option key, this could mean either:
enable
or file
) and thus causes conflicts.cool_provider_account_id
.I think the issue could be solved by encouraging plugin authors to choose better option names and document potentially conflicting plugins.
To summarize, I prefer the config format as it is for now. Nevertheless, I really would like to hear an example where you discovered conflicting hooks options.
Best, Chris
The current implementation of the config reader doesn't support nested configurations for hook plugins. Also, two plugins using the same option key would cause a problem and render one of the plugins unusable.
proposal
change the config structure like this:
change the
Config.HooksPlugins
to an array of structs// change the HooksPlugins to PluginHookConfig array type Config struct { HooksPlugins []PluginHookConfig }
considerations
maybe decoding the options to the structure can be done in semantic-release itself before calling
Hook.Init
by reflecting the argument type of the Init function; I'm not sure if that works with the go-plugins libraryfor backwards compatibility add a check if
plugins.hooks.names
exist; if so populate HooksPlugins by hand (otherwise it could be unmarshalled using viper)map[string]string
this would also work for other plugins and allow the config to be unmarshalled completely instead of parsing it by hand. In my opingion the config struct could look much cleaner this way; thoughts on this ?