коммит произвёл
GitHub
родитель
b45ff0be5d
Коммит
717a4d04a9
@@ -23,7 +23,7 @@ type API interface {
|
||||
//
|
||||
// @tag Plugin
|
||||
// Minimum server version: 5.2
|
||||
LoadPluginConfiguration(dest interface{}) error
|
||||
LoadPluginConfiguration(dest any) error
|
||||
|
||||
// RegisterCommand registers a custom slash command. When the command is triggered, your plugin
|
||||
// can fulfill it via the ExecuteCommand hook.
|
||||
@@ -66,13 +66,13 @@ type API interface {
|
||||
//
|
||||
// @tag Plugin
|
||||
// Minimum server version: 5.6
|
||||
GetPluginConfig() map[string]interface{}
|
||||
GetPluginConfig() map[string]any
|
||||
|
||||
// SavePluginConfig sets the given config for plugin and persists the changes
|
||||
//
|
||||
// @tag Plugin
|
||||
// Minimum server version: 5.6
|
||||
SavePluginConfig(config map[string]interface{}) *model.AppError
|
||||
SavePluginConfig(config map[string]any) *model.AppError
|
||||
|
||||
// GetBundlePath returns the absolute path where the plugin's bundle was unpacked.
|
||||
//
|
||||
@@ -938,7 +938,7 @@ type API interface {
|
||||
// broadcast determines to which users to send the event.
|
||||
//
|
||||
// Minimum server version: 5.2
|
||||
PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
|
||||
PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast)
|
||||
|
||||
// HasPermissionTo check if the user has the permission at system scope.
|
||||
//
|
||||
@@ -971,7 +971,7 @@ type API interface {
|
||||
//
|
||||
// @tag Logging
|
||||
// Minimum server version: 5.2
|
||||
LogDebug(msg string, keyValuePairs ...interface{})
|
||||
LogDebug(msg string, keyValuePairs ...any)
|
||||
|
||||
// LogInfo writes a log message to the Mattermost server log file.
|
||||
// Appropriate context such as the plugin name will already be added as fields so plugins
|
||||
@@ -979,7 +979,7 @@ type API interface {
|
||||
//
|
||||
// @tag Logging
|
||||
// Minimum server version: 5.2
|
||||
LogInfo(msg string, keyValuePairs ...interface{})
|
||||
LogInfo(msg string, keyValuePairs ...any)
|
||||
|
||||
// LogError writes a log message to the Mattermost server log file.
|
||||
// Appropriate context such as the plugin name will already be added as fields so plugins
|
||||
@@ -987,7 +987,7 @@ type API interface {
|
||||
//
|
||||
// @tag Logging
|
||||
// Minimum server version: 5.2
|
||||
LogError(msg string, keyValuePairs ...interface{})
|
||||
LogError(msg string, keyValuePairs ...any)
|
||||
|
||||
// LogWarn writes a log message to the Mattermost server log file.
|
||||
// Appropriate context such as the plugin name will already be added as fields so plugins
|
||||
@@ -995,7 +995,7 @@ type API interface {
|
||||
//
|
||||
// @tag Logging
|
||||
// Minimum server version: 5.2
|
||||
LogWarn(msg string, keyValuePairs ...interface{})
|
||||
LogWarn(msg string, keyValuePairs ...any)
|
||||
|
||||
// SendMail sends an email to a specific address
|
||||
//
|
||||
|
||||
@@ -28,7 +28,7 @@ func (api *apiTimerLayer) recordTime(startTime timePkg.Time, name string, succes
|
||||
}
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) LoadPluginConfiguration(dest interface{}) error {
|
||||
func (api *apiTimerLayer) LoadPluginConfiguration(dest any) error {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.LoadPluginConfiguration(dest)
|
||||
api.recordTime(startTime, "LoadPluginConfiguration", _returnsA == nil)
|
||||
@@ -77,14 +77,14 @@ func (api *apiTimerLayer) SaveConfig(config *model.Config) *model.AppError {
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) GetPluginConfig() map[string]interface{} {
|
||||
func (api *apiTimerLayer) GetPluginConfig() map[string]any {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.GetPluginConfig()
|
||||
api.recordTime(startTime, "GetPluginConfig", true)
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) SavePluginConfig(config map[string]interface{}) *model.AppError {
|
||||
func (api *apiTimerLayer) SavePluginConfig(config map[string]any) *model.AppError {
|
||||
startTime := timePkg.Now()
|
||||
_returnsA := api.apiImpl.SavePluginConfig(config)
|
||||
api.recordTime(startTime, "SavePluginConfig", _returnsA == nil)
|
||||
@@ -1007,7 +1007,7 @@ func (api *apiTimerLayer) KVList(page, perPage int) ([]string, *model.AppError)
|
||||
return _returnsA, _returnsB
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
|
||||
func (api *apiTimerLayer) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
|
||||
startTime := timePkg.Now()
|
||||
api.apiImpl.PublishWebSocketEvent(event, payload, broadcast)
|
||||
api.recordTime(startTime, "PublishWebSocketEvent", true)
|
||||
@@ -1041,25 +1041,25 @@ func (api *apiTimerLayer) RolesGrantPermission(roleNames []string, permissionId
|
||||
return _returnsA
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) LogDebug(msg string, keyValuePairs ...interface{}) {
|
||||
func (api *apiTimerLayer) LogDebug(msg string, keyValuePairs ...any) {
|
||||
startTime := timePkg.Now()
|
||||
api.apiImpl.LogDebug(msg, keyValuePairs...)
|
||||
api.recordTime(startTime, "LogDebug", true)
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) LogInfo(msg string, keyValuePairs ...interface{}) {
|
||||
func (api *apiTimerLayer) LogInfo(msg string, keyValuePairs ...any) {
|
||||
startTime := timePkg.Now()
|
||||
api.apiImpl.LogInfo(msg, keyValuePairs...)
|
||||
api.recordTime(startTime, "LogInfo", true)
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) LogError(msg string, keyValuePairs ...interface{}) {
|
||||
func (api *apiTimerLayer) LogError(msg string, keyValuePairs ...any) {
|
||||
startTime := timePkg.Now()
|
||||
api.apiImpl.LogError(msg, keyValuePairs...)
|
||||
api.recordTime(startTime, "LogError", true)
|
||||
}
|
||||
|
||||
func (api *apiTimerLayer) LogWarn(msg string, keyValuePairs ...interface{}) {
|
||||
func (api *apiTimerLayer) LogWarn(msg string, keyValuePairs ...any) {
|
||||
startTime := timePkg.Now()
|
||||
api.apiImpl.LogWarn(msg, keyValuePairs...)
|
||||
api.recordTime(startTime, "LogWarn", true)
|
||||
|
||||
@@ -15,7 +15,7 @@ const (
|
||||
// Starts the serving of a Mattermost plugin over net/rpc. gRPC is not yet supported.
|
||||
//
|
||||
// Call this when your plugin is ready to start.
|
||||
func ClientMain(pluginImplementation interface{}) {
|
||||
func ClientMain(pluginImplementation any) {
|
||||
if impl, ok := pluginImplementation.(interface {
|
||||
SetAPI(api API)
|
||||
SetDriver(driver Driver)
|
||||
|
||||
@@ -43,24 +43,24 @@ type hooksRPCClient struct {
|
||||
}
|
||||
|
||||
type hooksRPCServer struct {
|
||||
impl interface{}
|
||||
impl any
|
||||
muxBroker *plugin.MuxBroker
|
||||
apiRPCClient *apiRPCClient
|
||||
}
|
||||
|
||||
// Implements hashicorp/go-plugin/plugin.Plugin interface to connect the hooks of a plugin
|
||||
type hooksPlugin struct {
|
||||
hooks interface{}
|
||||
hooks any
|
||||
apiImpl API
|
||||
driverImpl Driver
|
||||
log *mlog.Logger
|
||||
}
|
||||
|
||||
func (p *hooksPlugin) Server(b *plugin.MuxBroker) (interface{}, error) {
|
||||
func (p *hooksPlugin) Server(b *plugin.MuxBroker) (any, error) {
|
||||
return &hooksRPCServer{impl: p.hooks, muxBroker: b}, nil
|
||||
}
|
||||
|
||||
func (p *hooksPlugin) Client(b *plugin.MuxBroker, client *rpc.Client) (interface{}, error) {
|
||||
func (p *hooksPlugin) Client(b *plugin.MuxBroker, client *rpc.Client) (any, error) {
|
||||
return &hooksRPCClient{client: client,
|
||||
log: p.log,
|
||||
muxBroker: b,
|
||||
@@ -158,8 +158,8 @@ func decodableError(err error) error {
|
||||
// Registering some types used by MM for encoding/gob used by rpc
|
||||
func init() {
|
||||
gob.Register([]*model.SlackAttachment{})
|
||||
gob.Register([]interface{}{})
|
||||
gob.Register(map[string]interface{}{})
|
||||
gob.Register([]any{})
|
||||
gob.Register(map[string]any{})
|
||||
gob.Register(&model.AppError{})
|
||||
gob.Register(&pq.Error{})
|
||||
gob.Register(&mysql.MySQLError{})
|
||||
@@ -328,7 +328,7 @@ type Z_LoadPluginConfigurationArgsReturns struct {
|
||||
A []byte
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LoadPluginConfiguration(dest interface{}) error {
|
||||
func (g *apiRPCClient) LoadPluginConfiguration(dest any) error {
|
||||
_args := &Z_LoadPluginConfigurationArgsArgs{}
|
||||
_returns := &Z_LoadPluginConfigurationArgsReturns{}
|
||||
if err := g.client.Call("Plugin.LoadPluginConfiguration", _args, _returns); err != nil {
|
||||
@@ -341,9 +341,9 @@ func (g *apiRPCClient) LoadPluginConfiguration(dest interface{}) error {
|
||||
}
|
||||
|
||||
func (s *apiRPCServer) LoadPluginConfiguration(args *Z_LoadPluginConfigurationArgsArgs, returns *Z_LoadPluginConfigurationArgsReturns) error {
|
||||
var config interface{}
|
||||
var config any
|
||||
if hook, ok := s.impl.(interface {
|
||||
LoadPluginConfiguration(dest interface{}) error
|
||||
LoadPluginConfiguration(dest any) error
|
||||
}); ok {
|
||||
if err := hook.LoadPluginConfiguration(&config); err != nil {
|
||||
return err
|
||||
@@ -705,13 +705,13 @@ func (s *hooksRPCServer) MessageWillBeUpdated(args *Z_MessageWillBeUpdatedArgs,
|
||||
|
||||
type Z_LogDebugArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
B []any
|
||||
}
|
||||
|
||||
type Z_LogDebugReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogDebug(msg string, keyValuePairs ...interface{}) {
|
||||
func (g *apiRPCClient) LogDebug(msg string, keyValuePairs ...any) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &Z_LogDebugArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogDebugReturns{}
|
||||
@@ -723,7 +723,7 @@ func (g *apiRPCClient) LogDebug(msg string, keyValuePairs ...interface{}) {
|
||||
|
||||
func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogDebug(msg string, keyValuePairs ...interface{})
|
||||
LogDebug(msg string, keyValuePairs ...any)
|
||||
}); ok {
|
||||
hook.LogDebug(args.A, args.B...)
|
||||
} else {
|
||||
@@ -734,13 +734,13 @@ func (s *apiRPCServer) LogDebug(args *Z_LogDebugArgs, returns *Z_LogDebugReturns
|
||||
|
||||
type Z_LogInfoArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
B []any
|
||||
}
|
||||
|
||||
type Z_LogInfoReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogInfo(msg string, keyValuePairs ...interface{}) {
|
||||
func (g *apiRPCClient) LogInfo(msg string, keyValuePairs ...any) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &Z_LogInfoArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogInfoReturns{}
|
||||
@@ -752,7 +752,7 @@ func (g *apiRPCClient) LogInfo(msg string, keyValuePairs ...interface{}) {
|
||||
|
||||
func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogInfo(msg string, keyValuePairs ...interface{})
|
||||
LogInfo(msg string, keyValuePairs ...any)
|
||||
}); ok {
|
||||
hook.LogInfo(args.A, args.B...)
|
||||
} else {
|
||||
@@ -763,13 +763,13 @@ func (s *apiRPCServer) LogInfo(args *Z_LogInfoArgs, returns *Z_LogInfoReturns) e
|
||||
|
||||
type Z_LogWarnArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
B []any
|
||||
}
|
||||
|
||||
type Z_LogWarnReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogWarn(msg string, keyValuePairs ...interface{}) {
|
||||
func (g *apiRPCClient) LogWarn(msg string, keyValuePairs ...any) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &Z_LogWarnArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogWarnReturns{}
|
||||
@@ -781,7 +781,7 @@ func (g *apiRPCClient) LogWarn(msg string, keyValuePairs ...interface{}) {
|
||||
|
||||
func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogWarn(msg string, keyValuePairs ...interface{})
|
||||
LogWarn(msg string, keyValuePairs ...any)
|
||||
}); ok {
|
||||
hook.LogWarn(args.A, args.B...)
|
||||
} else {
|
||||
@@ -792,13 +792,13 @@ func (s *apiRPCServer) LogWarn(args *Z_LogWarnArgs, returns *Z_LogWarnReturns) e
|
||||
|
||||
type Z_LogErrorArgs struct {
|
||||
A string
|
||||
B []interface{}
|
||||
B []any
|
||||
}
|
||||
|
||||
type Z_LogErrorReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) LogError(msg string, keyValuePairs ...interface{}) {
|
||||
func (g *apiRPCClient) LogError(msg string, keyValuePairs ...any) {
|
||||
stringifiedPairs := stringifyToObjects(keyValuePairs)
|
||||
_args := &Z_LogErrorArgs{msg, stringifiedPairs}
|
||||
_returns := &Z_LogErrorReturns{}
|
||||
@@ -809,7 +809,7 @@ func (g *apiRPCClient) LogError(msg string, keyValuePairs ...interface{}) {
|
||||
|
||||
func (s *apiRPCServer) LogError(args *Z_LogErrorArgs, returns *Z_LogErrorReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
LogError(msg string, keyValuePairs ...interface{})
|
||||
LogError(msg string, keyValuePairs ...any)
|
||||
}); ok {
|
||||
hook.LogError(args.A, args.B...)
|
||||
} else {
|
||||
|
||||
@@ -982,10 +982,10 @@ type Z_GetPluginConfigArgs struct {
|
||||
}
|
||||
|
||||
type Z_GetPluginConfigReturns struct {
|
||||
A map[string]interface{}
|
||||
A map[string]any
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) GetPluginConfig() map[string]interface{} {
|
||||
func (g *apiRPCClient) GetPluginConfig() map[string]any {
|
||||
_args := &Z_GetPluginConfigArgs{}
|
||||
_returns := &Z_GetPluginConfigReturns{}
|
||||
if err := g.client.Call("Plugin.GetPluginConfig", _args, _returns); err != nil {
|
||||
@@ -996,7 +996,7 @@ func (g *apiRPCClient) GetPluginConfig() map[string]interface{} {
|
||||
|
||||
func (s *apiRPCServer) GetPluginConfig(args *Z_GetPluginConfigArgs, returns *Z_GetPluginConfigReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
GetPluginConfig() map[string]interface{}
|
||||
GetPluginConfig() map[string]any
|
||||
}); ok {
|
||||
returns.A = hook.GetPluginConfig()
|
||||
} else {
|
||||
@@ -1006,14 +1006,14 @@ func (s *apiRPCServer) GetPluginConfig(args *Z_GetPluginConfigArgs, returns *Z_G
|
||||
}
|
||||
|
||||
type Z_SavePluginConfigArgs struct {
|
||||
A map[string]interface{}
|
||||
A map[string]any
|
||||
}
|
||||
|
||||
type Z_SavePluginConfigReturns struct {
|
||||
A *model.AppError
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) SavePluginConfig(config map[string]interface{}) *model.AppError {
|
||||
func (g *apiRPCClient) SavePluginConfig(config map[string]any) *model.AppError {
|
||||
_args := &Z_SavePluginConfigArgs{config}
|
||||
_returns := &Z_SavePluginConfigReturns{}
|
||||
if err := g.client.Call("Plugin.SavePluginConfig", _args, _returns); err != nil {
|
||||
@@ -1024,7 +1024,7 @@ func (g *apiRPCClient) SavePluginConfig(config map[string]interface{}) *model.Ap
|
||||
|
||||
func (s *apiRPCServer) SavePluginConfig(args *Z_SavePluginConfigArgs, returns *Z_SavePluginConfigReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
SavePluginConfig(config map[string]interface{}) *model.AppError
|
||||
SavePluginConfig(config map[string]any) *model.AppError
|
||||
}); ok {
|
||||
returns.A = hook.SavePluginConfig(args.A)
|
||||
} else {
|
||||
@@ -4854,14 +4854,14 @@ func (s *apiRPCServer) KVList(args *Z_KVListArgs, returns *Z_KVListReturns) erro
|
||||
|
||||
type Z_PublishWebSocketEventArgs struct {
|
||||
A string
|
||||
B map[string]interface{}
|
||||
B map[string]any
|
||||
C *model.WebsocketBroadcast
|
||||
}
|
||||
|
||||
type Z_PublishWebSocketEventReturns struct {
|
||||
}
|
||||
|
||||
func (g *apiRPCClient) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
|
||||
func (g *apiRPCClient) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
|
||||
_args := &Z_PublishWebSocketEventArgs{event, payload, broadcast}
|
||||
_returns := &Z_PublishWebSocketEventReturns{}
|
||||
if err := g.client.Call("Plugin.PublishWebSocketEvent", _args, _returns); err != nil {
|
||||
@@ -4872,7 +4872,7 @@ func (g *apiRPCClient) PublishWebSocketEvent(event string, payload map[string]in
|
||||
|
||||
func (s *apiRPCServer) PublishWebSocketEvent(args *Z_PublishWebSocketEventArgs, returns *Z_PublishWebSocketEventReturns) error {
|
||||
if hook, ok := s.impl.(interface {
|
||||
PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
|
||||
PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast)
|
||||
}); ok {
|
||||
hook.PublishWebSocketEvent(args.A, args.B, args.C)
|
||||
} else {
|
||||
|
||||
@@ -120,7 +120,7 @@ func (env *Environment) PrepackagedPlugins() []*PrepackagedPlugin {
|
||||
// The returned list should not be modified.
|
||||
func (env *Environment) Active() []*model.BundleInfo {
|
||||
activePlugins := []*model.BundleInfo{}
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
env.registeredPlugins.Range(func(key, value any) bool {
|
||||
plugin := value.(registeredPlugin)
|
||||
if env.IsActive(plugin.BundleInfo.Manifest.Id) {
|
||||
activePlugins = append(activePlugins, plugin.BundleInfo)
|
||||
@@ -365,7 +365,7 @@ func (env *Environment) Shutdown() {
|
||||
env.TogglePluginHealthCheckJob(false)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
env.registeredPlugins.Range(func(key, value any) bool {
|
||||
rp := value.(registeredPlugin)
|
||||
|
||||
if rp.supervisor == nil || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
@@ -399,7 +399,7 @@ func (env *Environment) Shutdown() {
|
||||
|
||||
wg.Wait()
|
||||
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
env.registeredPlugins.Range(func(key, value any) bool {
|
||||
env.registeredPlugins.Delete(key)
|
||||
|
||||
return true
|
||||
@@ -484,7 +484,7 @@ func (env *Environment) HooksForPlugin(id string) (Hooks, error) {
|
||||
func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool, hookId int) {
|
||||
startTime := time.Now()
|
||||
|
||||
env.registeredPlugins.Range(func(key, value interface{}) bool {
|
||||
env.registeredPlugins.Range(func(key, value any) bool {
|
||||
rp := value.(registeredPlugin)
|
||||
|
||||
if rp.supervisor == nil || !rp.supervisor.Implements(hookId) || !env.IsActive(rp.BundleInfo.Manifest.Id) {
|
||||
@@ -502,7 +502,7 @@ func (env *Environment) RunMultiPluginHook(hookRunnerFunc func(hooks Hooks) bool
|
||||
return result
|
||||
})
|
||||
|
||||
env.registeredProducts.Range(func(key, value interface{}) bool {
|
||||
env.registeredProducts.Range(func(key, value any) bool {
|
||||
rp := value.(*registeredProduct)
|
||||
|
||||
if !rp.Implements(hookId) {
|
||||
|
||||
@@ -109,7 +109,7 @@ func (p *HelpPlugin) MessageHasBeenPosted(c *plugin.Context, post *model.Post) {
|
||||
p.API.SendEphemeralPost(post.UserId, &model.Post{
|
||||
ChannelId: configuration.channelID,
|
||||
Message: "You asked for help? Checkout https://support.mattermost.com/hc/en-us",
|
||||
Props: map[string]interface{}{
|
||||
Props: map[string]any{
|
||||
"sent_by_plugin": true,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -19,7 +19,7 @@ type hclogAdapter struct {
|
||||
extrasKey string
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Log(level hclog.Level, msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Log(level hclog.Level, msg string, args ...any) {
|
||||
switch level {
|
||||
case hclog.Trace:
|
||||
h.Trace(msg, args...)
|
||||
@@ -37,7 +37,7 @@ func (h *hclogAdapter) Log(level hclog.Level, msg string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Trace(msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Trace(msg string, args ...any) {
|
||||
extras := strings.TrimSpace(fmt.Sprint(args...))
|
||||
if extras != "" {
|
||||
h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, extras))
|
||||
@@ -46,7 +46,7 @@ func (h *hclogAdapter) Trace(msg string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Debug(msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Debug(msg string, args ...any) {
|
||||
extras := strings.TrimSpace(fmt.Sprint(args...))
|
||||
if extras != "" {
|
||||
h.wrappedLogger.Debug(msg, mlog.String(h.extrasKey, extras))
|
||||
@@ -55,7 +55,7 @@ func (h *hclogAdapter) Debug(msg string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Info(msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Info(msg string, args ...any) {
|
||||
extras := strings.TrimSpace(fmt.Sprint(args...))
|
||||
if extras != "" {
|
||||
h.wrappedLogger.Info(msg, mlog.String(h.extrasKey, extras))
|
||||
@@ -64,7 +64,7 @@ func (h *hclogAdapter) Info(msg string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Warn(msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Warn(msg string, args ...any) {
|
||||
extras := strings.TrimSpace(fmt.Sprint(args...))
|
||||
if extras != "" {
|
||||
h.wrappedLogger.Warn(msg, mlog.String(h.extrasKey, extras))
|
||||
@@ -73,7 +73,7 @@ func (h *hclogAdapter) Warn(msg string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Error(msg string, args ...interface{}) {
|
||||
func (h *hclogAdapter) Error(msg string, args ...any) {
|
||||
extras := strings.TrimSpace(fmt.Sprint(args...))
|
||||
if extras != "" {
|
||||
h.wrappedLogger.Error(msg, mlog.String(h.extrasKey, extras))
|
||||
@@ -102,7 +102,7 @@ func (h *hclogAdapter) IsError() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) With(args ...interface{}) hclog.Logger {
|
||||
func (h *hclogAdapter) With(args ...any) hclog.Logger {
|
||||
return h
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ func (h *hclogAdapter) StandardWriter(opts *hclog.StandardLoggerOptions) io.Writ
|
||||
|
||||
func (h *hclogAdapter) SetLevel(hclog.Level) {}
|
||||
|
||||
func (h *hclogAdapter) ImpliedArgs() []interface{} {
|
||||
return []interface{}{}
|
||||
func (h *hclogAdapter) ImpliedArgs() []any {
|
||||
return []any{}
|
||||
}
|
||||
|
||||
func (h *hclogAdapter) Name() string {
|
||||
|
||||
@@ -534,7 +534,7 @@ type HooksTemplateParams struct {
|
||||
}
|
||||
|
||||
func generateHooksGlue(info *PluginInterfaceInfo) {
|
||||
templateFunctions := map[string]interface{}{
|
||||
templateFunctions := map[string]any{
|
||||
"funcStyle": func(fields *ast.FieldList) string { return FieldListToFuncList(fields, info.FileSet) },
|
||||
"structStyle": func(fields *ast.FieldList) string { return FieldListToStructList(fields, info.FileSet) },
|
||||
"valuesOnly": func(fields *ast.FieldList) string { return FieldListToNames(fields, false) },
|
||||
@@ -586,7 +586,7 @@ func generateHooksGlue(info *PluginInterfaceInfo) {
|
||||
}
|
||||
|
||||
func generateProductHooksInterfaces(info *PluginInterfaceInfo) {
|
||||
templateFunctions := map[string]interface{}{
|
||||
templateFunctions := map[string]any{
|
||||
"funcStyle": func(fields *ast.FieldList) string { return FieldListToFuncList(fields, info.FileSet) },
|
||||
"valuesOnly": func(fields *ast.FieldList) string { return FieldListToNames(fields, false) },
|
||||
}
|
||||
@@ -619,7 +619,7 @@ func generateProductHooksInterfaces(info *PluginInterfaceInfo) {
|
||||
}
|
||||
|
||||
func generatePluginTimerLayer(info *PluginInterfaceInfo) {
|
||||
templateFunctions := map[string]interface{}{
|
||||
templateFunctions := map[string]any{
|
||||
"funcStyle": func(fields *ast.FieldList) string { return FieldListToFuncList(fields, info.FileSet) },
|
||||
"structStyle": func(fields *ast.FieldList) string { return FieldListToStructList(fields, info.FileSet) },
|
||||
"valuesOnly": func(fields *ast.FieldList) string { return FieldListToNames(fields, true) },
|
||||
|
||||
@@ -24,10 +24,10 @@ func AnythingOfType(t string) AnythingOfTypeArgument {
|
||||
return mock.AnythingOfType(t)
|
||||
}
|
||||
|
||||
func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool {
|
||||
func AssertExpectationsForObjects(t TestingT, testObjects ...any) bool {
|
||||
return mock.AssertExpectationsForObjects(t, testObjects...)
|
||||
}
|
||||
|
||||
func MatchedBy(fn interface{}) interface{} {
|
||||
func MatchedBy(fn any) any {
|
||||
return mock.MatchedBy(fn)
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func stringify(objects []interface{}) []string {
|
||||
func stringify(objects []any) []string {
|
||||
stringified := make([]string, len(objects))
|
||||
for i, object := range objects {
|
||||
stringified[i] = fmt.Sprintf("%+v", object)
|
||||
@@ -15,17 +15,17 @@ func stringify(objects []interface{}) []string {
|
||||
return stringified
|
||||
}
|
||||
|
||||
func toObjects(strings []string) []interface{} {
|
||||
func toObjects(strings []string) []any {
|
||||
if strings == nil {
|
||||
return nil
|
||||
}
|
||||
objects := make([]interface{}, len(strings))
|
||||
objects := make([]any, len(strings))
|
||||
for i, string := range strings {
|
||||
objects[i] = string
|
||||
}
|
||||
return objects
|
||||
}
|
||||
|
||||
func stringifyToObjects(objects []interface{}) []interface{} {
|
||||
func stringifyToObjects(objects []any) []any {
|
||||
return toObjects(stringify(objects))
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ func TestStringify(t *testing.T) {
|
||||
assert.Empty(t, strings)
|
||||
})
|
||||
t.Run("EmptyShouldReturnEmpty", func(t *testing.T) {
|
||||
strings := stringify(make([]interface{}, 0))
|
||||
strings := stringify(make([]any, 0))
|
||||
assert.Empty(t, strings)
|
||||
})
|
||||
t.Run("PrimitivesAndCompositesShouldReturnCorrectValues", func(t *testing.T) {
|
||||
strings := stringify([]interface{}{
|
||||
strings := stringify([]any{
|
||||
1234,
|
||||
3.14159265358979323846264338327950288419716939937510,
|
||||
true,
|
||||
@@ -46,7 +46,7 @@ func TestStringify(t *testing.T) {
|
||||
}, strings)
|
||||
})
|
||||
t.Run("ErrorShouldReturnFormattedStack", func(t *testing.T) {
|
||||
strings := stringify([]interface{}{
|
||||
strings := stringify([]any{
|
||||
errors.New("error"),
|
||||
errors.WithStack(errors.New("error")),
|
||||
})
|
||||
@@ -89,6 +89,6 @@ func TestToObjects(t *testing.T) {
|
||||
})
|
||||
t.Run("ShouldReturnSliceOfObjects", func(t *testing.T) {
|
||||
objects := toObjects([]string{"foo", "bar"})
|
||||
assert.Equal(t, []interface{}{"foo", "bar"}, objects)
|
||||
assert.Equal(t, []any{"foo", "bar"}, objects)
|
||||
})
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user