Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MM-38146] Use mattermost-server/v6 #169

Merged
merged 2 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions build/deploy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"os"
"path/filepath"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mholt/archiver/v3"
"github.com/pkg/errors"
)
Expand Down Expand Up @@ -52,9 +52,9 @@ func deploy() error {
if adminUsername != "" && adminPassword != "" {
client := model.NewAPIv4Client(siteURL)
log.Printf("Authenticating as %s against %s.", adminUsername, siteURL)
_, resp := client.Login(adminUsername, adminPassword)
if resp.Error != nil {
return errors.Wrapf(resp.Error, "failed to login as %s", adminUsername)
_, _, err := client.Login(adminUsername, adminPassword)
if err != nil {
return errors.Wrapf(err, "failed to login as %s", adminUsername)
}

return uploadPlugin(client, pluginID, bundlePath)
Expand Down Expand Up @@ -83,15 +83,15 @@ func uploadPlugin(client *model.Client4, pluginID, bundlePath string) error {
defer pluginBundle.Close()

log.Print("Uploading plugin via API.")
_, resp := client.UploadPluginForced(pluginBundle)
if resp.Error != nil {
return errors.Wrap(resp.Error, "failed to upload plugin bundle")
_, _, err = client.UploadPluginForced(pluginBundle)
if err != nil {
return errors.Wrap(err, "failed to upload plugin bundle")
}

log.Print("Enabling plugin.")
_, resp = client.EnablePlugin(pluginID)
if resp.Error != nil {
return errors.Wrap(resp.Error, "Failed to enable plugin")
_, err = client.EnablePlugin(pluginID)
if err != nil {
return errors.Wrap(err, "Failed to enable plugin")
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion build/manifest/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"io/ioutil"
"os"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/pkg/errors"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.12

require (
github.com/gorilla/mux v1.8.0
github.com/mattermost/mattermost-server/v5 v5.3.2-0.20210621071817-df224571d8a1
github.com/mattermost/mattermost-server/v6 v6.0.0-20210901153517-42e75fad4dae
github.com/mholt/archiver/v3 v3.5.0
github.com/pkg/errors v0.9.1
github.com/stretchr/testify v1.7.0
Expand Down
209 changes: 66 additions & 143 deletions go.sum

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions server/autolink/autolink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"testing"
"time"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
Expand Down
2 changes: 1 addition & 1 deletion server/autolinkclient/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"net/http"
"testing"

"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand Down
8 changes: 4 additions & 4 deletions server/autolinkplugin/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (
"strconv"
"strings"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/pkg/errors"

"github.com/mattermost/mattermost-plugin-autolink/server/autolink"
Expand Down Expand Up @@ -310,9 +310,9 @@ func executeHelp(p *Plugin, c *plugin.Context, header *model.CommandArgs, args .

func responsef(format string, args ...interface{}) *model.CommandResponse {
return &model.CommandResponse{
ResponseType: model.COMMAND_RESPONSE_TYPE_EPHEMERAL,
ResponseType: model.CommandResponseTypeEphemeral,
Text: fmt.Sprintf(format, args...),
Type: model.POST_DEFAULT,
Type: model.PostTypeDefault,
}
}

Expand Down
2 changes: 1 addition & 1 deletion server/autolinkplugin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"sort"
"strings"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v6/model"

"github.com/mattermost/mattermost-plugin-autolink/server/autolink"
)
Expand Down
6 changes: 3 additions & 3 deletions server/autolinkplugin/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"errors"
"testing"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest/mock"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

Expand Down
7 changes: 3 additions & 4 deletions server/autolinkplugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"strings"
"sync"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/shared/markdown"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/mattermost/mattermost-server/v6/shared/markdown"

"github.com/mattermost/mattermost-plugin-autolink/server/api"
)
Expand Down Expand Up @@ -217,7 +217,6 @@ func (p *Plugin) ProcessPost(c *plugin.Context, post *model.Post) (*model.Post,
}

func (p *Plugin) ServeHTTP(c *plugin.Context, w http.ResponseWriter, r *http.Request) {
r.Header.Set("Mattermost-Plugin-ID", c.SourcePluginId)
p.handler.ServeHTTP(w, r)
}

Expand Down
11 changes: 6 additions & 5 deletions server/autolinkplugin/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"net/http/httptest"
"testing"

"github.com/mattermost/mattermost-server/v5/model"
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest"
"github.com/mattermost/mattermost-server/v5/plugin/plugintest/mock"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest"
"github.com/mattermost/mattermost-server/v6/plugin/plugintest/mock"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/stretchr/testify/suite"
Expand Down Expand Up @@ -725,7 +725,8 @@ func TestAPI(t *testing.T) {
recorder := httptest.NewRecorder()
req, err := http.NewRequest("POST", "/api/v1/link", bytes.NewReader(jbyte))
require.NoError(t, err)
p.ServeHTTP(&plugin.Context{SourcePluginId: "somthing"}, recorder, req)
req.Header.Set("Mattermost-Plugin-ID", "somthing")
p.ServeHTTP(&plugin.Context{}, recorder, req)
resp := recorder.Result()
require.NotNil(t, resp)
assert.Equal(t, http.StatusOK, resp.StatusCode)
Expand Down
2 changes: 1 addition & 1 deletion server/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main

import (
"github.com/mattermost/mattermost-server/v5/plugin"
"github.com/mattermost/mattermost-server/v6/plugin"

"github.com/mattermost/mattermost-plugin-autolink/server/autolinkplugin"
)
Expand Down