Skip to content

Commit

Permalink
update dependencies (mattermost#515)
Browse files Browse the repository at this point in the history
* update dependencies

* Drop support for installing a plugin with a specific version (mattermost#489)

* Drop support for installing a plugin with a specific version

* Update example

* update dependencies

* update translations

Co-authored-by: Ben Schumacher <[email protected]>
  • Loading branch information
isacikgoz and hanzei authored May 16, 2022
1 parent 8df60ca commit c8d04ea
Show file tree
Hide file tree
Showing 1,790 changed files with 105,747 additions and 62,629 deletions.
3 changes: 1 addition & 2 deletions commands/channel_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ func (s *MmctlE2ETestSuite) TestCreateChannelCmd() {
})

s.RunForAllClients("create channel with invalid name", func(c client.Client) {
s.T().Skip("MM-43873")
printer.Clean()

cmd := &cobra.Command{}
Expand All @@ -223,7 +222,7 @@ func (s *MmctlE2ETestSuite) TestCreateChannelCmd() {

err := createChannelCmdF(c, cmd, []string{})
s.Require().NotNil(err)
s.Require().Equal(": Name must be 2 or more lowercase alphanumeric characters., ", err.Error())
s.Require().Contains(err.Error(), "model.channel.is_valid.2_or_more.app_error")
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)

Expand Down
8 changes: 4 additions & 4 deletions commands/group_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupEnableCmd() {
Name: model.NewString("name" + id),
Source: model.GroupSourceLdap,
Description: "description_" + id,
RemoteId: model.NewId(),
RemoteId: model.NewString(model.NewId()),
})
s.Require().Nil(appErr)
defer func() {
Expand Down Expand Up @@ -106,7 +106,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupDisableCmd() {
Name: model.NewString("name" + id),
Source: model.GroupSourceLdap,
Description: "description_" + id,
RemoteId: model.NewId(),
RemoteId: model.NewString(model.NewId()),
})
s.Require().Nil(appErr)
defer func() {
Expand Down Expand Up @@ -261,7 +261,7 @@ func (s *MmctlE2ETestSuite) TestChannelGroupListCmd() {
Name: model.NewString("name" + id),
Source: model.GroupSourceLdap,
Description: "description_" + id,
RemoteId: model.NewId(),
RemoteId: model.NewString(model.NewId()),
})
s.Require().Nil(appErr)
defer func() {
Expand Down Expand Up @@ -484,7 +484,7 @@ func createTestGroupTeam(s *MmctlE2ETestSuite) (*model.Team, *model.Group, func(
Name: model.NewString("name" + id),
Source: model.GroupSourceLdap,
Description: "description_" + id,
RemoteId: model.NewId(),
RemoteId: model.NewString(model.NewId()),
})
s.Require().Nil(appErr)

Expand Down
40 changes: 7 additions & 33 deletions commands/plugin_marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package commands

import (
"fmt"

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

"github.com/mattermost/mmctl/v6/client"
Expand All @@ -21,16 +19,12 @@ var PluginMarketplaceCmd = &cobra.Command{
}

var PluginMarketplaceInstallCmd = &cobra.Command{
Use: "install <id> [version]",
Short: "Install a plugin from the marketplace",
Long: "Installs a plugin listed in the marketplace server",
Example: ` # you can specify with both the plugin id and its version
$ mmctl plugin marketplace install jitsi 2.0.0
# if you don't specify the version, the latest one will be installed
$ mmctl plugin marketplace install jitsi`,
Args: cobra.MinimumNArgs(1),
RunE: withClient(pluginMarketplaceInstallCmdF),
Use: "install <id>",
Short: "Install a plugin from the marketplace",
Long: "Installs a plugin listed in the marketplace server",
Example: ` plugin marketplace install jitsi`,
Args: cobra.ExactArgs(1),
RunE: withClient(pluginMarketplaceInstallCmdF),
}

var PluginMarketplaceListCmd = &cobra.Command{
Expand Down Expand Up @@ -71,28 +65,8 @@ func init() {

func pluginMarketplaceInstallCmdF(c client.Client, _ *cobra.Command, args []string) error {
id := args[0]
var version string

if len(args) < 2 {
plugins, _, err := c.GetMarketplacePlugins(&model.MarketplacePluginFilter{Filter: id, PerPage: 200})
if err != nil {
return errors.Wrap(err, "Failed to fetch plugins")
}

for _, plugin := range plugins {
if plugin.Manifest.Id == id {
version = plugin.Manifest.Version
}
}

if version == "" {
return fmt.Errorf("couldn't find a plugin with id %q", id)
}
} else {
version = args[1]
}

pluginRequest := &model.InstallMarketplacePluginRequest{Id: id, Version: version}
pluginRequest := &model.InstallMarketplacePluginRequest{Id: id}
manifest, _, err := c.InstallMarketplacePlugin(pluginRequest)
if err != nil {
return errors.Wrap(err, "couldn't install plugin from marketplace")
Expand Down
59 changes: 4 additions & 55 deletions commands/plugin_marketplace_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
package commands

import (
"fmt"

"github.com/mattermost/mattermost-server/v6/model"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -33,7 +31,7 @@ func (s *MmctlE2ETestSuite) TestPluginMarketplaceInstallCmd() {

defer removePluginIfInstalled(c, s, pluginID)

err := pluginMarketplaceInstallCmdF(c, &cobra.Command{}, []string{pluginID, pluginVersion})
err := pluginMarketplaceInstallCmdF(c, &cobra.Command{}, []string{pluginID})
s.Require().Nil(err)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 1)
Expand All @@ -54,13 +52,12 @@ func (s *MmctlE2ETestSuite) TestPluginMarketplaceInstallCmd() {
printer.Clean()

const (
pluginID = "jira"
pluginVersion = "3.0.0"
pluginID = "jira"
)

defer removePluginIfInstalled(s.th.Client, s, pluginID)

err := pluginMarketplaceInstallCmdF(s.th.Client, &cobra.Command{}, []string{pluginID, pluginVersion})
err := pluginMarketplaceInstallCmdF(s.th.Client, &cobra.Command{}, []string{pluginID})
s.Require().NotNil(err)
s.Require().Contains(err.Error(), "You do not have the appropriate permissions.")
s.Require().Len(printer.GetErrorLines(), 0)
Expand All @@ -72,54 +69,6 @@ func (s *MmctlE2ETestSuite) TestPluginMarketplaceInstallCmd() {
s.Require().Len(plugins.Inactive, 0)
})

s.RunForSystemAdminAndLocal("install a plugin without version", func(c client.Client) {
printer.Clean()

const (
pluginID = "jira"
)

defer removePluginIfInstalled(c, s, pluginID)

err := pluginMarketplaceInstallCmdF(c, &cobra.Command{}, []string{pluginID})
s.Require().Nil(err)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 1)

manifest := printer.GetLines()[0].(*model.Manifest)
s.Require().Equal(pluginID, manifest.Id)
s.Require().NotEmpty(manifest.Version)

plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 1)
s.Require().Equal(pluginID, plugins.Inactive[0].Id)
s.Require().NotEmpty(plugins.Inactive[0].Version)
})

s.RunForSystemAdminAndLocal("install a plugin with invalid version", func(c client.Client) {
printer.Clean()

const (
pluginID = "jira"
pluginVersion = "invalid-version"
)

defer removePluginIfInstalled(c, s, pluginID)

err := pluginMarketplaceInstallCmdF(c, &cobra.Command{}, []string{pluginID, pluginVersion})
s.Require().NotNil(err)
s.Require().Contains(err.Error(), "Could not find the requested marketplace plugin.")
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)

plugins, appErr := s.th.App.GetPlugins()
s.Require().Nil(appErr)
s.Require().Len(plugins.Active, 0)
s.Require().Len(plugins.Inactive, 0)
})

s.RunForSystemAdminAndLocal("install a nonexistent plugin", func(c client.Client) {
printer.Clean()

Expand All @@ -131,7 +80,7 @@ func (s *MmctlE2ETestSuite) TestPluginMarketplaceInstallCmd() {

err := pluginMarketplaceInstallCmdF(c, &cobra.Command{}, []string{pluginID})
s.Require().NotNil(err)
s.Require().Contains(err.Error(), fmt.Sprintf(`couldn't find a plugin with id "%s"`, pluginID))
s.Require().Contains(err.Error(), "Could not find the requested marketplace plugin")
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)

Expand Down
77 changes: 4 additions & 73 deletions commands/plugin_marketplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceInstallCmd() {
printer.Clean()

id := "myplugin"
version := "2.0.0"
args := []string{id, version}
pluginRequest := &model.InstallMarketplacePluginRequest{Id: id, Version: version}
args := []string{id}
pluginRequest := &model.InstallMarketplacePluginRequest{Id: id}
manifest := &model.Manifest{Name: "My Plugin", Id: id}

s.client.
Expand All @@ -43,46 +42,12 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceInstallCmd() {
s.Require().Equal(manifest, printer.GetLines()[0])
})

s.Run("Install a valid plugin omitting the version", func() {
printer.Clean()

id := "myplugin"
version := "2.0.0"

plugin := createMarketplacePlugin(id)
plugin.BaseMarketplacePlugin.Manifest.Id = id
plugin.BaseMarketplacePlugin.Manifest.Version = version
plugins := []*model.MarketplacePlugin{plugin}

pluginRequest := &model.InstallMarketplacePluginRequest{Id: id, Version: version}
manifest := &model.Manifest{Name: "My Plugin", Id: id}

s.client.
EXPECT().
GetMarketplacePlugins(&model.MarketplacePluginFilter{Filter: id, PerPage: 200}).
Return(plugins, &model.Response{}, nil).
Times(1)

s.client.
EXPECT().
InstallMarketplacePlugin(pluginRequest).
Return(manifest, &model.Response{}, nil).
Times(1)

err := pluginMarketplaceInstallCmdF(s.client, &cobra.Command{}, []string{id})
s.Require().NoError(err)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 1)
s.Require().Equal(manifest, printer.GetLines()[0])
})

s.Run("Install an invalid plugin", func() {
printer.Clean()

id := "myplugin"
version := "2.0.0"
args := []string{id, version}
pluginRequest := &model.InstallMarketplacePluginRequest{Id: id, Version: version}
args := []string{id}
pluginRequest := &model.InstallMarketplacePluginRequest{Id: id}

s.client.
EXPECT().
Expand All @@ -95,40 +60,6 @@ func (s *MmctlUnitTestSuite) TestPluginMarketplaceInstallCmd() {
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)
})

s.Run("Install an invalid plugin omitting the version", func() {
printer.Clean()

id := "myplugin"

s.client.
EXPECT().
GetMarketplacePlugins(&model.MarketplacePluginFilter{Filter: id, PerPage: 200}).
Return(nil, &model.Response{}, errors.New("mock error")).
Times(1)

err := pluginMarketplaceInstallCmdF(s.client, &cobra.Command{}, []string{id})
s.Require().Error(err)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)
})

s.Run("Install a nonexisting plugin omitting the version", func() {
printer.Clean()

id := "myplugin"

s.client.
EXPECT().
GetMarketplacePlugins(&model.MarketplacePluginFilter{Filter: id, PerPage: 200}).
Return([]*model.MarketplacePlugin{}, &model.Response{}, nil).
Times(1)

err := pluginMarketplaceInstallCmdF(s.client, &cobra.Command{}, []string{id})
s.Require().Error(err)
s.Require().Len(printer.GetErrorLines(), 0)
s.Require().Len(printer.GetLines(), 0)
})
}

func (s *MmctlUnitTestSuite) TestPluginMarketplaceListCmd() {
Expand Down
8 changes: 2 additions & 6 deletions docs/mmctl_plugin_marketplace_install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,14 @@ Installs a plugin listed in the marketplace server

::

mmctl plugin marketplace install <id> [version] [flags]
mmctl plugin marketplace install <id> [flags]

Examples
~~~~~~~~

::

# you can specify with both the plugin id and its version
$ mmctl plugin marketplace install jitsi 2.0.0

# if you don't specify the version, the latest one will be installed
$ mmctl plugin marketplace install jitsi
plugin marketplace install jitsi

Options
~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion enterprise_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1bbb8177d42efda9a0bf10033d4a24a3fcc5f4f1
6185d9ea2cb7954b153c280f91cedb11ae92930f
Loading

0 comments on commit c8d04ea

Please sign in to comment.