[MM-52924] Implement ConfigurationWillBeSaved plugin hook (#23567)
* Implement ConfigurationWillBeSaved plugin hook * Add comment * Update comment * Fix potential nil dereference if plugin environment is unset * Address PR review
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
d0ad46b496
Коммит
62a3ee8adc
@@ -1037,6 +1037,42 @@ func (s *hooksRPCServer) GetTopicMetadataByIds(args *Z_GetTopicMetadataByIdsArgs
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
hookNameToId["ConfigurationWillBeSaved"] = ConfigurationWillBeSavedID
|
||||
}
|
||||
|
||||
type Z_ConfigurationWillBeSavedArgs struct {
|
||||
A *model.Config
|
||||
}
|
||||
|
||||
type Z_ConfigurationWillBeSavedReturns struct {
|
||||
A *model.Config
|
||||
B error
|
||||
}
|
||||
|
||||
func (g *hooksRPCClient) ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error) {
|
||||
_args := &Z_ConfigurationWillBeSavedArgs{newCfg}
|
||||
_returns := &Z_ConfigurationWillBeSavedReturns{}
|
||||
if g.implemented[ConfigurationWillBeSavedID] {
|
||||
if err := g.client.Call("Plugin.ConfigurationWillBeSaved", _args, _returns); err != nil {
|
||||
g.log.Error("RPC call ConfigurationWillBeSaved to plugin failed.", mlog.Err(err))
|
||||
}
|
||||
}
|
||||
return _returns.A, _returns.B
|
||||
}
|
||||
|
||||
func (s *hooksRPCServer) ConfigurationWillBeSaved(args *Z_ConfigurationWillBeSavedArgs, returns *Z_ConfigurationWillBeSavedReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
ConfigurationWillBeSaved(newCfg *model.Config) (*model.Config, error)
|
||||
}); ok {
|
||||
returns.A, returns.B = hook.ConfigurationWillBeSaved(args.A)
|
||||
returns.B = encodableError(returns.B)
|
||||
} else {
|
||||
return encodableError(fmt.Errorf("Hook ConfigurationWillBeSaved called but not implemented."))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type Z_RegisterCommandArgs struct {
|
||||
A *model.Command
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user