Commit Graph

206 Commits

Author SHA1 Message Date
Shobhit Gupta
7d99d8fba7 Add IsValid method to *Manifest struct (#13609) 2020-01-17 21:08:55 +01:00
Maria A Nunez
87eb7697f9 MM-19606- Rework Prepackaged Plugins (#13449)
* MM-19609 - Add new prepackage configuration settings (#13062)

* Add signatures to the prepackaged plugins (#13138)

* MM-19612 - Support querying local plugin marketplace when upst… (#13250)

* MM-19612 - Support querying local plugin marketplace when upstream unavailable or disabled

* Update translations file

* Fixed comment

* Updated to check EnableRemoteMarketplace setting and LocalOnly to get marketplace plugins

* Fixed unit tests

* Tests cleanup code

* Removed unused error message

* Updated tests

* MM-19614- Updated Marketplace Service error id (#13388)

* [MM-19610] Consume prepackaged plugins (#13005)

* consume prepackaged plugins into memory

* missing i18n

* remove spurious .gitignore changes

* return on failure to install prepackged plugins

* cleanup

* s/plugins/availablePlugins

* whitespace

* don't return extractDir when not needed

* s/plug/plugin

* error on icon, cleanup

* update armored version of testplugin signature

* honour AutomaticPrepackagedPlugins

* document getPrepackagedPlugin

* MM-19613 - Include prepackaged plugins in marketplace results (#13433)

* Added prepackaged plugins to marketplace results

* PR Feedback

* PR Feedback

* Update error where definition

* Removing unnecessary var declaration

* Updated comments

* MM-21263 - Use EnableRemoteMarketplace in marketplace install… (#13438)

* MM-21263 - Use EnableRemoteMarketplace in marketplace install endpoint

* Call updateConfig before calling NewServer in TestHelper

* Added translations

* PR feedback

* Translations

* Feedback

* s/helpers.go/download.go

* Converging env.PrepackagedPlugins

* Initial PR feedback

* Ordered imports properly

* Updated DownloadURL to return slice of bytes

* Fixed method typo

* Fixed logging

* Added read lock for prepackaged plugins list

* PR Feedback

* Added condition to only install prepackaged plugin if it was previously enabled

* Linting

* Updated to check plugin state in config

* Closing filereader

* Only add local label if remote marketplace is enabled

* Updated local tag description

* Fixed tests

Co-authored-by: Ali Farooq <ali.farooq0@pm.me>
Co-authored-by: Shota Gvinepadze <wineson@gmail.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
2020-01-15 13:38:55 -05:00
Eli Yukelzon
e77ef9733c MM-20977 - Inviting multiple users with valid/allowed and inva… (#13372) 2020-01-14 15:29:50 +02:00
Rajat Varyani
1b3846a508 [MM-16700] Add InstallPluginFromUrl helper method (#12994)
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
2020-01-07 13:56:12 +01:00
Agniva De Sarker
edddabf95c MM-19628: Fix race in (*registeredPlugin).State access (#13332)
* MM-19628: Fix race in (*registeredPlugin).State access

We used a pointer to an integer in the State variable, and therefore
setting a pointer value directly caused a race condition.

Since the registeredPlugin is a private struct, changing it to a normal int
creates fewer pointers and lets us to fix the race condition by simply setting
the integer value and then doing a registeredPlugins.Store.

The alternative to keeping the pointer would be to create a copy of each
member of a registeredPlugin and do a store again, which I feel is a roundabout
way to achieve this.

* Address review comments

Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-07 17:30:34 +05:30
Jesús Espino
092e53ace2 Fix inconsistencies in variable names for struct methods (#13561) 2020-01-07 10:47:03 +01:00
Ibrahim Serdar Acikgoz
d8ac09b302 Gh 10166 (#13021)
* model/config: add required server config field to manifest

* plugin/helpers: add check required server configuration method

* plugin/helpers: code polish

* model/manifest: add documentation

* Update plugin/helpers_config.go

Co-Authored-By: Ben Schumacher <ben.schumacher@mattermost.com>

* plugin/helpers_config: remove stagnant line

* plugin/helpers: update to v5

* plugin/helpers_config: add license

Co-authored-by: Ben Schumacher <ben.schumacher@mattermost.com>
Co-authored-by: Jesse Hallam <jesse.hallam@gmail.com>
Co-authored-by: mattermod <mattermod@users.noreply.github.com>
2020-01-06 17:08:24 -04:00
Vladimir Lebedev
722924b910 MM-19508 Extend ShouldProcessMessage to filter out from_webhoo… (#13270)
Extend ShouldProcessMessage to filter out from_webhook posts
2019-12-19 20:52:41 +01:00
Ben Schumacher
5122b9e292 [MM-20723] Add golint for plugin package to golangci (#13090) 2019-12-05 20:31:53 +01:00
Ben Schumacher
d0d6ce0a70 [MM-20353] Change KVSetWithOptions to accept a byte slice (#13213)
* Drop EncodeJSON from PluginKVSetOptions

* Add unit tests for KVSetWithOptions with nil values
2019-12-03 10:46:15 +01:00
Jesús Espino
a63684fcb5 Consistent license message for all the go files (#13235)
* Consistent license message for all the go files

* Fixing the last set of unconsistencies with the license headers

* Addressing PR review comments

* Fixing busy.go and busy_test.go license header
2019-11-29 12:59:40 +01:00
İlker Göktuğ Öztürk
0adbfa8478 plugin: fix InstallPlugin() API by manually creating RPC code (#13041)
Flugin: fix InstallPlugin() API by manually creating RPC code

previous implementation of InstallPlugin()-#12232 's RPC funcs wasn't working because `io.Reader` isn't supported by the RPC code generation tool.

RPC does not support streaming data and RPC code generation tool does not handle this exception.

thus, RPC funcs are now implemented manually to stream `io.Reader` through a separate multiplexed connection.
2019-11-29 12:41:17 +01:00
Miguel de la Cruz
2259b7f2a8 [MM-19948] Set version on module file and internal paths (#13186)
* [MM-19948] Set version on module file and internal paths

* Fixes after merge

* Fix i18n checker error
2019-11-28 14:39:38 +01:00
Rajat Varyani
f2fcfa8f9d [MM-16709] Add helper method for plugins using MessageHasBeenPosted (#12539)
The PR introduces a method in helper interface. The method has common code for filtering to be used across plugins which use MessageHasBeenPosted.
2019-11-18 10:47:32 +01:00
kanozec
1e2609651b Fix typo in plugin package (#13043)
Automatic Merge
2019-11-15 07:13:38 -05:00
Alex Sahin
6b0a88debf [MM-17297] Extend EnsureBot helper to include bot images (#12153) 2019-11-15 05:19:00 +01:00
Andres
1155b08404 MM - 19155 Change plugin helpers files to be golint complied (#12686)
* MM-19155 Change plugin helpers files to be golint complied

* add makefile target that checks if plugin/helpers files are golint
  compliant

* MM-19155 - Change plugin helpers files to be golint complied

* added comment documentation to exported plugin/helpers methods
* changed variable names to be compliant with golint

* Address feedback
2019-11-12 06:29:21 +01:00
Rajat Varyani
14b1777959 [MM-19153] Add server version check in helper methods for plugins (#12675) 2019-11-06 17:42:46 +01:00
Clément Collin
5f91c14576 [MM-18676] Add tag annotations to plugin server API methods (#12701)
* [MM-18676] Add tag annotations to plugin server API methods

- With mattermost-developer-documentation/pull/383, it will allow to group methods by tag in documentation index

* Refine tag annotations in plugin API documentation

- Replace "Profile" by "User"
- Add additional tags to multi purpose methods
- Add "Group" tag
- Add tags to new methods
2019-11-06 07:49:28 +01:00
Christopher Speller
428454cee4 Adding interplugin communication. (#12829)
* Adding interplugin communication.

* Naming changes and moving ResponseTransfer to own file.

* Fix.

* Tests and moving to buffering bytes.

* Switching API to passing plugin ID through path rather than a header.

* Review feedback.
2019-11-04 17:35:58 -08:00
Gervasio Marchand
1db045bce3 MM-16822 - Implement KVSetWithOptions (#11818)
* Add SetWithOptions

* Avoid passing two structs to the functions

* Rename ExpiryInSeconds -> ExpireInSeconds

* Use t.Run for the tests

* Fix build

* Address feedback

* Update log message

* Update docs and use KVSetWithOptions in KVCompareAndSetJSON

* Improve code style

* Use struct instead of pointer to struct

* Fix minimum server versions

* Update documentation

* Address feedback

* Revert new implemention of kv helpers

* Adress feedback
2019-11-04 13:49:54 +01:00
Ben Schumacher
a2adf7b3f5 Run unused against codebase (#12968)
* Remove unused methods

* Fix missed issues
2019-11-01 23:08:01 +01:00
Christopher Poile
0697f5206c [MM-16437] Plugin crashes the server when calling WriteHeader with an invalid http code (#11276)
* [MM-16437] add a check so that we don't write an invalid header

* better solution

* * passing in the logger; logging the error; fixed a spelling mistake

* trigger jenkins
2019-10-31 13:27:49 -04:00
Paulo Bittencourt
7d0d7c304e MM-17888 Check plugin Helpers minimum server version comments (#12663) 2019-10-30 08:34:29 +01:00
Clément Collin
7cc1f19453 [MM-18898] Stringify plugin.Log* parameters (#12700)
- Add stringutils with method that "stringify" object slices
  - "stringify" means convert each object to its string representation
- Move plugin.Log* implementations to client_rpc, use stringify method before calling server method
- Exclude Log* methods from generated RPC methods
- No signature change for plugin.Log* API
- Add test in plugin_api_test to use plugin.Log* methods with RPC
2019-10-30 04:17:04 +01:00
Ben Schumacher
7a665aacdd Run gosimple against codebase (#12928) 2019-10-29 07:45:09 +01:00
Joram Wilander
9307f75fe9 Add some group plugin APIs (#12180)
* Add group store GetByUser

* Add group store GetByName

* Add group plugin APIs

* Minor naming fixes

* Add minimum version comments
2019-10-22 14:38:08 -04:00
Christopher Speller
e62471dff6 MM-18816 Adding ability to add users as another user to the plugin API. (#12562)
* Adding ability to add users as anouther user to the plugin API.

* Documentation feedback.
2019-10-17 16:11:26 -07:00
Nikhil Ranjan
d7ee3553fa Plugin framework: add ability to install other plugins to the… (#12232)
* add ability to upload other plugins to the plugin API

* generated client rpc glue code

* fix UploadPlugin API signature

* generated plugin mocks

* added upload plugin test

* removed unused comment

* using single line to call InstallPlugin with file Reader

* fix minimum server version

* added successful plugin upload test

* renamed UploadPlugin to InstallPlugin
2019-10-17 14:57:55 -04:00
Michael Kochell
83bab2c125 [MM-19102] Enable debug flag for plugin check tests (#12588) 2019-10-17 10:38:47 -06:00
jatinjtg
0ba6a791ef Fix typo (#12655) 2019-10-15 15:45:46 +02:00
Santosh Desani
dc05e81012 [MM-18277] Refactor plugin/health_check.go to use structured l… (#12734) 2019-10-14 12:00:23 -06:00
Maria A Nunez
f257109953 Revert "MM-16809: Added EnsureChannel Helper (#11852)" (#12314)
This reverts commit 5aa24aedc8.
2019-09-24 13:48:33 -04:00
Jesse Hallam
33cf37bbc0 MM: 16479: ensure replacement file finishes io.Copy (#12249)
* simplify FileWillBeUploaded

* MM-16479: ensure replacement file finishes io.Copy
2019-09-19 22:02:19 -03:00
Jesse Hallam
4ce7b92283 MM-17023: Plugin Marketplace (#12183)
* MM-17149 - Extend config.json for marketplace settings (#11933)

* MM-17149 - Extend config.json for marketplace settings

* Renamed MarketplaceUrl, tracking default marketplace url

* Added EnableMarketplace to the client config

* Revert "Added EnableMarketplace to the client config"

This reverts commit 0f982c4c66.

* MM-17149 - Added EnableMarketplace to the client config (#11958)

* Added EnableMarketplace to the client config

* Moved EnableMarketplace setting out of limited client configuration

* MM-17150, MM-17545, MM-18100 - Implement GET /api/v4/plugins/m… (#11977)

* MM-17150 - Implement GET /api/v4/plugins/marketplace proxying upstream
MM-17545 - Merge locally installed plugins into GET /api/v4/plugins/marketplace

* Replaced MarketplacePluginState with Installed

* Setting InstalledVersion instead of Installed

* marketplace client setting per_page if non zero

* Creating insecure client for marketplace url

* Fixed trailing slash for default marketplace url

* Adding filtering

* Fixed function names

* Renamed Manifest() to GetManifest(), added godoc for BaseMarketplacePlugin

* Handling plugin.ErrNotFound correctly

* Checking err == nil instead when a plugin is installed

* MM-18450 - Local-only plugin search (#12152)

* MM-17846: plugin icons (#12157)

* MM-17846: add support for plugin icons

Extend the model definitions to support plugin icons from the marketplace.

* s/IconURL/IconData

* MM-18475 - Converge on snake_case responses from the marketplace (#12179)

* MM-18520 - MM-Server should forward server version to marketplace server (#12181)

* Renamed request to filter client4.GetMarketplacePlugins

* Renamed request to filter

* Guarding against bad marketplace server response
2019-09-17 15:02:26 -04:00
Paulo Bittencourt
5b79fc4110 [MM-17889] Implement validation of plugin API version comments (#11941) 2019-09-17 08:03:28 +02:00
Nikhil Ranjan
54c0e394f5 MM-18278 Converting to structured logging the file plugin/supe… (#12177) 2019-09-12 09:31:09 -04:00
Jesse Hallam
451982f9d3 improved OnDeactivate handling (#11988)
* Deactivate plugins in parallel to improve shutdown time
* Give plugins at most 10s to handle OnDeactivate before forcefully terminating
2019-09-05 17:27:36 -03:00
Rodrigo Villablanca Vásquez
65f03de1ee [MM-19711] - Get plugin configuration without removing secrets (#11928)
* Method GetUnsanitizedConfig() exposed to API (Plugin) interface and his implementations

* improvements with some suggestions

* Fix documentation (final period added)

Co-Authored-By: Ali Farooq <25732808+ali-farooq0@users.noreply.github.com>

* Added some test for Plugin.GetConfig and Plugin.GetUnsanitizedConfig

* Removed empty lines
2019-09-03 18:41:52 -04:00
Ankit R. Gadiya
5aa24aedc8 MM-16809: Added EnsureChannel Helper (#11852)
This PR adds EnsureChannel helper analogous to EnsureBot helper which creates a new channel if not exists and update the meta data of the channel if exists. Also, it will throw error
if the type of existing channel do not match the type of new channel.
2019-09-03 22:18:08 +02:00
Jesse Hallam
8afbe9c6a4 MM-18167: fix KV* helpers error handling (#12023)
* MM-18167: fix KV* helpers error handling

Returning a `nil` `*model.AppError` does not make a `nil` `error`
interface. As a consequence, all of the KV* helper methods would always
appear to fail, even if the underlying API call was successful.

Fix this mismatch by explicitly assigning `appErr` in the helpers and
only ever returning a `nil` `error` interface. Extend unit tests to
achieve 100% coverage of the associated files.

In the long run, we must change all function signatures to return the
`error` interface instead of the abomination that is returning
`*model.AppError` today.
2019-09-03 22:17:20 +02:00
Carlos Tadeu Panato Junior
9e9f1bb2aa Stop plugin healthchecks before shutting down plugins (#11972)
* cancel plugin check when shutdown

* move to top

* stop healthcheck job only once, and if started

* whitespace
2019-08-30 02:36:38 +08:00
Ali Farooq
5754ffc320 MM-17087 - Disable plugin on removal (#11779)
* MM-17087 - Disable plugin on removal

* Updated documentation

* Got reid of notifyPluginEvents

* Updated documentation

* Added plugin installation/activatoin flow as a toplevel go doc in plugin_install.go

* Generating webapp bundle on plugin installation

* Fixed shadowing issue

* Updated doc to include unguarded race condition

* Renamed GenerateWebappBundle

* Added a debug log when peers are not ready to notify

* Updated docs

* Removed extra line
2019-08-22 15:17:47 -04:00
Gervasio Marchand
11b0a20d7d MM-16821 - Add a KVCompareAndDelete to the plugin API (#11804)
* Implement KVCompareAndDelete and KVCompareAndDeleteJSON

* Add tests for KVCompareAndDelete

* Update minimum server version

* Handle nil value on CompareAndSet so that it deletes it

* Fix comments

* Tweaks from PR comments

* Go back to deleted, err
2019-08-21 23:25:38 -03:00
Jesse Hallam
9ce52fb1da MM-16378: revert plugin health check config removal (#11819)
* revert 4e5f6fcfbc

This reverts the configuration setting to disable plugin health checks, preferring instead to retain this functionality for advanced cases. In part, this was driven by the discovery that the health checks were failing on Windows, though that will be addressed separately.

Fixes: MM-16378

* simplify interval handling/logging

Also shutdown the job when plugins are altogether disabled.
2019-08-12 18:48:02 -03:00
Jesse Hallam
1135e42ac0 MM-17488: simplify plugin health check (#11820)
Simplify the plugin health check to only leverage the `Ping` API instead of sending signals, the latter of which is not supported on Windows.
2019-08-12 18:38:25 -03:00
Ali Farooq
5ed40a48c8 MM-16872 - Extend Plugin API to set LHS bot icon (#11601)
* MM-16872 - Extend Plugin API to set LHS bot icon

* MM-16872 - Using ReadSeeker as opposed to Reader for reading svg image file

* MM-16872 - PR feedback

* MM-16872 - Using userId rather than bot.UserId

* MM-16872 - Minor stylistic changes

* MM-16872 - Removing DriverName check
2019-07-11 12:00:12 -04:00
Jesper Hansen
b464f31b38 Add progressive backoff function (#11497)
* [MM-15267] Utils: add backoff function to allow retries (#10958)

* [MM-15267] Utils: add unit test and update retry logic (#10958)

* [MM-15267] Utils: Add three retries to ProgressiveRetry (#10958)

* [MM-15267] Utils: add comments for progressive retry (#10958)

* [MM-15267] Utils: add license header to newly added file (#10958)

* [MM-15267] Utils: fix typo (#10958)

* [MM-15267] Utils: inline callback in function call (#10958)

* [MM-15267] Utils: remove type definition for backoff callback function (#10958)

* [MM-15267] Utils: use lookup table for timeout duration (#10958)

* [MM-15267] Utils: table driven unit tests for Progressive Backoff (#10958)

* [MM-15267] Utils: simplify retry function (#10958)

* [MM-15267] Utils: add assert and require packages to test file (#10958)

* [MM-15267] Utils: revert changes in go.mod and go.sum (#10958)
2019-07-10 15:59:18 -03:00
Jesse Hallam
0d05fe32af MM-16796: reduce plugin job interval to once per day (#11521)
* MM-16796: reduce plugin job interval to once per day

The Jobs infrastructure isn't currently setup for running frequent jobs,
as it spams the Jobs table with useless records. Update the plugin job
interval to run less frequently -- since the cleanup doesn't affect
semantics anyway -- and clean up the previously created entries in the Jobs table.
2019-07-05 20:11:11 -03:00
Jesse Hallam
620d941b6e MM-8602: KV Store Json helper tweaks (#11502)
* move kv helpers to helpers_kv*.go

* change KVGetJSON return signature

Return a boolean and an error, to clearly indicate if no value was found and thus no value unmarshalled into the target interface.

Also fix an issue with CompareAndSet to allow an oldValue of nil (i.e.
expected to be unset).

* add missing license

* tweak documentation

* document KVSetWithExpiryJSON minimum version
2019-07-05 17:33:39 -03:00