No description
This repository has been archived on 2024-11-03. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Find a file
Ben Schumacher f5e50c1e17
Integrate GolangCI-Lint (#90)
* Use plugin orb for ci

* Add golangci-lint config and fix issues

* Simplify circleci config

* Drop unparam

* Drop maligned

* Ignore varcheck in server/manifest.go
2020-04-02 15:01:00 -03:00
.circleci Integrate GolangCI-Lint (#90) 2020-04-02 15:01:00 -03:00
assets Allow plugins to include assets in the bundle (#28) 2019-03-18 20:09:23 +01:00
build Integrate GolangCI-Lint (#90) 2020-04-02 15:01:00 -03:00
public [MM-14189] Update references to "mattermost-plugin-sample" to be… (#47) 2019-06-24 22:02:25 -04:00
server Integrate GolangCI-Lint (#90) 2020-04-02 15:01:00 -03:00
webapp Add junit.xml to gitignore (#89) 2020-03-20 09:07:35 +01:00
.editorconfig Add .editorconfig (#34) 2019-03-25 10:31:26 -04:00
.gitattributes Mark manifest.[go|js] as a generated file (#57) 2019-08-14 23:40:52 +02:00
.gitignore Remove node_modules from root .gitignore (#81) 2020-02-05 16:15:32 +01:00
.golangci.yml Integrate GolangCI-Lint (#90) 2020-04-02 15:01:00 -03:00
CHANGELOG.md initial commit 2018-07-23 13:43:22 -04:00
go.mod Bump dependencies and go version (#87) 2020-02-28 11:25:13 -05:00
go.sum Bump dependencies and go version (#87) 2020-02-28 11:25:13 -05:00
LICENSE initial commit 2018-07-23 13:43:22 -04:00
Makefile Integrate GolangCI-Lint (#90) 2020-04-02 15:01:00 -03:00
plugin.json [MM-14189] Update references to "mattermost-plugin-sample" to be… (#47) 2019-06-24 22:02:25 -04:00
README.md Allow make deploy using token (#79) 2020-02-08 10:14:26 -05:00

Plugin Starter Template CircleCI branch

This plugin serves as a starting point for writing a Mattermost plugin. Feel free to base your own plugin off this repository.

To learn more about plugins, see our plugin documentation.

Getting Started

Use GitHub's template feature to make a copy of this repository by clicking the "Use this template" button then clone outside of $GOPATH.

Alternatively shallow clone the repository to a directory outside of $GOPATH matching your plugin name:

git clone --depth 1 https://github.com/mattermost/mattermost-plugin-starter-template com.example.my-plugin

Note that this project uses Go modules. Be sure to locate the project outside of $GOPATH, or allow the use of Go modules within your $GOPATH with an export GO111MODULE=on.

Edit plugin.json with your id, name, and description:

{
    "id": "com.example.my-plugin",
    "name": "My Plugin",
    "description": "A plugin to enhance Mattermost."
}

Build your plugin:

make

This will produce a single plugin file (with support for multiple architectures) for upload to your Mattermost server:

dist/com.example.my-plugin.tar.gz

There is a build target to automate deploying and enabling the plugin to your server, but it requires login credentials:

export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_USERNAME=admin
export MM_ADMIN_PASSWORD=password
make deploy

or configuration of a personal access token:

export MM_SERVICESETTINGS_SITEURL=http://localhost:8065
export MM_ADMIN_TOKEN=j44acwd8obn78cdcx7koid4jkr
make deploy

Alternatively, if you are running your mattermost-server out of a sibling directory by the same name, use the deploy target alone to unpack the files into the right directory. You will need to restart your server and manually enable your plugin.

In production, deploy and upload your plugin via the System Console.

Q&A

How do I make a server-only or web app-only plugin?

Simply delete the server or webapp folders and remove the corresponding sections from plugin.json. The build scripts will skip the missing portions automatically.

How do I include assets in the plugin bundle?

Place them into the assets directory. To use an asset at runtime, build the path to your asset and open as a regular file:

bundlePath, err := p.API.GetBundlePath()
if err != nil {
    return errors.Wrap(err, "failed to get bundle path")
}

profileImage, err := ioutil.ReadFile(filepath.Join(bundlePath, "assets", "profile_image.png"))
if err != nil {
    return errors.Wrap(err, "failed to read profile image")
}

if appErr := p.API.SetProfileImage(userID, profileImage); appErr != nil {
    return errors.Wrap(err, "failed to set profile image")
}

How do I build the plugin with unminified JavaScript?

Use make debug-dist and make debug-deploy in place of make dist and make deploy to configure webpack to generate unminified Javascript.