Enforce use of any instead of interface{} (#30588)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
9aa4818c71
Коммит
166a676fe5
@@ -4,6 +4,9 @@ run:
|
|||||||
linters-settings:
|
linters-settings:
|
||||||
gofmt:
|
gofmt:
|
||||||
simplify: true
|
simplify: true
|
||||||
|
rewrite-rules:
|
||||||
|
- pattern: 'interface{}'
|
||||||
|
replacement: 'any'
|
||||||
govet:
|
govet:
|
||||||
enable-all: true
|
enable-all: true
|
||||||
disable:
|
disable:
|
||||||
@@ -54,6 +57,10 @@ issues:
|
|||||||
- staticcheck
|
- staticcheck
|
||||||
text: SA1019
|
text: SA1019
|
||||||
|
|
||||||
|
- linters:
|
||||||
|
- gofmt
|
||||||
|
path: "mock.*"
|
||||||
|
|
||||||
- linters:
|
- linters:
|
||||||
- errcheck
|
- errcheck
|
||||||
path: "\
|
path: "\
|
||||||
|
|||||||
@@ -140,8 +140,8 @@ func channelSliceColumns(prefix ...string) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func channelToSlice(channel *model.Channel) []interface{} {
|
func channelToSlice(channel *model.Channel) []any {
|
||||||
return []interface{}{
|
return []any{
|
||||||
channel.Id,
|
channel.Id,
|
||||||
channel.CreateAt,
|
channel.CreateAt,
|
||||||
channel.UpdateAt,
|
channel.UpdateAt,
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ type Bot struct {
|
|||||||
DeleteAt int64 `json:"delete_at"`
|
DeleteAt int64 `json:"delete_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Bot) Auditable() map[string]interface{} {
|
func (b *Bot) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"user_id": b.UserId,
|
"user_id": b.UserId,
|
||||||
"username": b.Username,
|
"username": b.Username,
|
||||||
"display_name": b.DisplayName,
|
"display_name": b.DisplayName,
|
||||||
@@ -54,8 +54,8 @@ type BotPatch struct {
|
|||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BotPatch) Auditable() map[string]interface{} {
|
func (b *BotPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"username": b.Username,
|
"username": b.Username,
|
||||||
"display_name": b.DisplayName,
|
"display_name": b.DisplayName,
|
||||||
"description": b.Description,
|
"description": b.Description,
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ type ChannelBannerInfo struct {
|
|||||||
BackgroundColor *string `json:"background_color"`
|
BackgroundColor *string `json:"background_color"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelBannerInfo) Scan(value interface{}) error {
|
func (c *ChannelBannerInfo) Scan(value any) error {
|
||||||
if value == nil {
|
if value == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@@ -96,8 +96,8 @@ type Channel struct {
|
|||||||
BannerInfo *ChannelBannerInfo `json:"banner_info"`
|
BannerInfo *ChannelBannerInfo `json:"banner_info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Channel) Auditable() map[string]interface{} {
|
func (o *Channel) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"creator_id": o.CreatorId,
|
"creator_id": o.CreatorId,
|
||||||
"delete_at": o.DeleteAt,
|
"delete_at": o.DeleteAt,
|
||||||
@@ -142,8 +142,8 @@ type ChannelPatch struct {
|
|||||||
BannerInfo *ChannelBannerInfo `json:"banner_info"`
|
BannerInfo *ChannelBannerInfo `json:"banner_info"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelPatch) Auditable() map[string]interface{} {
|
func (c *ChannelPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"header": c.Header,
|
"header": c.Header,
|
||||||
"group_constrained": c.GroupConstrained,
|
"group_constrained": c.GroupConstrained,
|
||||||
"purpose": c.Purpose,
|
"purpose": c.Purpose,
|
||||||
@@ -181,8 +181,8 @@ type ChannelModerationPatch struct {
|
|||||||
Roles *ChannelModeratedRolesPatch `json:"roles"`
|
Roles *ChannelModeratedRolesPatch `json:"roles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelModerationPatch) Auditable() map[string]interface{} {
|
func (c *ChannelModerationPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"name": c.Name,
|
"name": c.Name,
|
||||||
"roles": c.Roles,
|
"roles": c.Roles,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ type ChannelBookmark struct {
|
|||||||
ParentId string `json:"parent_id,omitempty"`
|
ParentId string `json:"parent_id,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ChannelBookmark) Auditable() map[string]interface{} {
|
func (o *ChannelBookmark) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
@@ -193,8 +193,8 @@ type ChannelBookmarkPatch struct {
|
|||||||
Emoji *string `json:"emoji,omitempty"`
|
Emoji *string `json:"emoji,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ChannelBookmarkPatch) Auditable() map[string]interface{} {
|
func (o *ChannelBookmarkPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"file_id": o.FileId,
|
"file_id": o.FileId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -226,7 +226,7 @@ type ChannelBookmarkWithFileInfo struct {
|
|||||||
FileInfo *FileInfo `json:"file,omitempty"`
|
FileInfo *FileInfo `json:"file,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ChannelBookmarkWithFileInfo) Auditable() map[string]interface{} {
|
func (o *ChannelBookmarkWithFileInfo) Auditable() map[string]any {
|
||||||
a := o.ChannelBookmark.Auditable()
|
a := o.ChannelBookmark.Auditable()
|
||||||
if o.FileInfo != nil {
|
if o.FileInfo != nil {
|
||||||
a["file"] = o.FileInfo.Auditable()
|
a["file"] = o.FileInfo.Auditable()
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ type ChannelMember struct {
|
|||||||
ExplicitRoles string `json:"explicit_roles"`
|
ExplicitRoles string `json:"explicit_roles"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *ChannelMember) Auditable() map[string]interface{} {
|
func (o *ChannelMember) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"channel_id": o.ChannelId,
|
"channel_id": o.ChannelId,
|
||||||
"user_id": o.UserId,
|
"user_id": o.UserId,
|
||||||
"roles": o.Roles,
|
"roles": o.Roles,
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ type Command struct {
|
|||||||
AutocompleteIconData string `db:"-" json:"autocomplete_icon_data,omitempty"`
|
AutocompleteIconData string `db:"-" json:"autocomplete_icon_data,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Command) Auditable() map[string]interface{} {
|
func (o *Command) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ type CommandArgs struct {
|
|||||||
ChannelMentions ChannelMentionMap `json:"-"`
|
ChannelMentions ChannelMentionMap `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *CommandArgs) Auditable() map[string]interface{} {
|
func (o *CommandArgs) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"user_id": o.UserId,
|
"user_id": o.UserId,
|
||||||
"channel_id": o.ChannelId,
|
"channel_id": o.ChannelId,
|
||||||
"team_id": o.TeamId,
|
"team_id": o.TeamId,
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ type Compliance struct {
|
|||||||
Emails string `json:"emails"`
|
Emails string `json:"emails"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Compliance) Auditable() map[string]interface{} {
|
func (c *Compliance) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": c.Id,
|
"id": c.Id,
|
||||||
"create_at": c.CreateAt,
|
"create_at": c.CreateAt,
|
||||||
"user_id": c.UserId,
|
"user_id": c.UserId,
|
||||||
|
|||||||
@@ -3741,8 +3741,8 @@ type Config struct {
|
|||||||
ConnectedWorkspacesSettings ConnectedWorkspacesSettings
|
ConnectedWorkspacesSettings ConnectedWorkspacesSettings
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Config) Auditable() map[string]interface{} {
|
func (o *Config) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ type RetentionPolicyWithTeamAndChannelIDs struct {
|
|||||||
ChannelIDs []string `json:"channel_ids"`
|
ChannelIDs []string `json:"channel_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *RetentionPolicyWithTeamAndChannelIDs) Auditable() map[string]interface{} {
|
func (o *RetentionPolicyWithTeamAndChannelIDs) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"retention_policy": o.RetentionPolicy,
|
"retention_policy": o.RetentionPolicy,
|
||||||
"team_ids": o.TeamIDs,
|
"team_ids": o.TeamIDs,
|
||||||
"channel_ids": o.ChannelIDs,
|
"channel_ids": o.ChannelIDs,
|
||||||
@@ -36,8 +36,8 @@ type RetentionPolicyWithTeamAndChannelCounts struct {
|
|||||||
TeamCount int64 `json:"team_count"`
|
TeamCount int64 `json:"team_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *RetentionPolicyWithTeamAndChannelCounts) Auditable() map[string]interface{} {
|
func (o *RetentionPolicyWithTeamAndChannelCounts) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"retention_policy": o.RetentionPolicy,
|
"retention_policy": o.RetentionPolicy,
|
||||||
"channel_count": o.ChannelCount,
|
"channel_count": o.ChannelCount,
|
||||||
"team_count": o.TeamCount,
|
"team_count": o.TeamCount,
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (o *Draft) PreSave() {
|
|||||||
|
|
||||||
func (o *Draft) PreCommit() {
|
func (o *Draft) PreCommit() {
|
||||||
if o.GetProps() == nil {
|
if o.GetProps() == nil {
|
||||||
o.SetProps(make(map[string]interface{}))
|
o.SetProps(make(map[string]any))
|
||||||
}
|
}
|
||||||
|
|
||||||
if o.FileIds == nil {
|
if o.FileIds == nil {
|
||||||
|
|||||||
@@ -25,8 +25,8 @@ type Emoji struct {
|
|||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (emoji *Emoji) Auditable() map[string]interface{} {
|
func (emoji *Emoji) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": emoji.Id,
|
"id": emoji.Id,
|
||||||
"create_at": emoji.CreateAt,
|
"create_at": emoji.CreateAt,
|
||||||
"update_at": emoji.UpdateAt,
|
"update_at": emoji.UpdateAt,
|
||||||
|
|||||||
@@ -59,8 +59,8 @@ type FileInfo struct {
|
|||||||
Archived bool `json:"archived"`
|
Archived bool `json:"archived"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fi *FileInfo) Auditable() map[string]interface{} {
|
func (fi *FileInfo) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": fi.Id,
|
"id": fi.Id,
|
||||||
"creator_id": fi.CreatorId,
|
"creator_id": fi.CreatorId,
|
||||||
"post_id": fi.PostId,
|
"post_id": fi.PostId,
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ type Group struct {
|
|||||||
MemberIDs []string `db:"-" json:"member_ids"`
|
MemberIDs []string `db:"-" json:"member_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (group *Group) Auditable() map[string]interface{} {
|
func (group *Group) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": group.Id,
|
"id": group.Id,
|
||||||
"source": group.Source,
|
"source": group.Source,
|
||||||
"remote_id": group.GetRemoteId(),
|
"remote_id": group.GetRemoteId(),
|
||||||
@@ -58,7 +58,7 @@ func (group *Group) Auditable() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (group *Group) LogClone() any {
|
func (group *Group) LogClone() any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": group.Id,
|
"id": group.Id,
|
||||||
"name": group.GetName(),
|
"name": group.GetName(),
|
||||||
"display_name": group.DisplayName,
|
"display_name": group.DisplayName,
|
||||||
@@ -78,8 +78,8 @@ type GroupWithUserIds struct {
|
|||||||
UserIds []string `json:"user_ids"`
|
UserIds []string `json:"user_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (group *GroupWithUserIds) Auditable() map[string]interface{} {
|
func (group *GroupWithUserIds) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": group.Id,
|
"id": group.Id,
|
||||||
"source": group.Source,
|
"source": group.Source,
|
||||||
"remote_id": group.GetRemoteId(),
|
"remote_id": group.GetRemoteId(),
|
||||||
@@ -176,8 +176,8 @@ type GroupModifyMembers struct {
|
|||||||
UserIds []string `json:"user_ids"`
|
UserIds []string `json:"user_ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (group *GroupModifyMembers) Auditable() map[string]interface{} {
|
func (group *GroupModifyMembers) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"user_ids": group.UserIds,
|
"user_ids": group.UserIds,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,8 +42,8 @@ type GroupSyncable struct {
|
|||||||
TeamID string `db:"-" json:"-"`
|
TeamID string `db:"-" json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (syncable *GroupSyncable) Auditable() map[string]interface{} {
|
func (syncable *GroupSyncable) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"group_id": syncable.GroupId,
|
"group_id": syncable.GroupId,
|
||||||
"syncable_id": syncable.SyncableId,
|
"syncable_id": syncable.SyncableId,
|
||||||
"auto_add": syncable.AutoAdd,
|
"auto_add": syncable.AutoAdd,
|
||||||
@@ -153,8 +153,8 @@ type GroupSyncablePatch struct {
|
|||||||
SchemeAdmin *bool `json:"scheme_admin"`
|
SchemeAdmin *bool `json:"scheme_admin"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (syncable *GroupSyncablePatch) Auditable() map[string]interface{} {
|
func (syncable *GroupSyncablePatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"auto_add": syncable.AutoAdd,
|
"auto_add": syncable.AutoAdd,
|
||||||
"scheme_admin": syncable.SchemeAdmin,
|
"scheme_admin": syncable.SchemeAdmin,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ func TestGroupLogClone(t *testing.T) {
|
|||||||
l := g.LogClone()
|
l := g.LogClone()
|
||||||
require.NotNil(t, l)
|
require.NotNil(t, l)
|
||||||
|
|
||||||
m, ok := l.(map[string]interface{})
|
m, ok := l.(map[string]any)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
assert.Equal(t, "", m["remote_id"])
|
assert.Equal(t, "", m["remote_id"])
|
||||||
})
|
})
|
||||||
@@ -77,7 +77,7 @@ func TestGroupLogClone(t *testing.T) {
|
|||||||
AllowReference: true,
|
AllowReference: true,
|
||||||
}
|
}
|
||||||
l := g.LogClone()
|
l := g.LogClone()
|
||||||
m, ok := l.(map[string]interface{})
|
m, ok := l.(map[string]any)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
expected := map[string]any{
|
expected := map[string]any{
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ type GuestsInvite struct {
|
|||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *GuestsInvite) Auditable() map[string]interface{} {
|
func (i *GuestsInvite) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"emails": i.Emails,
|
"emails": i.Emails,
|
||||||
"channels": i.Channels,
|
"channels": i.Channels,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ type IncomingWebhook struct {
|
|||||||
ChannelLocked bool `json:"channel_locked"`
|
ChannelLocked bool `json:"channel_locked"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *IncomingWebhook) Auditable() map[string]interface{} {
|
func (o *IncomingWebhook) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ type AllowedIPRange struct {
|
|||||||
OwnerID string `json:"owner_id"`
|
OwnerID string `json:"owner_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (air *AllowedIPRanges) Auditable() map[string]interface{} {
|
func (air *AllowedIPRanges) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"AllowedIPRanges": air,
|
"AllowedIPRanges": air,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -91,8 +91,8 @@ type Job struct {
|
|||||||
Data StringMap `json:"data"`
|
Data StringMap `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) Auditable() map[string]interface{} {
|
func (j *Job) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": j.Id,
|
"id": j.Id,
|
||||||
"type": j.Type,
|
"type": j.Type,
|
||||||
"priority": j.Priority,
|
"priority": j.Priority,
|
||||||
@@ -129,7 +129,7 @@ func (j *Job) MarshalYAML() (any, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *Job) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (j *Job) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
out := struct {
|
out := struct {
|
||||||
Id string `yaml:"id"`
|
Id string `yaml:"id"`
|
||||||
Type string `yaml:"type"`
|
Type string `yaml:"type"`
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ type MemberInvite struct {
|
|||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *MemberInvite) Auditable() map[string]interface{} {
|
func (i *MemberInvite) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"emails": i.Emails,
|
"emails": i.Emails,
|
||||||
"channel_ids": i.ChannelIds,
|
"channel_ids": i.ChannelIds,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ type OAuthApp struct {
|
|||||||
MattermostAppID string `json:"mattermost_app_id"`
|
MattermostAppID string `json:"mattermost_app_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *OAuthApp) Auditable() map[string]interface{} {
|
func (a *OAuthApp) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": a.Id,
|
"id": a.Id,
|
||||||
"creator_id": a.CreatorId,
|
"creator_id": a.CreatorId,
|
||||||
"create_at": a.CreateAt,
|
"create_at": a.CreateAt,
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ type CompleteOnboardingRequest struct {
|
|||||||
InstallPlugins []string `json:"install_plugins"` // InstallPlugins is a list of plugins to be installed
|
InstallPlugins []string `json:"install_plugins"` // InstallPlugins is a list of plugins to be installed
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *CompleteOnboardingRequest) Auditable() map[string]interface{} {
|
func (r *CompleteOnboardingRequest) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"install_plugins": r.InstallPlugins,
|
"install_plugins": r.InstallPlugins,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,8 +38,8 @@ type OutgoingOAuthConnection struct {
|
|||||||
Audiences StringArray `json:"audiences"`
|
Audiences StringArray `json:"audiences"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (oa *OutgoingOAuthConnection) Auditable() map[string]interface{} {
|
func (oa *OutgoingOAuthConnection) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": oa.Id,
|
"id": oa.Id,
|
||||||
"creator_id": oa.CreatorId,
|
"creator_id": oa.CreatorId,
|
||||||
"create_at": oa.CreateAt,
|
"create_at": oa.CreateAt,
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ type OutgoingWebhook struct {
|
|||||||
IconURL string `json:"icon_url"`
|
IconURL string `json:"icon_url"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *OutgoingWebhook) Auditable() map[string]interface{} {
|
func (o *OutgoingWebhook) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func TestPacketMetadataValidate(t *testing.T) {
|
|||||||
ServerID: NewId(),
|
ServerID: NewId(),
|
||||||
LicenseID: NewId(),
|
LicenseID: NewId(),
|
||||||
CustomerID: NewId(),
|
CustomerID: NewId(),
|
||||||
Extras: map[string]interface{}{"key": "value"},
|
Extras: map[string]any{"key": "value"},
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
@@ -36,7 +36,7 @@ func TestPacketMetadataValidate(t *testing.T) {
|
|||||||
GeneratedAt: 1720097114454,
|
GeneratedAt: 1720097114454,
|
||||||
ServerVersion: "5.33.3",
|
ServerVersion: "5.33.3",
|
||||||
ServerID: NewId(),
|
ServerID: NewId(),
|
||||||
Extras: map[string]interface{}{"key": "value"},
|
Extras: map[string]any{"key": "value"},
|
||||||
},
|
},
|
||||||
expectErr: false,
|
expectErr: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -122,13 +122,13 @@ type Post struct {
|
|||||||
Metadata *PostMetadata `json:"metadata,omitempty"`
|
Metadata *PostMetadata `json:"metadata,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Post) Auditable() map[string]interface{} {
|
func (o *Post) Auditable() map[string]any {
|
||||||
var metaData map[string]any
|
var metaData map[string]any
|
||||||
if o.Metadata != nil {
|
if o.Metadata != nil {
|
||||||
metaData = o.Metadata.Auditable()
|
metaData = o.Metadata.Auditable()
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
@@ -211,8 +211,8 @@ type SearchParameter struct {
|
|||||||
IncludeDeletedChannels *bool `json:"include_deleted_channels"`
|
IncludeDeletedChannels *bool `json:"include_deleted_channels"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sp SearchParameter) Auditable() map[string]interface{} {
|
func (sp SearchParameter) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"terms": sp.Terms,
|
"terms": sp.Terms,
|
||||||
"is_or_search": sp.IsOrSearch,
|
"is_or_search": sp.IsOrSearch,
|
||||||
"time_zone_offset": sp.TimeZoneOffset,
|
"time_zone_offset": sp.TimeZoneOffset,
|
||||||
@@ -240,8 +240,8 @@ func (o *PostPatch) WithRewrittenImageURLs(f func(string) string) *PostPatch {
|
|||||||
return &pCopy
|
return &pCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *PostPatch) Auditable() map[string]interface{} {
|
func (o *PostPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"is_pinned": o.IsPinned,
|
"is_pinned": o.IsPinned,
|
||||||
"props": o.Props,
|
"props": o.Props,
|
||||||
"file_ids": o.FileIds,
|
"file_ids": o.FileIds,
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ func (o *PostSearchResults) ForPlugin() *PostSearchResults {
|
|||||||
return &plCopy
|
return &plCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *PostSearchResults) Auditable() map[string]interface{} {
|
func (o *PostSearchResults) Auditable() map[string]any {
|
||||||
var numResults int
|
var numResults int
|
||||||
var hasNext bool
|
var hasNext bool
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ type PropertyField struct {
|
|||||||
DeleteAt int64 `json:"delete_at"`
|
DeleteAt int64 `json:"delete_at"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pf *PropertyField) Auditable() map[string]interface{} {
|
func (pf *PropertyField) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": pf.ID,
|
"id": pf.ID,
|
||||||
"group_id": pf.GroupID,
|
"group_id": pf.GroupID,
|
||||||
"name": pf.Name,
|
"name": pf.Name,
|
||||||
@@ -106,8 +106,8 @@ type PropertyFieldPatch struct {
|
|||||||
TargetType *string `json:"target_type"`
|
TargetType *string `json:"target_type"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pfp *PropertyFieldPatch) Auditable() map[string]interface{} {
|
func (pfp *PropertyFieldPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"name": pfp.Name,
|
"name": pfp.Name,
|
||||||
"type": pfp.Type,
|
"type": pfp.Type,
|
||||||
"attrs": pfp.Attrs,
|
"attrs": pfp.Attrs,
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ type RemoteCluster struct {
|
|||||||
Options Bitmask `json:"options"` // bit-flag set of options
|
Options Bitmask `json:"options"` // bit-flag set of options
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rc *RemoteCluster) Auditable() map[string]interface{} {
|
func (rc *RemoteCluster) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"remote_id": rc.RemoteId,
|
"remote_id": rc.RemoteId,
|
||||||
"remote_team_id": rc.RemoteTeamId,
|
"remote_team_id": rc.RemoteTeamId,
|
||||||
"name": rc.Name,
|
"name": rc.Name,
|
||||||
@@ -148,8 +148,8 @@ type RemoteClusterPatch struct {
|
|||||||
DefaultTeamId *string `json:"default_team_id"`
|
DefaultTeamId *string `json:"default_team_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rcp *RemoteClusterPatch) Auditable() map[string]interface{} {
|
func (rcp *RemoteClusterPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"display_name": rcp.DisplayName,
|
"display_name": rcp.DisplayName,
|
||||||
"default_team_id": rcp.DefaultTeamId,
|
"default_team_id": rcp.DefaultTeamId,
|
||||||
}
|
}
|
||||||
@@ -300,8 +300,8 @@ type RemoteClusterFrame struct {
|
|||||||
Msg RemoteClusterMsg `json:"msg"`
|
Msg RemoteClusterMsg `json:"msg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *RemoteClusterFrame) Auditable() map[string]interface{} {
|
func (f *RemoteClusterFrame) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"remote_id": f.RemoteId,
|
"remote_id": f.RemoteId,
|
||||||
"msg_id": f.Msg.Id,
|
"msg_id": f.Msg.Id,
|
||||||
"topic": f.Msg.Topic,
|
"topic": f.Msg.Topic,
|
||||||
|
|||||||
@@ -425,8 +425,8 @@ type Role struct {
|
|||||||
BuiltIn bool `json:"built_in"`
|
BuiltIn bool `json:"built_in"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Role) Auditable() map[string]interface{} {
|
func (r *Role) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": r.Id,
|
"id": r.Id,
|
||||||
"name": r.Name,
|
"name": r.Name,
|
||||||
"display_name": r.DisplayName,
|
"display_name": r.DisplayName,
|
||||||
@@ -471,7 +471,7 @@ func (r *Role) MarshalYAML() (any, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *Role) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (r *Role) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
out := struct {
|
out := struct {
|
||||||
Id string `yaml:"id"`
|
Id string `yaml:"id"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
@@ -522,8 +522,8 @@ type RolePatch struct {
|
|||||||
Permissions *[]string `json:"permissions"`
|
Permissions *[]string `json:"permissions"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *RolePatch) Auditable() map[string]interface{} {
|
func (r *RolePatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"permissions": r.Permissions,
|
"permissions": r.Permissions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -128,13 +128,13 @@ func (s *ScheduledPost) ToPost() (*Post, error) {
|
|||||||
return post, nil
|
return post, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *ScheduledPost) Auditable() map[string]interface{} {
|
func (s *ScheduledPost) Auditable() map[string]any {
|
||||||
var metaData map[string]any
|
var metaData map[string]any
|
||||||
if s.Metadata != nil {
|
if s.Metadata != nil {
|
||||||
metaData = s.Metadata.Auditable()
|
metaData = s.Metadata.Auditable()
|
||||||
}
|
}
|
||||||
|
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": s.Id,
|
"id": s.Id,
|
||||||
"create_at": s.CreateAt,
|
"create_at": s.CreateAt,
|
||||||
"update_at": s.UpdateAt,
|
"update_at": s.UpdateAt,
|
||||||
|
|||||||
@@ -41,8 +41,8 @@ type Scheme struct {
|
|||||||
DefaultRunMemberRole string `json:"default_run_member_role"`
|
DefaultRunMemberRole string `json:"default_run_member_role"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scheme *Scheme) Auditable() map[string]interface{} {
|
func (scheme *Scheme) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": scheme.Id,
|
"id": scheme.Id,
|
||||||
"name": scheme.Name,
|
"name": scheme.Name,
|
||||||
"display_name": scheme.DisplayName,
|
"display_name": scheme.DisplayName,
|
||||||
@@ -112,7 +112,7 @@ func (scheme *Scheme) MarshalYAML() (any, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scheme *Scheme) UnmarshalYAML(unmarshal func(interface{}) error) error {
|
func (scheme *Scheme) UnmarshalYAML(unmarshal func(any) error) error {
|
||||||
out := struct {
|
out := struct {
|
||||||
Id string `yaml:"id"`
|
Id string `yaml:"id"`
|
||||||
Name string `yaml:"name"`
|
Name string `yaml:"name"`
|
||||||
@@ -181,8 +181,8 @@ type SchemePatch struct {
|
|||||||
Description *string `json:"description"`
|
Description *string `json:"description"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scheme *SchemePatch) Auditable() map[string]interface{} {
|
func (scheme *SchemePatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"name": scheme.Name,
|
"name": scheme.Name,
|
||||||
"display_name": scheme.DisplayName,
|
"display_name": scheme.DisplayName,
|
||||||
"description": scheme.Description,
|
"description": scheme.Description,
|
||||||
@@ -193,8 +193,8 @@ type SchemeIDPatch struct {
|
|||||||
SchemeID *string `json:"scheme_id"`
|
SchemeID *string `json:"scheme_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *SchemeIDPatch) Auditable() map[string]interface{} {
|
func (p *SchemeIDPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"scheme_id": p.SchemeID,
|
"scheme_id": p.SchemeID,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -243,8 +243,8 @@ type SchemeRoles struct {
|
|||||||
SchemeGuest bool `json:"scheme_guest"`
|
SchemeGuest bool `json:"scheme_guest"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SchemeRoles) Auditable() map[string]interface{} {
|
func (s *SchemeRoles) Auditable() map[string]any {
|
||||||
return map[string]interface{}{}
|
return map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (scheme *Scheme) IsValid() bool {
|
func (scheme *Scheme) IsValid() bool {
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ type Session struct {
|
|||||||
Local bool `json:"local" db:"-"`
|
Local bool `json:"local" db:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Session) Auditable() map[string]interface{} {
|
func (s *Session) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": s.Id,
|
"id": s.Id,
|
||||||
"create_at": s.CreateAt,
|
"create_at": s.CreateAt,
|
||||||
"expires_at": s.ExpiresAt,
|
"expires_at": s.ExpiresAt,
|
||||||
|
|||||||
@@ -13,8 +13,8 @@ type SwitchRequest struct {
|
|||||||
LdapLoginId string `json:"ldap_id"`
|
LdapLoginId string `json:"ldap_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *SwitchRequest) Auditable() map[string]interface{} {
|
func (o *SwitchRequest) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"current_service": o.CurrentService,
|
"current_service": o.CurrentService,
|
||||||
"new_service": o.NewService,
|
"new_service": o.NewService,
|
||||||
"email": o.Email,
|
"email": o.Email,
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ type Team struct {
|
|||||||
CloudLimitsArchived bool `json:"cloud_limits_archived"`
|
CloudLimitsArchived bool `json:"cloud_limits_archived"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *Team) Auditable() map[string]interface{} {
|
func (o *Team) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": o.Id,
|
"id": o.Id,
|
||||||
"create_at": o.CreateAt,
|
"create_at": o.CreateAt,
|
||||||
"update_at": o.UpdateAt,
|
"update_at": o.UpdateAt,
|
||||||
@@ -74,8 +74,8 @@ type TeamPatch struct {
|
|||||||
CloudLimitsArchived *bool `json:"cloud_limits_archived"`
|
CloudLimitsArchived *bool `json:"cloud_limits_archived"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *TeamPatch) Auditable() map[string]interface{} {
|
func (o *TeamPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"allow_open_invite": o.AllowOpenInvite,
|
"allow_open_invite": o.AllowOpenInvite,
|
||||||
"group_constrained": o.GroupConstrained,
|
"group_constrained": o.GroupConstrained,
|
||||||
"cloud_limits_archived": o.CloudLimitsArchived,
|
"cloud_limits_archived": o.CloudLimitsArchived,
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ type TeamMember struct {
|
|||||||
CreateAt int64 `json:"-"`
|
CreateAt int64 `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *TeamMember) Auditable() map[string]interface{} {
|
func (o *TeamMember) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"team_id": o.TeamId,
|
"team_id": o.TeamId,
|
||||||
"user_id": o.UserId,
|
"user_id": o.UserId,
|
||||||
"roles": o.Roles,
|
"roles": o.Roles,
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ type UploadSession struct {
|
|||||||
ReqFileId string `json:"req_file_id"`
|
ReqFileId string `json:"req_file_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (us *UploadSession) Auditable() map[string]interface{} {
|
func (us *UploadSession) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": us.Id,
|
"id": us.Id,
|
||||||
"type": us.Type,
|
"type": us.Type,
|
||||||
"user_id": us.UserId,
|
"user_id": us.UserId,
|
||||||
|
|||||||
@@ -112,8 +112,8 @@ type User struct {
|
|||||||
MfaUsedTimestamps StringArray `json:"mfa_used_timestamps,omitempty"`
|
MfaUsedTimestamps StringArray `json:"mfa_used_timestamps,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) Auditable() map[string]interface{} {
|
func (u *User) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": u.Id,
|
"id": u.Id,
|
||||||
"create_at": u.CreateAt,
|
"create_at": u.CreateAt,
|
||||||
"update_at": u.UpdateAt,
|
"update_at": u.UpdateAt,
|
||||||
@@ -145,7 +145,7 @@ func (u *User) Auditable() map[string]interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (u *User) LogClone() any {
|
func (u *User) LogClone() any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"id": u.Id,
|
"id": u.Id,
|
||||||
"create_at": u.CreateAt,
|
"create_at": u.CreateAt,
|
||||||
"update_at": u.UpdateAt,
|
"update_at": u.UpdateAt,
|
||||||
@@ -195,8 +195,8 @@ type UserPatch struct {
|
|||||||
RemoteId *string `json:"remote_id"`
|
RemoteId *string `json:"remote_id"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserPatch) Auditable() map[string]interface{} {
|
func (u *UserPatch) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"username": u.Username,
|
"username": u.Username,
|
||||||
"nickname": u.Nickname,
|
"nickname": u.Nickname,
|
||||||
"first_name": u.FirstName,
|
"first_name": u.FirstName,
|
||||||
@@ -217,8 +217,8 @@ type UserAuth struct {
|
|||||||
AuthService string `json:"auth_service,omitempty"`
|
AuthService string `json:"auth_service,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *UserAuth) Auditable() map[string]interface{} {
|
func (u *UserAuth) Auditable() map[string]any {
|
||||||
return map[string]interface{}{
|
return map[string]any{
|
||||||
"auth_service": u.AuthService,
|
"auth_service": u.AuthService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ func TestUserLogClone(t *testing.T) {
|
|||||||
l := u.LogClone()
|
l := u.LogClone()
|
||||||
require.NotNil(t, l)
|
require.NotNil(t, l)
|
||||||
|
|
||||||
m, ok := l.(map[string]interface{})
|
m, ok := l.(map[string]any)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
assert.Equal(t, "", m["remote_id"])
|
assert.Equal(t, "", m["remote_id"])
|
||||||
})
|
})
|
||||||
@@ -135,7 +135,7 @@ func TestUserLogClone(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
l := u.LogClone()
|
l := u.LogClone()
|
||||||
m, ok := l.(map[string]interface{})
|
m, ok := l.(map[string]any)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
expected := map[string]any{
|
expected := map[string]any{
|
||||||
|
|||||||
@@ -4,5 +4,4 @@
|
|||||||
package missing
|
package missing
|
||||||
|
|
||||||
// SomeType is a fake interface for testing the plugin comment checker.
|
// SomeType is a fake interface for testing the plugin comment checker.
|
||||||
type SomeType interface {
|
type SomeType any
|
||||||
}
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ const (
|
|||||||
// MutexPluginAPI is the plugin API interface required to manage mutexes.
|
// MutexPluginAPI is the plugin API interface required to manage mutexes.
|
||||||
type MutexPluginAPI interface {
|
type MutexPluginAPI interface {
|
||||||
KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
KVSetWithOptions(key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||||
LogError(msg string, keyValuePairs ...interface{})
|
LogError(msg string, keyValuePairs ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mutex is similar to sync.Mutex, except usable by multiple plugin instances across a cluster.
|
// Mutex is similar to sync.Mutex, except usable by multiple plugin instances across a cluster.
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ type ConfigurationService struct {
|
|||||||
// struct to which the configuration JSON can be unmarshalled.
|
// struct to which the configuration JSON can be unmarshalled.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.2
|
// Minimum server version: 5.2
|
||||||
func (c *ConfigurationService) LoadPluginConfiguration(dest interface{}) error {
|
func (c *ConfigurationService) LoadPluginConfiguration(dest any) error {
|
||||||
// TODO: Isn't this method redundant given GetPluginConfig() and even GetConfig()?
|
// TODO: Isn't this method redundant given GetPluginConfig() and even GetConfig()?
|
||||||
return c.api.LoadPluginConfiguration(dest)
|
return c.api.LoadPluginConfiguration(dest)
|
||||||
}
|
}
|
||||||
@@ -43,13 +43,13 @@ func (c *ConfigurationService) SaveConfig(cfg *model.Config) error {
|
|||||||
// GetPluginConfig fetches the currently persisted config of plugin
|
// GetPluginConfig fetches the currently persisted config of plugin
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.6
|
// Minimum server version: 5.6
|
||||||
func (c *ConfigurationService) GetPluginConfig() map[string]interface{} {
|
func (c *ConfigurationService) GetPluginConfig() map[string]any {
|
||||||
return c.api.GetPluginConfig()
|
return c.api.GetPluginConfig()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SavePluginConfig sets the given config for plugin and persists the changes
|
// SavePluginConfig sets the given config for plugin and persists the changes
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.6
|
// Minimum server version: 5.6
|
||||||
func (c *ConfigurationService) SavePluginConfig(cfg map[string]interface{}) error {
|
func (c *ConfigurationService) SavePluginConfig(cfg map[string]any) error {
|
||||||
return normalizeAppErr(c.api.SavePluginConfig(cfg))
|
return normalizeAppErr(c.api.SavePluginConfig(cfg))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ func NewFromAPI(api common.LogAPI, dmer poster.DMer, logLevel logger.LogLevel, i
|
|||||||
return New(logger.New(api), dmer, logLevel, includeContext, userIDs...)
|
return New(logger.New(api), dmer, logLevel, includeContext, userIDs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *adminCCLogger) Debugf(format string, args ...interface{}) {
|
func (l *adminCCLogger) Debugf(format string, args ...any) {
|
||||||
l.Logger.Debugf(format, args...)
|
l.Logger.Debugf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 4 {
|
if logger.Level(l.logLevel) >= 4 {
|
||||||
@@ -54,7 +54,7 @@ func (l *adminCCLogger) Debugf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *adminCCLogger) Errorf(format string, args ...interface{}) {
|
func (l *adminCCLogger) Errorf(format string, args ...any) {
|
||||||
l.Logger.Errorf(format, args...)
|
l.Logger.Errorf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 1 {
|
if logger.Level(l.logLevel) >= 1 {
|
||||||
@@ -62,7 +62,7 @@ func (l *adminCCLogger) Errorf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *adminCCLogger) Infof(format string, args ...interface{}) {
|
func (l *adminCCLogger) Infof(format string, args ...any) {
|
||||||
l.Logger.Infof(format, args...)
|
l.Logger.Infof(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 3 {
|
if logger.Level(l.logLevel) >= 3 {
|
||||||
@@ -70,7 +70,7 @@ func (l *adminCCLogger) Infof(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *adminCCLogger) Warnf(format string, args ...interface{}) {
|
func (l *adminCCLogger) Warnf(format string, args ...any) {
|
||||||
l.Logger.Warnf(format, args...)
|
l.Logger.Warnf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 2 {
|
if logger.Level(l.logLevel) >= 2 {
|
||||||
@@ -86,7 +86,7 @@ func (l *adminCCLogger) logToAdmins(level, message string) {
|
|||||||
_ = l.dmAdmins("(log " + level + ") " + message)
|
_ = l.dmAdmins("(log " + level + ") " + message)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *adminCCLogger) dmAdmins(format string, args ...interface{}) error {
|
func (l *adminCCLogger) dmAdmins(format string, args ...any) error {
|
||||||
for _, id := range l.userIDs {
|
for _, id := range l.userIDs {
|
||||||
_, err := l.dmer.DM(id, format, args)
|
_, err := l.dmer.DM(id, format, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func New(api common.LogAPI) Logger {
|
|||||||
func (l *defaultLogger) With(logContext LogContext) Logger {
|
func (l *defaultLogger) With(logContext LogContext) Logger {
|
||||||
newLogger := *l
|
newLogger := *l
|
||||||
if len(newLogger.logContext) == 0 {
|
if len(newLogger.logContext) == 0 {
|
||||||
newLogger.logContext = map[string]interface{}{}
|
newLogger.logContext = map[string]any{}
|
||||||
}
|
}
|
||||||
for k, v := range logContext {
|
for k, v := range logContext {
|
||||||
newLogger.logContext[k] = v
|
newLogger.logContext[k] = v
|
||||||
@@ -41,7 +41,7 @@ func (l *defaultLogger) With(logContext LogContext) Logger {
|
|||||||
func (l *defaultLogger) WithError(err error) Logger {
|
func (l *defaultLogger) WithError(err error) Logger {
|
||||||
newLogger := *l
|
newLogger := *l
|
||||||
if len(newLogger.logContext) == 0 {
|
if len(newLogger.logContext) == 0 {
|
||||||
newLogger.logContext = map[string]interface{}{}
|
newLogger.logContext = map[string]any{}
|
||||||
}
|
}
|
||||||
newLogger.logContext[ErrorKey] = err.Error()
|
newLogger.logContext[ErrorKey] = err.Error()
|
||||||
return &newLogger
|
return &newLogger
|
||||||
@@ -57,25 +57,25 @@ func (l *defaultLogger) Timed() Logger {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultLogger) Debugf(format string, args ...interface{}) {
|
func (l *defaultLogger) Debugf(format string, args ...any) {
|
||||||
measure(l.logContext)
|
measure(l.logContext)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
l.logAPI.LogDebug(message, toKeyValuePairs(l.logContext)...)
|
l.logAPI.LogDebug(message, toKeyValuePairs(l.logContext)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultLogger) Errorf(format string, args ...interface{}) {
|
func (l *defaultLogger) Errorf(format string, args ...any) {
|
||||||
measure(l.logContext)
|
measure(l.logContext)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
l.logAPI.LogError(message, toKeyValuePairs(l.logContext)...)
|
l.logAPI.LogError(message, toKeyValuePairs(l.logContext)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultLogger) Infof(format string, args ...interface{}) {
|
func (l *defaultLogger) Infof(format string, args ...any) {
|
||||||
measure(l.logContext)
|
measure(l.logContext)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
l.logAPI.LogInfo(message, toKeyValuePairs(l.logContext)...)
|
l.logAPI.LogInfo(message, toKeyValuePairs(l.logContext)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *defaultLogger) Warnf(format string, args ...interface{}) {
|
func (l *defaultLogger) Warnf(format string, args ...any) {
|
||||||
measure(l.logContext)
|
measure(l.logContext)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
l.logAPI.LogWarn(message, toKeyValuePairs(l.logContext)...)
|
l.logAPI.LogWarn(message, toKeyValuePairs(l.logContext)...)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// LogContext defines the context for the logs.
|
// LogContext defines the context for the logs.
|
||||||
type LogContext map[string]interface{}
|
type LogContext map[string]any
|
||||||
|
|
||||||
// Logger defines an object able to log messages.
|
// Logger defines an object able to log messages.
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
@@ -37,13 +37,13 @@ type Logger interface {
|
|||||||
// Timed add a timed log context.
|
// Timed add a timed log context.
|
||||||
Timed() Logger
|
Timed() Logger
|
||||||
// Debugf logs a formatted string as a debug message.
|
// Debugf logs a formatted string as a debug message.
|
||||||
Debugf(format string, args ...interface{})
|
Debugf(format string, args ...any)
|
||||||
// Errorf logs a formatted string as an error message.
|
// Errorf logs a formatted string as an error message.
|
||||||
Errorf(format string, args ...interface{})
|
Errorf(format string, args ...any)
|
||||||
// Infof logs a formatted string as an info message.
|
// Infof logs a formatted string as an info message.
|
||||||
Infof(format string, args ...interface{})
|
Infof(format string, args ...any)
|
||||||
// Warnf logs a formatted string as an warning message.
|
// Warnf logs a formatted string as an warning message.
|
||||||
Warnf(format string, args ...interface{})
|
Warnf(format string, args ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
func measure(lc LogContext) {
|
func measure(lc LogContext) {
|
||||||
@@ -70,7 +70,7 @@ func Level(l LogLevel) int {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func toKeyValuePairs(in map[string]interface{}) (out []interface{}) {
|
func toKeyValuePairs(in map[string]any) (out []any) {
|
||||||
for k, v := range in {
|
for k, v := range in {
|
||||||
out = append(out, k, v)
|
out = append(out, k, v)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ func NewNilLogger() Logger {
|
|||||||
return &nilLogger{}
|
return &nilLogger{}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *nilLogger) With(LogContext) Logger { return l }
|
func (l *nilLogger) With(LogContext) Logger { return l }
|
||||||
func (l *nilLogger) WithError(error) Logger { return l }
|
func (l *nilLogger) WithError(error) Logger { return l }
|
||||||
func (l *nilLogger) Context() LogContext { return nil }
|
func (l *nilLogger) Context() LogContext { return nil }
|
||||||
func (l *nilLogger) Timed() Logger { return l }
|
func (l *nilLogger) Timed() Logger { return l }
|
||||||
func (l *nilLogger) Debugf(string, ...interface{}) {}
|
func (l *nilLogger) Debugf(string, ...any) {}
|
||||||
func (l *nilLogger) Errorf(string, ...interface{}) {}
|
func (l *nilLogger) Errorf(string, ...any) {}
|
||||||
func (l *nilLogger) Infof(string, ...interface{}) {}
|
func (l *nilLogger) Infof(string, ...any) {}
|
||||||
func (l *nilLogger) Warnf(string, ...interface{}) {}
|
func (l *nilLogger) Warnf(string, ...any) {}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ func NewFromAPI(api common.LogAPI, logLevel logger.LogLevel, tracker telemetry.T
|
|||||||
return New(logger.New(api), logLevel, tracker)
|
return New(logger.New(api), logLevel, tracker)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *telemetryLogger) Debugf(format string, args ...interface{}) {
|
func (l *telemetryLogger) Debugf(format string, args ...any) {
|
||||||
l.Logger.Debugf(format, args...)
|
l.Logger.Debugf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 4 {
|
if logger.Level(l.logLevel) >= 4 {
|
||||||
@@ -45,7 +45,7 @@ func (l *telemetryLogger) Debugf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *telemetryLogger) Errorf(format string, args ...interface{}) {
|
func (l *telemetryLogger) Errorf(format string, args ...any) {
|
||||||
l.Logger.Errorf(format, args...)
|
l.Logger.Errorf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 1 {
|
if logger.Level(l.logLevel) >= 1 {
|
||||||
@@ -53,7 +53,7 @@ func (l *telemetryLogger) Errorf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *telemetryLogger) Infof(format string, args ...interface{}) {
|
func (l *telemetryLogger) Infof(format string, args ...any) {
|
||||||
l.Logger.Infof(format, args...)
|
l.Logger.Infof(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 3 {
|
if logger.Level(l.logLevel) >= 3 {
|
||||||
@@ -61,7 +61,7 @@ func (l *telemetryLogger) Infof(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *telemetryLogger) Warnf(format string, args ...interface{}) {
|
func (l *telemetryLogger) Warnf(format string, args ...any) {
|
||||||
l.Logger.Warnf(format, args...)
|
l.Logger.Warnf(format, args...)
|
||||||
message := fmt.Sprintf(format, args...)
|
message := fmt.Sprintf(format, args...)
|
||||||
if logger.Level(l.logLevel) >= 2 {
|
if logger.Level(l.logLevel) >= 2 {
|
||||||
@@ -70,7 +70,7 @@ func (l *telemetryLogger) Warnf(format string, args ...interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (l *telemetryLogger) logToTelemetry(level, message string) {
|
func (l *telemetryLogger) logToTelemetry(level, message string) {
|
||||||
properties := map[string]interface{}{}
|
properties := map[string]any{}
|
||||||
properties["message"] = message
|
properties["message"] = message
|
||||||
for k, v := range l.Context() {
|
for k, v := range l.Context() {
|
||||||
properties["context_"+k] = fmt.Sprintf("%v", v)
|
properties["context_"+k] = fmt.Sprintf("%v", v)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ func NewTestLogger() Logger {
|
|||||||
func (l *testLogger) With(logContext LogContext) Logger {
|
func (l *testLogger) With(logContext LogContext) Logger {
|
||||||
newl := *l
|
newl := *l
|
||||||
if len(newl.logContext) == 0 {
|
if len(newl.logContext) == 0 {
|
||||||
newl.logContext = map[string]interface{}{}
|
newl.logContext = map[string]any{}
|
||||||
}
|
}
|
||||||
for k, v := range logContext {
|
for k, v := range logContext {
|
||||||
newl.logContext[k] = v
|
newl.logContext[k] = v
|
||||||
@@ -30,7 +30,7 @@ func (l *testLogger) With(logContext LogContext) Logger {
|
|||||||
func (l *testLogger) WithError(err error) Logger {
|
func (l *testLogger) WithError(err error) Logger {
|
||||||
newl := *l
|
newl := *l
|
||||||
if len(newl.logContext) == 0 {
|
if len(newl.logContext) == 0 {
|
||||||
newl.logContext = map[string]interface{}{}
|
newl.logContext = map[string]any{}
|
||||||
}
|
}
|
||||||
newl.logContext[ErrorKey] = err.Error()
|
newl.logContext[ErrorKey] = err.Error()
|
||||||
return &newl
|
return &newl
|
||||||
@@ -46,7 +46,7 @@ func (l *testLogger) Timed() Logger {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *testLogger) logf(prefix, format string, args ...interface{}) {
|
func (l *testLogger) logf(prefix, format string, args ...any) {
|
||||||
out := fmt.Sprintf(prefix+": "+format, args...)
|
out := fmt.Sprintf(prefix+": "+format, args...)
|
||||||
if len(l.logContext) > 0 {
|
if len(l.logContext) > 0 {
|
||||||
measure(l.logContext)
|
measure(l.logContext)
|
||||||
@@ -55,7 +55,7 @@ func (l *testLogger) logf(prefix, format string, args ...interface{}) {
|
|||||||
l.TB.Log(out)
|
l.TB.Log(out)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *testLogger) Debugf(format string, args ...interface{}) { l.logf("DEBUG", format, args...) }
|
func (l *testLogger) Debugf(format string, args ...any) { l.logf("DEBUG", format, args...) }
|
||||||
func (l *testLogger) Errorf(format string, args ...interface{}) { l.logf("ERROR", format, args...) }
|
func (l *testLogger) Errorf(format string, args ...any) { l.logf("ERROR", format, args...) }
|
||||||
func (l *testLogger) Infof(format string, args ...interface{}) { l.logf("INFO", format, args...) }
|
func (l *testLogger) Infof(format string, args ...any) { l.logf("INFO", format, args...) }
|
||||||
func (l *testLogger) Warnf(format string, args ...interface{}) { l.logf("WARN", format, args...) }
|
func (l *testLogger) Warnf(format string, args ...any) { l.logf("WARN", format, args...) }
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ func NewPoster(postAPI PostAPI, id string) Poster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DM posts a simple Direct Message to the specified user
|
// DM posts a simple Direct Message to the specified user
|
||||||
func (p *defaultPoster) DM(mattermostUserID, format string, args ...interface{}) (string, error) {
|
func (p *defaultPoster) DM(mattermostUserID, format string, args ...any) (string, error) {
|
||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
Message: fmt.Sprintf(format, args...),
|
Message: fmt.Sprintf(format, args...),
|
||||||
}
|
}
|
||||||
@@ -44,7 +44,7 @@ func (p *defaultPoster) DMWithAttachments(mattermostUserID string, attachments .
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ephemeral sends an ephemeral message to a user
|
// Ephemeral sends an ephemeral message to a user
|
||||||
func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...interface{}) {
|
func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...any) {
|
||||||
post := &model.Post{
|
post := &model.Post{
|
||||||
UserId: p.id,
|
UserId: p.id,
|
||||||
ChannelId: channelID,
|
ChannelId: channelID,
|
||||||
@@ -53,7 +53,7 @@ func (p *defaultPoster) Ephemeral(userID, channelID, format string, args ...inte
|
|||||||
p.postAPI.SendEphemeralPost(userID, post)
|
p.postAPI.SendEphemeralPost(userID, post)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *defaultPoster) UpdatePostByID(postID, format string, args ...interface{}) error {
|
func (p *defaultPoster) UpdatePostByID(postID, format string, args ...any) error {
|
||||||
post, err := p.postAPI.GetPost(postID)
|
post, err := p.postAPI.GetPost(postID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ func TestInterface(t *testing.T) {
|
|||||||
|
|
||||||
func TestDM(t *testing.T) {
|
func TestDM(t *testing.T) {
|
||||||
format := "test format, string: %s int: %d value: %v"
|
format := "test format, string: %s int: %d value: %v"
|
||||||
args := []interface{}{"some string", 5, 8.423}
|
args := []any{"some string", 5, 8.423}
|
||||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||||
|
|
||||||
expectedPostID := "expected-post-id"
|
expectedPostID := "expected-post-id"
|
||||||
@@ -153,7 +153,7 @@ func TestDMWithAttachments(t *testing.T) {
|
|||||||
|
|
||||||
func TestEphemeral(t *testing.T) {
|
func TestEphemeral(t *testing.T) {
|
||||||
format := "test format, string: %s int: %d value: %v"
|
format := "test format, string: %s int: %d value: %v"
|
||||||
args := []interface{}{"some string", 5, 8.423}
|
args := []any{"some string", 5, 8.423}
|
||||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||||
|
|
||||||
channelID := "some-channel"
|
channelID := "some-channel"
|
||||||
@@ -194,7 +194,7 @@ func TestEphemeral(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdatePostByID(t *testing.T) {
|
func TestUpdatePostByID(t *testing.T) {
|
||||||
format := "test format, string: %s int: %d value: %v"
|
format := "test format, string: %s int: %d value: %v"
|
||||||
args := []interface{}{"some string", 5, 8.423}
|
args := []any{"some string", 5, 8.423}
|
||||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||||
|
|
||||||
postID := "some-post-id"
|
postID := "some-post-id"
|
||||||
@@ -364,7 +364,7 @@ func TestUpdatePost(t *testing.T) {
|
|||||||
|
|
||||||
func TestUpdatePosterID(t *testing.T) {
|
func TestUpdatePosterID(t *testing.T) {
|
||||||
format := "test format, string: %s int: %d value: %v"
|
format := "test format, string: %s int: %d value: %v"
|
||||||
args := []interface{}{"some string", 5, 8.423}
|
args := []any{"some string", 5, 8.423}
|
||||||
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
expectedMessage := "test format, string: some string int: 5 value: 8.423"
|
||||||
|
|
||||||
expectedPostID := "expected-post-id"
|
expectedPostID := "expected-post-id"
|
||||||
|
|||||||
@@ -16,10 +16,10 @@ type Poster interface {
|
|||||||
DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error)
|
DMWithAttachments(mattermostUserID string, attachments ...*model.SlackAttachment) (string, error)
|
||||||
|
|
||||||
// Ephemeral sends an ephemeral message to a user
|
// Ephemeral sends an ephemeral message to a user
|
||||||
Ephemeral(mattermostUserID, channelID, format string, args ...interface{})
|
Ephemeral(mattermostUserID, channelID, format string, args ...any)
|
||||||
|
|
||||||
// UpdatePostByID updates the post with postID with the formatted message
|
// UpdatePostByID updates the post with postID with the formatted message
|
||||||
UpdatePostByID(postID, format string, args ...interface{}) error
|
UpdatePostByID(postID, format string, args ...any) error
|
||||||
|
|
||||||
// DeletePost deletes a single post
|
// DeletePost deletes a single post
|
||||||
DeletePost(postID string) error
|
DeletePost(postID string) error
|
||||||
@@ -34,5 +34,5 @@ type Poster interface {
|
|||||||
// DMer defines an entity that can send Direct Messages
|
// DMer defines an entity that can send Direct Messages
|
||||||
type DMer interface {
|
type DMer interface {
|
||||||
// DM posts a simple Direct Message to the specified user
|
// DM posts a simple Direct Message to the specified user
|
||||||
DM(mattermostUserID, format string, args ...interface{}) (string, error)
|
DM(mattermostUserID, format string, args ...any) (string, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
var ErrNotFound = errors.New("not found")
|
var ErrNotFound = errors.New("not found")
|
||||||
|
|
||||||
type KVStore interface {
|
type KVStore interface {
|
||||||
Set(key string, value interface{}, options ...pluginapi.KVSetOption) (bool, error)
|
Set(key string, value any, options ...pluginapi.KVSetOption) (bool, error)
|
||||||
Get(key string, o interface{}) error
|
Get(key string, o any) error
|
||||||
Delete(key string) error
|
Delete(key string) error
|
||||||
DeleteAll() error
|
DeleteAll() error
|
||||||
ListKeys(page, count int, options ...pluginapi.ListKeysOption) ([]string, error)
|
ListKeys(page, count int, options ...pluginapi.ListKeysOption) ([]string, error)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
type LogAPI interface {
|
type LogAPI interface {
|
||||||
LogError(message string, keyValuePairs ...interface{})
|
LogError(message string, keyValuePairs ...any)
|
||||||
LogWarn(message string, keyValuePairs ...interface{})
|
LogWarn(message string, keyValuePairs ...any)
|
||||||
LogInfo(message string, keyValuePairs ...interface{})
|
LogInfo(message string, keyValuePairs ...any)
|
||||||
LogDebug(message string, keyValuePairs ...interface{})
|
LogDebug(message string, keyValuePairs ...any)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
func JSON(ref interface{}) string {
|
func JSON(ref any) string {
|
||||||
bb, _ := json.MarshalIndent(ref, "", " ")
|
bb, _ := json.MarshalIndent(ref, "", " ")
|
||||||
return string(bb)
|
return string(bb)
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,6 @@ func CodeBlock(in string) string {
|
|||||||
return fmt.Sprintf("\n```\n%s\n```\n", in)
|
return fmt.Sprintf("\n```\n%s\n```\n", in)
|
||||||
}
|
}
|
||||||
|
|
||||||
func JSONBlock(ref interface{}) string {
|
func JSONBlock(ref any) string {
|
||||||
return fmt.Sprintf("\n```json\n%s\n```\n", JSON(ref))
|
return fmt.Sprintf("\n```json\n%s\n```\n", JSON(ref))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,8 +259,8 @@ func Goto(toName Name) func(*Flow) (Name, State, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DialogGoto(toName Name) func(*Flow, map[string]interface{}) (Name, State, map[string]string, error) {
|
func DialogGoto(toName Name) func(*Flow, map[string]any) (Name, State, map[string]string, error) {
|
||||||
return func(_ *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error) {
|
return func(_ *Flow, submitted map[string]any) (Name, State, map[string]string, error) {
|
||||||
stateUpdate := State{}
|
stateUpdate := State{}
|
||||||
for k, v := range submitted {
|
for k, v := range submitted {
|
||||||
stateUpdate[k] = fmt.Sprintf("%v", v)
|
stateUpdate[k] = fmt.Sprintf("%v", v)
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ func (f *Flow) handleButton(fromName Name, selectedButton int, triggerID string)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flow) handleDialog(
|
func (f *Flow) handleDialog(
|
||||||
fromName Name, selectedButton int, submission map[string]interface{},
|
fromName Name, selectedButton int, submission map[string]any,
|
||||||
) (
|
) (
|
||||||
*model.Post, map[string]string, error,
|
*model.Post, map[string]string, error,
|
||||||
) {
|
) {
|
||||||
@@ -105,7 +105,7 @@ func (f *Flow) handleDialog(
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *Flow) handle(
|
func (f *Flow) handle(
|
||||||
fromName Name, selectedButton int, submission map[string]interface{}, triggerID string, asButton bool,
|
fromName Name, selectedButton int, submission map[string]any, triggerID string, asButton bool,
|
||||||
) (
|
) (
|
||||||
*model.Post, map[string]string, error,
|
*model.Post, map[string]string, error,
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import (
|
|||||||
var errStateNotFound = errors.New("flow state not found")
|
var errStateNotFound = errors.New("flow state not found")
|
||||||
|
|
||||||
// State is the "app"'s state
|
// State is the "app"'s state
|
||||||
type State map[string]interface{}
|
type State map[string]any
|
||||||
|
|
||||||
func (s State) MergeWith(update State) State {
|
func (s State) MergeWith(update State) State {
|
||||||
n := State{}
|
n := State{}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ type Button struct {
|
|||||||
// Function that is called when the dialog box is submitted. It can return a
|
// Function that is called when the dialog box is submitted. It can return a
|
||||||
// general error, or field-specific errors. On success it returns the name
|
// general error, or field-specific errors. On success it returns the name
|
||||||
// of the next step, and the state updates to apply.
|
// of the next step, and the state updates to apply.
|
||||||
OnDialogSubmit func(f *Flow, submitted map[string]interface{}) (Name, State, map[string]string, error)
|
OnDialogSubmit func(f *Flow, submitted map[string]any) (Name, State, map[string]string, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStep(name Name) Step {
|
func NewStep(name Name) Step {
|
||||||
@@ -229,7 +229,7 @@ func renderButton(b Button, stepName Name, i int, state State) *model.PostAction
|
|||||||
Disabled: b.Disabled,
|
Disabled: b.Disabled,
|
||||||
Style: string(b.Color),
|
Style: string(b.Color),
|
||||||
Integration: &model.PostActionIntegration{
|
Integration: &model.PostActionIntegration{
|
||||||
Context: map[string]interface{}{
|
Context: map[string]any{
|
||||||
contextStepKey: string(stepName),
|
contextStepKey: string(stepName),
|
||||||
contextButtonKey: strconv.Itoa(i),
|
contextButtonKey: strconv.Itoa(i),
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Panel interface {
|
type Panel interface {
|
||||||
Set(userID, settingID string, value interface{}) error
|
Set(userID, settingID string, value any) error
|
||||||
Print(userID string)
|
Print(userID string)
|
||||||
ToPost(userID string) (*model.Post, error)
|
ToPost(userID string) (*model.Post, error)
|
||||||
Clear(userID string) error
|
Clear(userID string) error
|
||||||
@@ -57,7 +57,7 @@ func NewSettingsPanel(
|
|||||||
return panel
|
return panel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *panel) Set(userID, settingID string, value interface{}) error {
|
func (p *panel) Set(userID, settingID string, value any) error {
|
||||||
s, ok := p.settings[settingID]
|
s, ok := p.settings[settingID]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("cannot find setting " + settingID)
|
return errors.New("cannot find setting " + settingID)
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ func (s *baseSetting) GetDependency() string {
|
|||||||
return s.dependsOn
|
return s.dependsOn
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *baseSetting) IsDisabled(foreignValue interface{}) bool {
|
func (s *baseSetting) IsDisabled(foreignValue any) bool {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func NewBoolSetting(id, title, description, dependsOn string, store SettingStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *boolSetting) Set(userID string, value interface{}) error {
|
func (s *boolSetting) Set(userID string, value any) error {
|
||||||
boolValue := false
|
boolValue := false
|
||||||
if value == TrueString {
|
if value == TrueString {
|
||||||
boolValue = true
|
boolValue = true
|
||||||
@@ -39,7 +39,7 @@ func (s *boolSetting) Set(userID string, value interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *boolSetting) Get(userID string) (interface{}, error) {
|
func (s *boolSetting) Get(userID string) (any, error) {
|
||||||
value, err := s.store.GetSetting(userID, s.id)
|
value, err := s.store.GetSetting(userID, s.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -79,7 +79,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
|||||||
Name: "Yes",
|
Name: "Yes",
|
||||||
Integration: &model.PostActionIntegration{
|
Integration: &model.PostActionIntegration{
|
||||||
URL: settingHandler,
|
URL: settingHandler,
|
||||||
Context: map[string]interface{}{
|
Context: map[string]any{
|
||||||
ContextIDKey: s.id,
|
ContextIDKey: s.id,
|
||||||
ContextButtonValueKey: TrueString,
|
ContextButtonValueKey: TrueString,
|
||||||
},
|
},
|
||||||
@@ -91,7 +91,7 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
|||||||
Name: "No",
|
Name: "No",
|
||||||
Integration: &model.PostActionIntegration{
|
Integration: &model.PostActionIntegration{
|
||||||
URL: settingHandler,
|
URL: settingHandler,
|
||||||
Context: map[string]interface{}{
|
Context: map[string]any{
|
||||||
ContextIDKey: s.id,
|
ContextIDKey: s.id,
|
||||||
ContextButtonValueKey: FalseString,
|
ContextButtonValueKey: FalseString,
|
||||||
},
|
},
|
||||||
@@ -111,6 +111,6 @@ func (s *boolSetting) GetSlackAttachments(userID, settingHandler string, disable
|
|||||||
return &sa, nil
|
return &sa, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *boolSetting) IsDisabled(foreignValue interface{}) bool {
|
func (s *boolSetting) IsDisabled(foreignValue any) bool {
|
||||||
return foreignValue == FalseString
|
return foreignValue == FalseString
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,10 @@ func (s *emptySetting) GetSlackAttachments(userID, settingHandler string, disabl
|
|||||||
return &sa, nil
|
return &sa, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *emptySetting) Get(userID string) (interface{}, error) {
|
func (s *emptySetting) Get(userID string) (any, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *emptySetting) Set(userID string, value interface{}) error {
|
func (s *emptySetting) Set(userID string, value any) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func NewOptionSetting(id, title, description, dependsOn string, options []string
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *optionSetting) Set(userID string, value interface{}) error {
|
func (s *optionSetting) Set(userID string, value any) error {
|
||||||
err := s.store.SetSetting(userID, s.id, value)
|
err := s.store.SetSetting(userID, s.id, value)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -36,7 +36,7 @@ func (s *optionSetting) Set(userID string, value interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *optionSetting) Get(userID string) (interface{}, error) {
|
func (s *optionSetting) Get(userID string) (any, error) {
|
||||||
value, err := s.store.GetSetting(userID, s.id)
|
value, err := s.store.GetSetting(userID, s.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -66,7 +66,7 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab
|
|||||||
Name: "Select an option:",
|
Name: "Select an option:",
|
||||||
Integration: &model.PostActionIntegration{
|
Integration: &model.PostActionIntegration{
|
||||||
URL: settingHandler + "?" + s.id + "=true",
|
URL: settingHandler + "?" + s.id + "=true",
|
||||||
Context: map[string]interface{}{
|
Context: map[string]any{
|
||||||
ContextIDKey: s.id,
|
ContextIDKey: s.id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -86,6 +86,6 @@ func (s *optionSetting) GetSlackAttachments(userID, settingHandler string, disab
|
|||||||
return &sa, nil
|
return &sa, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *optionSetting) IsDisabled(foreignValue interface{}) bool {
|
func (s *optionSetting) IsDisabled(foreignValue any) bool {
|
||||||
return foreignValue == FalseString
|
return foreignValue == FalseString
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ func NewReadOnlySetting(id, title, description, dependsOn string, store SettingS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *readOnlySetting) Get(userID string) (interface{}, error) {
|
func (s *readOnlySetting) Get(userID string) (any, error) {
|
||||||
value, err := s.store.GetSetting(userID, s.id)
|
value, err := s.store.GetSetting(userID, s.id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -38,7 +38,7 @@ func (s *readOnlySetting) Get(userID string) (interface{}, error) {
|
|||||||
return stringValue, nil
|
return stringValue, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *readOnlySetting) Set(userID string, value interface{}) error {
|
func (s *readOnlySetting) Set(userID string, value any) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,6 +64,6 @@ func (s *readOnlySetting) GetSlackAttachments(userID, settingHandler string, dis
|
|||||||
return &sa, nil
|
return &sa, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *readOnlySetting) IsDisabled(foreignValue interface{}) bool {
|
func (s *readOnlySetting) IsDisabled(foreignValue any) bool {
|
||||||
return foreignValue == FalseString
|
return foreignValue == FalseString
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,11 +22,11 @@ const (
|
|||||||
|
|
||||||
// Setting defines the behavior of each element a the panel
|
// Setting defines the behavior of each element a the panel
|
||||||
type Setting interface {
|
type Setting interface {
|
||||||
Set(userID string, value interface{}) error
|
Set(userID string, value any) error
|
||||||
Get(userID string) (interface{}, error)
|
Get(userID string) (any, error)
|
||||||
GetID() string
|
GetID() string
|
||||||
GetDependency() string
|
GetDependency() string
|
||||||
IsDisabled(foreignValue interface{}) bool
|
IsDisabled(foreignValue any) bool
|
||||||
GetTitle() string
|
GetTitle() string
|
||||||
GetDescription() string
|
GetDescription() string
|
||||||
GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error)
|
GetSlackAttachments(userID, settingHandler string, disabled bool) (*model.SlackAttachment, error)
|
||||||
|
|||||||
@@ -2,6 +2,6 @@ package settings
|
|||||||
|
|
||||||
// SettingStore defines the behavior needed to set and get settings
|
// SettingStore defines the behavior needed to set and get settings
|
||||||
type SettingStore interface {
|
type SettingStore interface {
|
||||||
SetSetting(userID, settingID string, value interface{}) error
|
SetSetting(userID, settingID string, value any) error
|
||||||
GetSetting(userID, settingID string) (interface{}, error)
|
GetSetting(userID, settingID string) (any, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,9 +39,9 @@ func NewTrackerConfig(config *model.Config) TrackerConfig {
|
|||||||
// Tracker defines a telemetry tracker
|
// Tracker defines a telemetry tracker
|
||||||
type Tracker interface {
|
type Tracker interface {
|
||||||
// TrackEvent registers an event through the configured telemetry client
|
// TrackEvent registers an event through the configured telemetry client
|
||||||
TrackEvent(event string, properties map[string]interface{}) error
|
TrackEvent(event string, properties map[string]any) error
|
||||||
// TrackUserEvent registers an event through the configured telemetry client associated to a user
|
// TrackUserEvent registers an event through the configured telemetry client associated to a user
|
||||||
TrackUserEvent(event string, userID string, properties map[string]interface{}) error
|
TrackUserEvent(event string, userID string, properties map[string]any) error
|
||||||
// Reload Config re-evaluates tracker config to determine if tracking behavior should change
|
// Reload Config re-evaluates tracker config to determine if tracking behavior should change
|
||||||
ReloadConfig(config TrackerConfig)
|
ReloadConfig(config TrackerConfig)
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ type Client interface {
|
|||||||
type Track struct {
|
type Track struct {
|
||||||
UserID string
|
UserID string
|
||||||
Event string
|
Event string
|
||||||
Properties map[string]interface{}
|
Properties map[string]any
|
||||||
InstallationID string
|
InstallationID string
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,14 +126,14 @@ func (t *tracker) ReloadConfig(config TrackerConfig) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Note that config lock is handled by the caller.
|
// Note that config lock is handled by the caller.
|
||||||
func (t *tracker) debugf(message string, args ...interface{}) {
|
func (t *tracker) debugf(message string, args ...any) {
|
||||||
if t.logger == nil || !t.config.EnabledLogging {
|
if t.logger == nil || !t.config.EnabledLogging {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
t.logger.Debugf(message, args...)
|
t.logger.Debugf(message, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracker) TrackEvent(event string, properties map[string]interface{}) error {
|
func (t *tracker) TrackEvent(event string, properties map[string]any) error {
|
||||||
t.configLock.RLock()
|
t.configLock.RLock()
|
||||||
defer t.configLock.RUnlock()
|
defer t.configLock.RUnlock()
|
||||||
|
|
||||||
@@ -144,7 +144,7 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
if properties == nil {
|
if properties == nil {
|
||||||
properties = map[string]interface{}{}
|
properties = map[string]any{}
|
||||||
}
|
}
|
||||||
properties["PluginID"] = t.pluginID
|
properties["PluginID"] = t.pluginID
|
||||||
properties["PluginVersion"] = t.pluginVersion
|
properties["PluginVersion"] = t.pluginVersion
|
||||||
@@ -169,9 +169,9 @@ func (t *tracker) TrackEvent(event string, properties map[string]interface{}) er
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *tracker) TrackUserEvent(event, userID string, properties map[string]interface{}) error {
|
func (t *tracker) TrackUserEvent(event, userID string, properties map[string]any) error {
|
||||||
if properties == nil {
|
if properties == nil {
|
||||||
properties = map[string]interface{}{}
|
properties = map[string]any{}
|
||||||
}
|
}
|
||||||
|
|
||||||
properties["UserActualID"] = userID
|
properties["UserActualID"] = userID
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ func (f *FrontendService) OpenInteractiveDialog(dialog model.OpenDialogRequest)
|
|||||||
// broadcast determines to which users to send the event.
|
// broadcast determines to which users to send the event.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.2
|
// Minimum server version: 5.2
|
||||||
func (f *FrontendService) PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast) {
|
func (f *FrontendService) PublishWebSocketEvent(event string, payload map[string]any, broadcast *model.WebsocketBroadcast) {
|
||||||
f.api.PublishWebSocketEvent(event, payload, broadcast)
|
f.api.PublishWebSocketEvent(event, payload, broadcast)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type PluginAPI interface {
|
|||||||
GetBundlePath() (string, error)
|
GetBundlePath() (string, error)
|
||||||
GetConfig() *model.Config
|
GetConfig() *model.Config
|
||||||
GetUser(userID string) (*model.User, *model.AppError)
|
GetUser(userID string) (*model.User, *model.AppError)
|
||||||
LogWarn(msg string, keyValuePairs ...interface{})
|
LogWarn(msg string, keyValuePairs ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message is a string that can be localized.
|
// Message is a string that can be localized.
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ type KVService struct {
|
|||||||
|
|
||||||
type KVSetOptions struct {
|
type KVSetOptions struct {
|
||||||
model.PluginKVSetOptions
|
model.PluginKVSetOptions
|
||||||
oldValue interface{}
|
oldValue any
|
||||||
}
|
}
|
||||||
|
|
||||||
// KVSetOption is an option passed to Set() operation.
|
// KVSetOption is an option passed to Set() operation.
|
||||||
@@ -33,7 +33,7 @@ type KVSetOption func(*KVSetOptions)
|
|||||||
// SetAtomic guarantees the write will occur only when the current value of matches the given old
|
// SetAtomic guarantees the write will occur only when the current value of matches the given old
|
||||||
// value. A client is expected to read the old value first, then pass it back to ensure the value
|
// value. A client is expected to read the old value first, then pass it back to ensure the value
|
||||||
// has not since been modified.
|
// has not since been modified.
|
||||||
func SetAtomic(oldValue interface{}) KVSetOption {
|
func SetAtomic(oldValue any) KVSetOption {
|
||||||
return func(o *KVSetOptions) {
|
return func(o *KVSetOptions) {
|
||||||
o.Atomic = true
|
o.Atomic = true
|
||||||
o.oldValue = oldValue
|
o.oldValue = oldValue
|
||||||
@@ -55,7 +55,7 @@ func SetExpiry(ttl time.Duration) KVSetOption {
|
|||||||
// Returns (true, nil) if the value was set
|
// Returns (true, nil) if the value was set
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.18
|
// Minimum server version: 5.18
|
||||||
func (k *KVService) Set(key string, value interface{}, options ...KVSetOption) (bool, error) {
|
func (k *KVService) Set(key string, value any, options ...KVSetOption) (bool, error) {
|
||||||
if strings.HasPrefix(key, internalKeyPrefix) {
|
if strings.HasPrefix(key, internalKeyPrefix) {
|
||||||
return false, errors.Errorf("'%s' prefix is not allowed for keys", internalKeyPrefix)
|
return false, errors.Errorf("'%s' prefix is not allowed for keys", internalKeyPrefix)
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ func (k *KVService) Set(key string, value interface{}, options ...KVSetOption) (
|
|||||||
// Returns nil if the value was set.
|
// Returns nil if the value was set.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.18
|
// Minimum server version: 5.18
|
||||||
func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []byte) (newValue interface{}, err error)) error {
|
func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []byte) (newValue any, err error)) error {
|
||||||
for i := 0; i < numRetries; i++ {
|
for i := 0; i < numRetries; i++ {
|
||||||
var oldVal []byte
|
var oldVal []byte
|
||||||
if err := k.Get(key, &oldVal); err != nil {
|
if err := k.Get(key, &oldVal); err != nil {
|
||||||
@@ -153,7 +153,7 @@ func (k *KVService) SetAtomicWithRetries(key string, valueFunc func(oldValue []b
|
|||||||
// error, with nothing written to the given interface.
|
// error, with nothing written to the given interface.
|
||||||
//
|
//
|
||||||
// Minimum server version: 5.2
|
// Minimum server version: 5.2
|
||||||
func (k *KVService) Get(key string, o interface{}) error {
|
func (k *KVService) Get(key string, o any) error {
|
||||||
data, appErr := k.api.KVGet(key)
|
data, appErr := k.api.KVGet(key)
|
||||||
if appErr != nil {
|
if appErr != nil {
|
||||||
return normalizeAppErr(appErr)
|
return normalizeAppErr(appErr)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ func TestKVSet(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
key string
|
key string
|
||||||
value interface{}
|
value any
|
||||||
options []pluginapi.KVSetOption
|
options []pluginapi.KVSetOption
|
||||||
expectedValue []byte
|
expectedValue []byte
|
||||||
expectedOptions model.PluginKVSetOptions
|
expectedOptions model.PluginKVSetOptions
|
||||||
@@ -158,7 +158,7 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
name string
|
name string
|
||||||
key string
|
key string
|
||||||
valueFunc func(t *testing.T) func(old []byte) (interface{}, error)
|
valueFunc func(t *testing.T) func(old []byte) (any, error)
|
||||||
setupAPI func(api *plugintest.API)
|
setupAPI func(api *plugintest.API)
|
||||||
wantErr bool
|
wantErr bool
|
||||||
expectedErrPrefix string
|
expectedErrPrefix string
|
||||||
@@ -166,8 +166,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries success after first attempt",
|
name: "Test SetAtomicWithRetries success after first attempt",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return 2, nil
|
return 2, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -184,8 +184,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test success after first attempt, old is struct and as expected",
|
name: "Test success after first attempt, old is struct and as expected",
|
||||||
key: "testNum2",
|
key: "testNum2",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
type toStore struct {
|
type toStore struct {
|
||||||
Value int
|
Value int
|
||||||
}
|
}
|
||||||
@@ -213,8 +213,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test success after first attempt, old is an int value and as expected",
|
name: "Test success after first attempt, old is an int value and as expected",
|
||||||
key: "testNum2",
|
key: "testNum2",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
fromDB, err := strconv.Atoi(string(old))
|
fromDB, err := strconv.Atoi(string(old))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -236,8 +236,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries success on fourth attempt",
|
name: "Test SetAtomicWithRetries success on fourth attempt",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return 2, nil
|
return 2, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -258,8 +258,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries success on fourth attempt because value was changed between calls to KVGet",
|
name: "Test SetAtomicWithRetries success on fourth attempt because value was changed between calls to KVGet",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return 2, nil
|
return 2, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -280,8 +280,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries failure on get",
|
name: "Test SetAtomicWithRetries failure on get",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return nil, errors.New("should not have got here")
|
return nil, errors.New("should not have got here")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -294,8 +294,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries failure on valueFunc",
|
name: "Test SetAtomicWithRetries failure on valueFunc",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return nil, errors.New("some user provided error")
|
return nil, errors.New("some user provided error")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -309,8 +309,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries DB failure on set",
|
name: "Test SetAtomicWithRetries DB failure on set",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return 2, nil
|
return 2, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -329,8 +329,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries failure on five set attempts -- depends on numRetries constant being = 5",
|
name: "Test SetAtomicWithRetries failure on five set attempts -- depends on numRetries constant being = 5",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
return 2, nil
|
return 2, nil
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -349,8 +349,8 @@ func TestSetAtomicWithRetries(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "Test SetAtomicWithRetries success after five set attempts -- depends on numRetries constant being = 5",
|
name: "Test SetAtomicWithRetries success after five set attempts -- depends on numRetries constant being = 5",
|
||||||
key: "testNum",
|
key: "testNum",
|
||||||
valueFunc: func(t *testing.T) func(old []byte) (interface{}, error) {
|
valueFunc: func(t *testing.T) func(old []byte) (any, error) {
|
||||||
return func(old []byte) (interface{}, error) {
|
return func(old []byte) (any, error) {
|
||||||
fromDB, err := strconv.Atoi(string(old))
|
fromDB, err := strconv.Atoi(string(old))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -13,21 +13,21 @@ type LogService struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Error logs an error message, optionally structured with alternating key, value parameters.
|
// Error logs an error message, optionally structured with alternating key, value parameters.
|
||||||
func (l *LogService) Error(message string, keyValuePairs ...interface{}) {
|
func (l *LogService) Error(message string, keyValuePairs ...any) {
|
||||||
l.api.LogError(message, keyValuePairs...)
|
l.api.LogError(message, keyValuePairs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Warn logs an error message, optionally structured with alternating key, value parameters.
|
// Warn logs an error message, optionally structured with alternating key, value parameters.
|
||||||
func (l *LogService) Warn(message string, keyValuePairs ...interface{}) {
|
func (l *LogService) Warn(message string, keyValuePairs ...any) {
|
||||||
l.api.LogWarn(message, keyValuePairs...)
|
l.api.LogWarn(message, keyValuePairs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Info logs an error message, optionally structured with alternating key, value parameters.
|
// Info logs an error message, optionally structured with alternating key, value parameters.
|
||||||
func (l *LogService) Info(message string, keyValuePairs ...interface{}) {
|
func (l *LogService) Info(message string, keyValuePairs ...any) {
|
||||||
l.api.LogInfo(message, keyValuePairs...)
|
l.api.LogInfo(message, keyValuePairs...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Debug logs an error message, optionally structured with alternating key, value parameters.
|
// Debug logs an error message, optionally structured with alternating key, value parameters.
|
||||||
func (l *LogService) Debug(message string, keyValuePairs ...interface{}) {
|
func (l *LogService) Debug(message string, keyValuePairs ...any) {
|
||||||
l.api.LogDebug(message, keyValuePairs...)
|
l.api.LogDebug(message, keyValuePairs...)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ func (lh *LogrusHook) Levels() []logrus.Level {
|
|||||||
|
|
||||||
// Fire proxies logrus entries through the plugin API at the appropriate level.
|
// Fire proxies logrus entries through the plugin API at the appropriate level.
|
||||||
func (lh *LogrusHook) Fire(entry *logrus.Entry) error {
|
func (lh *LogrusHook) Fire(entry *logrus.Entry) error {
|
||||||
fields := []interface{}{}
|
fields := []any{}
|
||||||
for key, value := range entry.Data {
|
for key, value := range entry.Data {
|
||||||
fields = append(fields, key, fmt.Sprintf("%+v", value))
|
fields = append(fields, key, fmt.Sprintf("%+v", value))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ func (c *Context) With(f func(ctx CTX) CTX) CTX {
|
|||||||
|
|
||||||
// CTX should be abbreviated as `rctx`.
|
// CTX should be abbreviated as `rctx`.
|
||||||
type CTX interface {
|
type CTX interface {
|
||||||
T(string, ...interface{}) string
|
T(string, ...any) string
|
||||||
GetT() i18n.TranslateFunc
|
GetT() i18n.TranslateFunc
|
||||||
Session() *model.Session
|
Session() *model.Session
|
||||||
RequestId() string
|
RequestId() string
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ func TestIsJSONEmpty(t *testing.T) {
|
|||||||
if !testCase.Empty {
|
if !testCase.Empty {
|
||||||
// don't really need to test the JSON unmarshaller but this is included
|
// don't really need to test the JSON unmarshaller but this is included
|
||||||
// to ensure the test cases stay valid.
|
// to ensure the test cases stay valid.
|
||||||
var v interface{}
|
var v any
|
||||||
err := json.Unmarshal(testCase.Data, &v)
|
err := json.Unmarshal(testCase.Data, &v)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ const enterpriseKeyPrefix = "ent."
|
|||||||
const untranslatedKey = "<untranslated>"
|
const untranslatedKey = "<untranslated>"
|
||||||
|
|
||||||
type Translation struct {
|
type Translation struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Translation interface{} `json:"translation"`
|
Translation any `json:"translation"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Item struct {
|
type Item struct {
|
||||||
@@ -730,7 +730,7 @@ func removeEmptyTranslations(oldList []Item) ([]Item, int) {
|
|||||||
return newList, count
|
return newList, count
|
||||||
}
|
}
|
||||||
|
|
||||||
func JSONMarshal(t interface{}) ([]byte, error) {
|
func JSONMarshal(t any) ([]byte, error) {
|
||||||
buffer := &bytes.Buffer{}
|
buffer := &bytes.Buffer{}
|
||||||
encoder := json.NewEncoder(buffer)
|
encoder := json.NewEncoder(buffer)
|
||||||
encoder.SetEscapeHTML(false)
|
encoder.SetEscapeHTML(false)
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user