Replacing interface{} with any everywhere (except generated mocks) (#29446)

Этот коммит содержится в:
Jesús Espino
2024-12-15 21:11:36 +01:00
коммит произвёл GitHub
родитель a21d470bee
Коммит d316df6d28
34 изменённых файлов: 96 добавлений и 96 удалений

Просмотреть файл

@@ -1774,7 +1774,7 @@ func addChannelMember(c *Context, w http.ResponseWriter, r *http.Request) {
props := model.StringInterfaceFromJSON(r.Body)
var userIds []string
interfaceIds, ok := props["user_ids"].([]interface{})
interfaceIds, ok := props["user_ids"].([]any)
if ok {
if len(interfaceIds) > maxListSize {
c.SetInvalidParam("user_ids")

Просмотреть файл

@@ -401,8 +401,8 @@ func queryLogs(c *Context, w http.ResponseWriter, r *http.Request) {
return
}
logsJSON := make(map[string][]interface{})
var result interface{}
logsJSON := make(map[string][]any)
var result any
for node, logLines := range logs {
for _, log := range logLines {
err = json.Unmarshal([]byte(log), &result)

Просмотреть файл

@@ -88,7 +88,7 @@ func (a *App) MakeAuditRecord(rctx request.CTX, event string, initialStatus stri
rec := &audit.Record{
EventName: event,
Status: initialStatus,
Meta: map[string]interface{}{
Meta: map[string]any{
audit.KeyAPIPath: "",
audit.KeyClusterID: a.GetClusterId(),
},
@@ -100,9 +100,9 @@ func (a *App) MakeAuditRecord(rctx request.CTX, event string, initialStatus stri
XForwardedFor: "",
},
EventData: audit.EventData{
Parameters: map[string]interface{}{},
PriorState: map[string]interface{}{},
ResultState: map[string]interface{}{},
Parameters: map[string]any{},
PriorState: map[string]any{},
ResultState: map[string]any{},
ObjectType: "",
},
}

Просмотреть файл

@@ -42,7 +42,7 @@ func (a *App) UpsertDraft(c request.CTX, draft *model.Draft, connectionID string
// Check that channel exists and has not been deleted
channel, errCh := a.Srv().Store().Channel().Get(draft.ChannelId, true)
if errCh != nil {
err := model.NewAppError("CreateDraft", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "draft.channel_id"}, "", http.StatusBadRequest).Wrap(errCh)
err := model.NewAppError("CreateDraft", "api.context.invalid_param.app_error", map[string]any{"Name": "draft.channel_id"}, "", http.StatusBadRequest).Wrap(errCh)
return nil, err
}

Просмотреть файл

@@ -114,7 +114,7 @@ func (a *App) elasticsearchChannelIndexCheck() {
}
// TODO include a link to changelog
postMessage := i18n.T("app.channel.elasticsearch_channel_index.notify_admin.message", map[string]interface{}{"ElasticsearchSection": elasticsearchSettingsSectionLink})
postMessage := i18n.T("app.channel.elasticsearch_channel_index.notify_admin.message", map[string]any{"ElasticsearchSection": elasticsearchSettingsSectionLink})
for _, sysAdmin := range sysAdmins {
var channel *model.Channel

Просмотреть файл

@@ -1512,7 +1512,7 @@ func (a *App) GetLastAccessibleFileTime() (int64, *model.AppError) {
lastAccessibleFileTime, err := strconv.ParseInt(system.Value, 10, 64)
if err != nil {
return 0, model.NewAppError("GetLastAccessibleFileTime", "common.parse_error_int64", map[string]interface{}{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
return 0, model.NewAppError("GetLastAccessibleFileTime", "common.parse_error_int64", map[string]any{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
}
return lastAccessibleFileTime, nil

Просмотреть файл

@@ -127,7 +127,7 @@ func (a *App) isUniqueToUsernames(val string) *model.AppError {
return model.NewAppError("isUniqueToUsernames", model.NoTranslation, nil, "", http.StatusInternalServerError).Wrap(err)
}
if user != nil {
return model.NewAppError("isUniqueToUsernames", "app.group.username_conflict", map[string]interface{}{"Username": val}, "", http.StatusBadRequest)
return model.NewAppError("isUniqueToUsernames", "app.group.username_conflict", map[string]any{"Username": val}, "", http.StatusBadRequest)
}
return nil
}

Просмотреть файл

@@ -135,14 +135,14 @@ func (a *App) upgradePlanAdminNotifyPost(c request.CTX, workspaceName string, us
props := make(model.StringInterface)
T := i18n.GetUserTranslations(admin.Locale)
message := T("app.cloud.upgrade_plan_bot_message", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
message := T("app.cloud.upgrade_plan_bot_message", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
if len(userBasedData) == 1 {
message = T("app.cloud.upgrade_plan_bot_message_single", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName}) // todo (allan): investigate if translations library can do this
message = T("app.cloud.upgrade_plan_bot_message_single", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName}) // todo (allan): investigate if translations library can do this
}
if trial {
message = T("app.cloud.trial_plan_bot_message", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
message = T("app.cloud.trial_plan_bot_message", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
if len(userBasedData) == 1 {
message = T("app.cloud.trial_plan_bot_message_single", map[string]interface{}{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
message = T("app.cloud.trial_plan_bot_message_single", map[string]any{"UsersNum": len(userBasedData), "WorkspaceName": workspaceName})
}
}

Просмотреть файл

@@ -114,11 +114,11 @@ func (ps *PlatformService) ReloadConfig() error {
return nil
}
func (ps *PlatformService) GetEnvironmentOverridesWithFilter(filter func(reflect.StructField) bool) map[string]interface{} {
func (ps *PlatformService) GetEnvironmentOverridesWithFilter(filter func(reflect.StructField) bool) map[string]any {
return ps.configStore.GetEnvironmentOverridesWithFilter(filter)
}
func (ps *PlatformService) GetEnvironmentOverrides() map[string]interface{} {
func (ps *PlatformService) GetEnvironmentOverrides() map[string]any {
return ps.configStore.GetEnvironmentOverrides()
}

Просмотреть файл

@@ -1597,7 +1597,7 @@ func (a *App) GetLastAccessiblePostTime() (int64, *model.AppError) {
lastAccessiblePostTime, err := strconv.ParseInt(system.Value, 10, 64)
if err != nil {
return 0, model.NewAppError("GetLastAccessiblePostTime", "common.parse_error_int64", map[string]interface{}{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
return 0, model.NewAppError("GetLastAccessiblePostTime", "common.parse_error_int64", map[string]any{"Value": system.Value}, "", http.StatusInternalServerError).Wrap(err)
}
return lastAccessiblePostTime, nil

Просмотреть файл

@@ -451,7 +451,7 @@ func (a *App) notifyUser(rctx request.CTX, userId string, userFailedMessages []*
var messageBuilder strings.Builder
totalFailedMessages := len(userFailedMessages)
messageHeader := T("app.scheduled_post.failed_messages", map[string]interface{}{
messageHeader := T("app.scheduled_post.failed_messages", map[string]any{
"Count": totalFailedMessages,
})
messageBuilder.WriteString(messageHeader)
@@ -461,7 +461,7 @@ func (a *App) notifyUser(rctx request.CTX, userId string, userFailedMessages []*
channelName := channelNames[key.ChannelId]
errorReason := getErrorReason(T, key.ErrorCode)
detailedMessage := T("app.scheduled_post.failed_message_detail", map[string]interface{}{
detailedMessage := T("app.scheduled_post.failed_message_detail", map[string]any{
"Count": count,
"ChannelName": channelName,
"ErrorReason": errorReason,

Просмотреть файл

@@ -384,7 +384,7 @@ func TestHandleFailedScheduledPosts(t *testing.T) {
}
T := i18n.GetUserTranslations(user.Locale)
messageHeader := T("app.scheduled_post.failed_messages", map[string]interface{}{
messageHeader := T("app.scheduled_post.failed_messages", map[string]any{
"Count": len(userFailedMessages),
})

Просмотреть файл

@@ -113,7 +113,7 @@ func (*ExportLinkProvider) DoCommand(a *app.App, c request.CTX, args *model.Comm
}
// return link
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command_exportlink.link.text", map[string]interface{}{
return &model.CommandResponse{ResponseType: model.CommandResponseTypeEphemeral, Text: args.T("api.command_exportlink.link.text", map[string]any{
"Link": res.URL,
"Expiration": res.Expiration.String(),
})}

Просмотреть файл

@@ -261,7 +261,7 @@ func (a *App) createUserOrGuest(c request.CTX, user *model.User, guest bool) (*m
case errors.Is(nErr, users.AcceptedDomainError):
return nil, model.NewAppError("createUserOrGuest", "api.user.create_user.accepted_domain.app_error", nil, "", http.StatusBadRequest).Wrap(nErr)
case errors.As(nErr, &nfErr):
return nil, model.NewAppError("createUserOrGuest", nfErr.Id(), map[string]interface{}{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
return nil, model.NewAppError("createUserOrGuest", nfErr.Id(), map[string]any{"Min": *a.Config().PasswordSettings.MinimumLength}, "", http.StatusBadRequest)
case errors.Is(nErr, users.UserStoreIsEmptyError):
return nil, model.NewAppError("createUserOrGuest", "app.user.store_is_empty.app_error", nil, "", http.StatusInternalServerError).Wrap(nErr)
case errors.As(nErr, &invErr):

Просмотреть файл

@@ -5,20 +5,20 @@ package audit
// Record provides a consistent set of fields used for all audit logging.
type Record struct {
EventName string `json:"event_name"`
Status string `json:"status"`
EventData EventData `json:"event"`
Actor EventActor `json:"actor"`
Meta map[string]interface{} `json:"meta"`
Error EventError `json:"error,omitempty"`
EventName string `json:"event_name"`
Status string `json:"status"`
EventData EventData `json:"event"`
Actor EventActor `json:"actor"`
Meta map[string]any `json:"meta"`
Error EventError `json:"error,omitempty"`
}
// EventData contains all event specific data about the modified entity
type EventData struct {
Parameters map[string]interface{} `json:"parameters"` // Payload and parameters being processed as part of the request
PriorState map[string]interface{} `json:"prior_state"` // Prior state of the object being modified, nil if no prior state
ResultState map[string]interface{} `json:"resulting_state"` // Resulting object after creating or modifying it
ObjectType string `json:"object_type"` // String representation of the object type. eg. "post"
Parameters map[string]any `json:"parameters"` // Payload and parameters being processed as part of the request
PriorState map[string]any `json:"prior_state"` // Prior state of the object being modified, nil if no prior state
ResultState map[string]any `json:"resulting_state"` // Resulting object after creating or modifying it
ObjectType string `json:"object_type"` // String representation of the object type. eg. "post"
}
// EventActor is the subject triggering the event
@@ -46,7 +46,7 @@ type EventError struct {
// AuditableObject returns. For example: it's likely OK to write a user object to the
// audit logs, but not the user password in cleartext or hashed form
type Auditable interface {
Auditable() map[string]interface{}
Auditable() map[string]any
}
// Success marks the audit record status as successful.
@@ -62,7 +62,7 @@ func (rec *Record) Fail() {
// AddEventParameter adds a parameter, e.g. query or post body, to the event
func AddEventParameter[T string | bool | int | int64 | []string | map[string]string](rec *Record, key string, val T) {
if rec.EventData.Parameters == nil {
rec.EventData.Parameters = make(map[string]interface{})
rec.EventData.Parameters = make(map[string]any)
}
rec.EventData.Parameters[key] = val
@@ -71,7 +71,7 @@ func AddEventParameter[T string | bool | int | int64 | []string | map[string]str
// AddEventParameterAuditable adds an object that is of type Auditable to the event
func AddEventParameterAuditable(rec *Record, key string, val Auditable) {
if rec.EventData.Parameters == nil {
rec.EventData.Parameters = make(map[string]interface{})
rec.EventData.Parameters = make(map[string]any)
}
rec.EventData.Parameters[key] = val.Auditable()
@@ -80,10 +80,10 @@ func AddEventParameterAuditable(rec *Record, key string, val Auditable) {
// AddEventParameterAuditableArray adds an array of objects of type Auditable to the event
func AddEventParameterAuditableArray[T Auditable](rec *Record, key string, val []T) {
if rec.EventData.Parameters == nil {
rec.EventData.Parameters = make(map[string]interface{})
rec.EventData.Parameters = make(map[string]any)
}
processedAuditables := make([]map[string]interface{}, 0, len(val))
processedAuditables := make([]map[string]any, 0, len(val))
for _, auditableVal := range val {
processedAuditables = append(processedAuditables, auditableVal.Auditable())
}
@@ -108,7 +108,7 @@ func (rec *Record) AddEventObjectType(objectType string) {
// AddMeta adds a key/value entry to the audit record that can be used for related information not directly related to
// the modified object, e.g. authentication method
func (rec *Record) AddMeta(name string, val interface{}) {
func (rec *Record) AddMeta(name string, val any) {
rec.Meta[name] = val
}

Просмотреть файл

@@ -38,8 +38,8 @@ func draftSliceColumns() []string {
}
}
func draftToSlice(draft *model.Draft) []interface{} {
return []interface{}{
func draftToSlice(draft *model.Draft) []any {
return []any{
draft.CreateAt,
draft.UpdateAt,
draft.DeleteAt,

Просмотреть файл

@@ -319,7 +319,7 @@ func (s SqlPreferenceStore) CleanupFlagsBatch(limit int64) (int64, error) {
// Delete preference for limit_visible_dms_gms where their value is greater than "40" or less than "1"
func (s SqlPreferenceStore) DeleteInvalidVisibleDmsGms() (int64, error) {
var queryString string
var args []interface{}
var args []any
var err error
// We need to pad the value field with zeros when doing comparison's because the value is stored as a string.

Просмотреть файл

@@ -48,8 +48,8 @@ func (s *SqlScheduledPostStore) columns(prefix string) []string {
}
}
func (s *SqlScheduledPostStore) scheduledPostToSlice(scheduledPost *model.ScheduledPost) []interface{} {
return []interface{}{
func (s *SqlScheduledPostStore) scheduledPostToSlice(scheduledPost *model.ScheduledPost) []any {
return []any{
scheduledPost.Id,
scheduledPost.CreateAt,
scheduledPost.UpdateAt,
@@ -230,9 +230,9 @@ func (s *SqlScheduledPostStore) UpdatedScheduledPost(scheduledPost *model.Schedu
return nil
}
func (s *SqlScheduledPostStore) toUpdateMap(scheduledPost *model.ScheduledPost) map[string]interface{} {
func (s *SqlScheduledPostStore) toUpdateMap(scheduledPost *model.ScheduledPost) map[string]any {
now := model.GetMillis()
return map[string]interface{}{
return map[string]any{
"UpdateAt": now,
"Message": scheduledPost.Message,
"Props": model.StringInterfaceToJSON(scheduledPost.GetProps()),

Просмотреть файл

@@ -71,14 +71,14 @@ func (c *Context) MakeAuditRecord(event string, initialStatus string) *audit.Rec
IpAddress: c.AppContext.IPAddress(),
XForwardedFor: c.AppContext.XForwardedFor(),
},
Meta: map[string]interface{}{
Meta: map[string]any{
audit.KeyAPIPath: c.AppContext.Path(),
audit.KeyClusterID: c.App.GetClusterId(),
},
EventData: audit.EventData{
Parameters: map[string]interface{}{},
PriorState: map[string]interface{}{},
ResultState: map[string]interface{}{},
Parameters: map[string]any{},
PriorState: map[string]any{},
ResultState: map[string]any{},
ObjectType: "",
},
}

Просмотреть файл

@@ -21,7 +21,7 @@ import (
func (s *MmctlE2ETestSuite) TestListChannelsCmdF() {
s.SetupTestHelper().InitBasic()
var assertChannelNames = func(want []string, lines []interface{}) {
var assertChannelNames = func(want []string, lines []any) {
var got []string
for i := 0; i < len(lines); i++ {
got = append(got, lines[i].(*model.Channel).Name)

Просмотреть файл

@@ -226,9 +226,9 @@ func archiveCommandCmdF(c client.Client, cmd *cobra.Command, args []string) erro
}
if resp.StatusCode == http.StatusOK {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "ok"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "ok"})
} else {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "error"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "error"})
}
return nil
}
@@ -320,9 +320,9 @@ func moveCommandCmdF(c client.Client, cmd *cobra.Command, args []string) error {
}
if resp.StatusCode == http.StatusOK {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "ok"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "ok"})
} else {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "error"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "error"})
}
return nil
}

Просмотреть файл

@@ -207,7 +207,7 @@ func (s *MmctlE2ETestSuite) TestArchiveCommandCmdF() {
err := archiveCommandCmdF(c, &cobra.Command{}, []string{command.Id})
s.Require().Nil(err)
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal(map[string]interface{}{"status": "ok"}, printer.GetLines()[0])
s.Require().Equal(map[string]any{"status": "ok"}, printer.GetLines()[0])
s.Require().Len(printer.GetErrorLines(), 0)
rcommand, err := s.th.App.GetCommand(command.Id)

Просмотреть файл

@@ -340,7 +340,7 @@ func (s *MmctlUnitTestSuite) TestArchiveCommandCmd() {
s.Run("Delete without errors", func() {
printer.Clean()
arg := "cmd1"
outputMessage := map[string]interface{}{"status": "ok"}
outputMessage := map[string]any{"status": "ok"}
s.client.
EXPECT().
@@ -358,7 +358,7 @@ func (s *MmctlUnitTestSuite) TestArchiveCommandCmd() {
s.Run("Not able to delete", func() {
printer.Clean()
arg := "cmd1"
outputMessage := map[string]interface{}{"status": "error"}
outputMessage := map[string]any{"status": "error"}
s.client.
EXPECT().
@@ -784,8 +784,8 @@ func (s *MmctlUnitTestSuite) TestCommandMoveCmd() {
}
mockError := errors.New("mock error")
outputMessageOK := map[string]interface{}{"status": "ok"}
outputMessageError := map[string]interface{}{"status": "error"}
outputMessageOK := map[string]any{"status": "ok"}
outputMessageError := map[string]any{"status": "error"}
s.Run("Move custom slash command to another team by id", func() {
printer.Clean()

Просмотреть файл

@@ -142,7 +142,7 @@ func init() {
RootCmd.AddCommand(ConfigCmd)
}
func getValue(path []string, obj interface{}) (interface{}, bool) {
func getValue(path []string, obj any) (any, bool) {
r := reflect.ValueOf(obj)
var val reflect.Value
if r.Kind() == reflect.Map {
@@ -187,7 +187,7 @@ func getValue(path []string, obj interface{}) (interface{}, bool) {
return nil, false
}
func setValueWithConversion(val reflect.Value, newValue interface{}) error {
func setValueWithConversion(val reflect.Value, newValue any) error {
switch val.Kind() {
case reflect.Struct:
val.Set(reflect.ValueOf(newValue))
@@ -236,7 +236,7 @@ func setValueWithConversion(val reflect.Value, newValue interface{}) error {
}
}
func setValue(path []string, obj reflect.Value, newValue interface{}) error {
func setValue(path []string, obj reflect.Value, newValue any) error {
var val reflect.Value
switch obj.Kind() {
case reflect.Struct:
@@ -307,7 +307,7 @@ func setConfigValue(path []string, config *model.Config, newValue []string) erro
return setValue(path, reflect.ValueOf(config).Elem(), newValue[0])
}
func resetConfigValue(path []string, config *model.Config, newValue interface{}) error {
func resetConfigValue(path []string, config *model.Config, newValue any) error {
nv := reflect.ValueOf(newValue)
if nv.Kind() == reflect.Ptr {
switch nv.Elem().Kind() {

Просмотреть файл

@@ -186,7 +186,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() {
s.Run("Get value if the key points to a map element", func() {
outputConfig := &model.Config{}
pluginState := &model.PluginState{Enable: true}
pluginSettings := map[string]interface{}{
pluginSettings := map[string]any{
"test1": 1,
"test2": []string{"a", "b"},
"test3": map[string]string{"a": "b"},
@@ -194,7 +194,7 @@ func (s *MmctlUnitTestSuite) TestConfigGetCmd() {
outputConfig.PluginSettings.PluginStates = map[string]*model.PluginState{
"com.mattermost.testplugin": pluginState,
}
outputConfig.PluginSettings.Plugins = map[string]map[string]interface{}{
outputConfig.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.testplugin": pluginSettings,
}
@@ -499,12 +499,12 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() {
defaultConfig.PluginSettings.PluginStates = map[string]*model.PluginState{
"com.mattermost.testplugin": {Enable: false},
}
pluginSettings := map[string]interface{}{
pluginSettings := map[string]any{
"test1": 1,
"test2": []string{"a", "b"},
"test3": map[string]interface{}{"a": "b"},
"test3": map[string]any{"a": "b"},
}
defaultConfig.PluginSettings.Plugins = map[string]map[string]interface{}{
defaultConfig.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.testplugin": pluginSettings,
}
@@ -513,7 +513,7 @@ func (s *MmctlUnitTestSuite) TestConfigSetCmd() {
inputConfig.PluginSettings.PluginStates = map[string]*model.PluginState{
"com.mattermost.testplugin": {Enable: true},
}
inputConfig.PluginSettings.Plugins = map[string]map[string]interface{}{
inputConfig.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.testplugin": pluginSettings,
}
s.client.

Просмотреть файл

@@ -205,7 +205,7 @@ func exportGeneratePresignedURLCmdF(c client.Client, command *cobra.Command, arg
return fmt.Errorf("failed to generate export link: %w", err)
}
printer.PrintT("Export link: {{.Link}}\nExpiration: {{.Expiration}}", map[string]interface{}{
printer.PrintT("Export link: {{.Link}}\nExpiration: {{.Expiration}}", map[string]any{
"Link": presignedURL.URL,
"Expiration": presignedURL.Expiration.String(),
})

Просмотреть файл

@@ -98,9 +98,9 @@ func ldapSyncCmdF(c client.Client, cmd *cobra.Command, args []string) error {
}
if resp.StatusCode == http.StatusOK {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "ok"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "ok"})
} else {
printer.PrintT("Status: {{.status}}", map[string]interface{}{"status": "error"})
printer.PrintT("Status: {{.status}}", map[string]any{"status": "error"})
}
return nil

Просмотреть файл

@@ -72,7 +72,7 @@ func (s *MmctlE2ETestSuite) TestLdapSyncCmd() {
s.Require().NoError(err)
s.Require().NotEmpty(printer.GetLines())
s.Require().Equal(printer.GetLines()[0], map[string]interface{}{"status": "ok"})
s.Require().Equal(printer.GetLines()[0], map[string]any{"status": "ok"})
s.Require().Len(printer.GetErrorLines(), 0)
// we need to wait a bit for job creation

Просмотреть файл

@@ -18,7 +18,7 @@ import (
func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.Run("Sync without errors", func() {
printer.Clean()
outputMessage := map[string]interface{}{"status": "ok"}
outputMessage := map[string]any{"status": "ok"}
s.client.
EXPECT().
@@ -35,7 +35,7 @@ func (s *MmctlUnitTestSuite) TestLdapSyncCmd() {
s.Run("Not able to Sync", func() {
printer.Clean()
outputMessage := map[string]interface{}{"status": "error"}
outputMessage := map[string]any{"status": "error"}
s.client.
EXPECT().

Просмотреть файл

@@ -123,7 +123,7 @@ func postCreateCmdF(c client.Client, cmd *cobra.Command, args []string) error {
return nil
}
func eventDataToPost(eventData map[string]interface{}) (*model.Post, error) {
func eventDataToPost(eventData map[string]any) (*model.Post, error) {
post := &model.Post{}
var rawPost string
for k, v := range eventData {

Просмотреть файл

@@ -92,7 +92,7 @@ func parseLogMessage(msg string) (result LogEntry, err error) {
result.Caller = s
default:
var p interface{}
var p any
if err2 := dec.Decode(&p); err2 != nil {
return result, err2
}
@@ -167,7 +167,7 @@ func numberToTime(v json.Number) (time.Time, error) {
// Decodes a value from JSON, coercing it to a string value as necessary
func decodeAsString(dec *json.Decoder) (s string, err error) {
var v interface{}
var v any
if err = dec.Decode(&v); err != nil {
return s, err
}

Просмотреть файл

@@ -32,7 +32,7 @@ type Printer struct { //nolint
templateFuncs template.FuncMap
pager bool
Quiet bool
Lines []interface{}
Lines []any
ErrorLines []string
cmd *cobra.Command
@@ -85,7 +85,7 @@ func SetNoNewline(no bool) {
printer.NoNewline = no
}
func SetTemplateFunc(name string, f interface{}) {
func SetTemplateFunc(name string, f any) {
printer.templateFuncs[name] = f
}
@@ -100,7 +100,7 @@ func SetSingle(single bool) {
// PrintT prints an element. Depending on the format, the element can be
// formatted and printed as a structure or used to populate the
// template
func PrintT(templateString string, v interface{}) {
func PrintT(templateString string, v any) {
if printer.Quiet {
return
}
@@ -118,7 +118,7 @@ func PrintT(templateString string, v interface{}) {
}
}
func PrintPreparedT(tpl *template.Template, v interface{}) {
func PrintPreparedT(tpl *template.Template, v any) {
if printer.Quiet {
return
}
@@ -138,7 +138,7 @@ func PrintPreparedT(tpl *template.Template, v interface{}) {
// Print an element. If the format requires a template, the element
// will be printed as a structure with field names using the print
// verb %+v
func Print(v interface{}) {
func Print(v any) {
PrintT("{{printf \"%+v\" .}}", v)
}
@@ -192,7 +192,7 @@ func Flush() error {
printer.printErrors()
defer func() {
printer.Lines = []interface{}{}
printer.Lines = []any{}
printer.ErrorLines = []string{}
}()
@@ -231,12 +231,12 @@ func Flush() error {
// Clean resets the printer's accumulated lines
func Clean() {
printer.Lines = []interface{}{}
printer.Lines = []any{}
printer.ErrorLines = []string{}
}
// GetLines returns the printer's accumulated lines
func GetLines() []interface{} {
func GetLines() []any {
return printer.Lines
}

Просмотреть файл

@@ -18,20 +18,20 @@ type ConfigDiff struct {
ActualVal any `json:"actual_val"`
}
func (c *ConfigDiff) Auditable() map[string]interface{} {
return map[string]interface{}{
func (c *ConfigDiff) Auditable() map[string]any {
return map[string]any{
"path": c.Path,
"base_val": c.BaseVal,
"actual_val": c.ActualVal,
}
}
func (cd *ConfigDiffs) Auditable() map[string]interface{} {
var s []interface{}
func (cd *ConfigDiffs) Auditable() map[string]any {
var s []any
for _, d := range cd.Sanitize() {
s = append(s, d.Auditable())
}
return map[string]interface{}{
return map[string]any{
"config_diffs": s,
}
}

Просмотреть файл

@@ -39,7 +39,7 @@ func TestRemoveEnvOverrides(t *testing.T) {
Enable: false,
},
}
in.PluginSettings.Plugins = map[string]map[string]interface{}{
in.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.plugin-1": {
"key1": "value1",
},
@@ -71,7 +71,7 @@ func TestRemoveEnvOverrides(t *testing.T) {
Enable: true,
},
}
in.PluginSettings.Plugins = map[string]map[string]interface{}{
in.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.plugin-1": {
"key1": "other-value",
},
@@ -166,9 +166,9 @@ func TestRemoveEnvOverrides(t *testing.T) {
Enable: true,
},
}
in.PluginSettings.Plugins = map[string]map[string]interface{}{
in.PluginSettings.Plugins = map[string]map[string]any{
"com.mattermost.plugin-1": {
"key": map[string]interface{}{
"key": map[string]any{
"key": "(?P<key>KEY)-(?P<id>\\d{1,6})(?P<comma>[,;]*)",
"value": "[$key-$id](https://example.com/?$project-$id)$comma",
},