Simple plugin to enable the /flip command inside of Mattermost

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.

Alternatively shallow clone the repository 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.

Edit the following files:

  1. plugin.json with your id, name, and description:
{
    "id": "com.example.my-plugin",
    "name": "My Plugin",
    "description": "A plugin to enhance Mattermost."
}
  1. go.mod with your Go module path, following the / / convention:
module github.com/example/my-plugin
  1. .golangci.yml with your Go module path:
linters-settings:
  # [...]
  goimports:
    local-prefixes: github.com/example/my-plugin

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

Development

To avoid having to manually install your plugin, build and deploy your plugin using one of the following options.

Deploying with Local Mode

If your Mattermost server is running locally, you can enable local mode to streamline deploying your plugin. Edit your server configuration as follows:

{
    "ServiceSettings": {
        ...
        "EnableLocalMode": true,
        "LocalModeSocketLocation": "/var/tmp/mattermost_local.socket"
    }
}

and then deploy your plugin:

make deploy

You may also customize the Unix socket path:

export MM_LOCALSOCKETPATH=/var/tmp/alternate_local.socket
make deploy

If developing a plugin with a webapp, watch for changes and deploy those automatically:

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

Deploying with credentials

Alternatively, you can authenticate with the server's API with credentials:

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

or with a personal access token:

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

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?

Setting the MM_DEBUG environment variable will invoke the debug builds. The simplist way to do this is to simply include this variable in your calls to make (e.g. make dist MM_DEBUG=1).

Similar Resources

The Webhooks Listener-Plugin library consists of two component libraries written in GoLang

The Webhooks Listener-Plugin library consists of two component libraries written in GoLang: WebHook Listener Libraries and Plugin (Event Consumer) Libraries.

Feb 3, 2022

Executor - Wrapper for exec.Command for simple using and multi commands executing

executor Examples package main import ( "fmt" "github.com/solar-jsoc/execut

Feb 12, 2022

bf.go - A dead simple brainfuck interpreter Slow and simple

bf.go - A dead simple brainfuck interpreter Slow and simple. Can execute pretty much all tested Brainfuck scripts. Installation If you have Go install

Oct 15, 2021

go-simple-geo is a library for simple geo calculations.

go-simple-geo is a library for simple geo calculations. Installation go get github.com/EpicStep/go-simple-geo Example package main import ( "github.

Dec 4, 2022

Colorize (highlight) `go build` command output

Colorize (highlight) `go build` command output

colorgo colorgo is a wrapper to go command that colorizes output from go build and go test. Installation go get -u github.com/songgao/colorgo Usage c

Dec 18, 2022

A command line tool to generate sequence diagrams

A command line tool to generate sequence diagrams

goseq - text based sequence diagrams A small command line utility used to generate UML sequence diagrams from a text-base definition file. Inspired by

Dec 22, 2022

command faker

command faker

Dec 28, 2021

Run The World. Command aggregator output. Define many services watch them in one place.

Run The World. Command aggregator output. Define many services watch them in one place.

Feb 2, 2022

Wordle - Wordle on command line

wordle Play WORDLE on the command line. Installation go install github.com/howey

May 19, 2022
Monitoring Go application inside docker container by InfluxDB, Telegraf, Grafana
Monitoring Go application inside docker container by InfluxDB, Telegraf, Grafana

REST API for TreatField app Docker compose for TIG and Golang simple app: https://github.com/tochytskyi/treatfield-api/blob/main/docker-compose.yml Gr

Nov 6, 2021
Packer Plugin Vagrant - The Vagrant multi-component plugin can be used with HashiCorp Packer to create custom images

Packer Plugin Vagrant - The Vagrant multi-component plugin can be used with HashiCorp Packer to create custom images

Jul 13, 2022
A command-line tool that triggers command when the input (doesn't) comes from STDIN in an interval.

conk A command-line tool that triggers command when the input (doesn't) comes from STDIN in an interval. Usage $ conk -h A command-line tool that trig

Apr 29, 2022
A Sonobuoy plugin to assess @crossplane conformance.

Crossplane Conformance Suite A Sonobuoy plugin to assess Crossplane conformance. To try it, first download the sonobuoy CLI, then: # The version of Cr

Jun 19, 2022
Kong Verifier plugin for HSDP API signed requests

Kong Verifier plugin for HSDP API signed requests

Jan 7, 2022
mackerel metric plugin for count lines in log

mackerel metric plugin for count lines in log

Nov 13, 2021
Steampipe plugin for the Hypothesis annotation system

Steampipe plugin for the Hypothesis annotation system

Nov 17, 2021
Rollup plugin go wasm

Rollup plugin go wasm

May 11, 2022
A helm plugin that shows a diff explaining what a helm upgrade would change
A helm plugin that shows a diff explaining what a helm upgrade would change

Helm Diff Plugin This is a Helm plugin giving your a preview of what a helm upgrade would change.

Jan 4, 2023
Traefik plugin for MaxMind GeoIP2

Traefik plugin for MaxMind GeoIP2 Traefik plugin that registers a custom middleware for getting data from MaxMind GeoIP databases and pass it downstre

Dec 19, 2021