Skip to content

Commit

Permalink
fix: config.hocon.enterprise.example for plugin and bump template file
Browse files Browse the repository at this point in the history
  • Loading branch information
JimMoen committed May 22, 2024
1 parent e2f9f86 commit 4333ab5
Show file tree
Hide file tree
Showing 8 changed files with 186 additions and 89 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ A plugin template for Elixir (experimental) can be found at https://github.com/e
## Prerequisites

+ A working build environment (eg `build_essential`) including `make`
+ Erlang OTP 25 or newer recommended
+ ASDF tool-chains recommended to manage EMQX released Erlang/OTP.
+ **MUST** use OTP 25 For docker image deployment. See also [./.tool-versions](./.tool-versions) and [EMQX Release v5.5.0](https://github.com/emqx/emqx/releases/tag/v5.5.0).
+ rebar3

## Usage
Expand All @@ -32,6 +33,8 @@ $ make -C my_emqx_plugin rel

> [!NOTE]
> In order to use the AVRO config schema feature, please make sure the plugin template tag version >= 5.7.0
> Rename files in the `./priv` directory to ensure that EMQX can load them correctly after the plugin is installed.
> See also [EMQX Documents - Plugins](https://www.emqx.io/docs/en/latest/extensions/plugins.html) for more detail.
> [!NOTE]
> If the `REBAR_CACHE_DIR` environment variable has been set, the directory for templates should be `$REBAR_CACHE_DIR/.config/rebar3/templates`.
Expand Down
1 change: 1 addition & 0 deletions README_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ An EMQX plugin release is a tar file including including a subdirectory of this

1. A JSON format metadata file describing the plugin
2. Versioned directories for all applications needed for this plugin (source and binaries).
3. Confirm the OTP version used by EMQX that the plugin will be installed on (See also [./.tool-versions](./.tool-versions)).

In a shell from this plugin's working directory execute `make rel` to have the package created like:

Expand Down
17 changes: 13 additions & 4 deletions emqx-plugin.template
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,29 @@
{description, "Another amazing EMQX plugin."},
{version, "1.0.0", "The release version of this plugin."},
{app_vsn, "0.1.0", "The erlang application vsn value."},
{emqx_vsn, "v5.4.1", "EMQX version to use as a dependency."},
{emqx_vsn, "v5.6.1", "EMQX version to use as a dependency."},
{license, "Apache-2.0", "Short identifier for license you want to distribute this plugin under."},
{author_website, "http://example.com", "A website with details about the author."},
{repo, "https://github.com/emqx/emqx-plugin-template", "Where to find the source code for this plugin."}
]}.
{dir, "{{name}}/src"}.
{dir, "{{name}}/priv"}.
{dir, "{{name}}/scripts"}.
{file, ".tool-versions", "{{name}}/.tool-versions"}.
{file, "LICENSE", "{{name}}/LICENSE"}.
{file, "Makefile", "{{name}}/Makefile"}.
{file, "erlang_ls.config", "{{name}}/erlang_ls.config"}.
{file, "get-rebar3", "{{name}}/get-rebar3"}.
{file, "priv/config.hocon", "{{name}}/priv/config.hocon"}.

{file, "priv/config.hocon.example", "{{name}}/priv/config.hocon.example"}.
{file, "priv/config_schema.avsc.enterprise.example", "{{name}}/priv/config_schema.avsc.enterprise.example"}.
{file, "priv/config_schema.avsc.example", "{{name}}/priv/config_schema.avsc.example"}.
{file, "priv/config_i18n.json.example", "{{name}}/priv/config_i18n.json.example"}.

{file, "scripts/ensure-rebar3.sh", "{{name}}/scripts/ensure-rebar3.sh"}.
{file, "scripts/get-otp-vsn.sh", "{{name}}/scripts/get-otp-vsn.sh"}.
{file, "gitignore_template", "{{name}}/.gitignore"}.
{chmod, "{{name}}/get-rebar3", 8#755}.
{chmod, "{{name}}/scripts/ensure-rebar3.sh", 8#755}.
{chmod, "{{name}}/scripts/get-otp-vsn.sh", 8#755}.
{template, "README_template.md", "{{name}}/README.md"}.
{template, "rebar_template.config", "{{name}}/rebar.config"}.
{template, "src/emqx_plugin_template.app.src", "{{name}}/src/{{name}}.app.src"}.
Expand Down
4 changes: 0 additions & 4 deletions priv/config.hocon

This file was deleted.

20 changes: 20 additions & 0 deletions priv/config.hocon.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## This is a demo config in HOCON format
## The same format used by EMQX since 5.0

hostname = "localhost"
port = 3306

connectionOptions = [
{
optionName = "autoReconnect"
optionType = "string"
optionValue = "true"
}
]

auth {
username = "admin"
password {
string = "Public123"
}
}
141 changes: 141 additions & 0 deletions priv/config_schema.avsc.enterprise.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
{
"type": "record",
"name": "ExtendedConfig",
"fields": [
{
"name": "hostname",
"type": "string",
"default": "localhost",
"$ui": {
"component": "input",
"flex": 12,
"required": true,
"label": "$hostname_label",
"description": "$hostname_desc",
"rules": [
{
"type": "pattern",
"pattern": "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$",
"message": "$hostname_validate"
}
]
}
},
{
"name": "port",
"type": "int",
"default": 3306,
"$ui": {
"component": "input-number",
"flex": 12,
"required": true,
"label": "$port_label",
"description": "$port_desc",
"rules": [
{
"type": "range",
"min": 1,
"max": 65535,
"message": "$port_range_validate"
}
]
}
},
{
"name": "connectionOptions",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "ConnectionOption",
"fields": [
{
"name": "optionName",
"type": "string"
},
{
"name": "optionValue",
"type": "string"
},
{
"name": "optionType",
"type": "string"
}
]
}
},
"default": [
{
"optionName": "autoReconnect",
"optionValue": "true",
"optionType": "boolean"
}
],
"$ui": {
"component": "maps-editor",
"flex": 24,
"items": {
"optionName": {
"label": "$option_name_label",
"description": "$option_name_desc",
"type": "string"
},
"optionValue": {
"label": "$option_value_label",
"description": "$option_value_desc",
"type": "string"
}
},
"label": "$connection_options_label",
"description": "$connection_options_desc"
}
},
{
"name": "auth",
"type": {
"type": "record",
"name": "authConfigs",
"fields": [
{
"name": "username",
"type": "string",
"$ui": {
"component": "input",
"flex": 12,
"required": true,
"label": "$username_label",
"description": "$username_desc"
}
},
{
"name": "password",
"type": [
"null",
"string"
],
"default": null,
"$ui": {
"component": "input-password",
"flex": 12,
"label": "$password_label",
"description": "$password_desc",
"rules": [
{
"type": "length",
"minLength": 8,
"maxLength": 128,
"message": "$password_length_validate"
},
{
"type": "pattern",
"pattern": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]*$",
"message": "$password_validate"
}
]
}
}
]
}
}
]
}
85 changes: 6 additions & 79 deletions priv/config_schema.avsc.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,12 @@
{
"name": "hostname",
"type": "string",
"default": "localhost",
"$ui": {
"component": "input",
"flex": 12,
"required": true,
"label": "$hostname_label",
"description": "$hostname_desc",
"rules": [
{
"type": "pattern",
"pattern": "^([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])(\\.([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9]))*$",
"message": "$hostname_validate"
}
]
}
"default": "localhost"
},
{
"name": "port",
"type": "int",
"default": 3306,
"$ui": {
"component": "input-number",
"flex": 12,
"required": true,
"label": "$port_label",
"description": "$port_desc",
"rules": [
{
"type": "range",
"min": 1,
"max": 65535,
"message": "$port_range_validate"
}
]
}
"default": 3306
},
{
"name": "connectionOptions",
Expand Down Expand Up @@ -68,27 +39,9 @@
{
"optionName": "autoReconnect",
"optionValue": "true",
"optionType": "string"
"optionType": "boolean"
}
],
"$ui": {
"component": "maps-editor",
"flex": 24,
"items": {
"optionName": {
"label": "$option_name_label",
"description": "$option_name_desc",
"type": "string"
},
"optionValue": {
"label": "$option_value_label",
"description": "$option_value_desc",
"type": "string"
}
},
"label": "$connection_options_label",
"description": "$connection_options_desc"
}
]
},
{
"name": "auth",
Expand All @@ -98,41 +51,15 @@
"fields": [
{
"name": "username",
"type": "string",
"$ui": {
"component": "input",
"flex": 12,
"required": true,
"label": "$username_label",
"description": "$username_desc"
}
"type": "string"
},
{
"name": "password",
"type": [
"null",
"string"
],
"default": null,
"$ui": {
"component": "input-password",
"flex": 12,
"label": "$password_label",
"description": "$password_desc",
"rules": [
{
"type": "length",
"minLength": 8,
"maxLength": 128,
"message": "$password_length_validate"
},
{
"type": "pattern",
"pattern": "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)[a-zA-Z\\d]*$",
"message": "$password_validate"
}
]
}
"default": null
}
]
}
Expand Down
2 changes: 1 addition & 1 deletion rebar_template.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
, {repo, "@@repo@@"}
, {functionality, ["Demo"]}
, {compatibility,
[ {emqx, "~> 5.0"}
[ {emqx, "~> 5.7"}
]}
, {description, "@@description@@"}
]
Expand Down

0 comments on commit 4333ab5

Please sign in to comment.