Plugins
n5i's app system is designed to be extended. A plugin is a gRPC service that runs in a container of an app and implements one of the plugin interfaces below. You can write it in any language that has gRPC support.
Plugin types
| Type | type value | What it does |
|---|---|---|
| Context plugin | context | Provides data to other apps when their templates are rendered, for example credentials it created for them. |
| Custom resource plugin | custom-resource | Provides new kinds of resources that other apps can declare in app.yml, for example Tor onion services. |
| Ingress plugin | ingress | Provides new ways to expose apps, for example as Tor onion services. |
| Runtime plugin | runtime | Parses and runs apps in other formats. |
| Source plugin | source | Adds new app store formats. |
| DNS provider plugin | dns-provider | Lets n5i manage DNS records for certificates and domain verification with a DNS provider. |
Declaring a plugin
Plugins are declared on the container that serves them, in the app's app.yml:
containers:
plugin:
image: registry.example.com/my-plugin:1.0.0
plugins:
info:
type: context
display_name: My app integration
port: 50051
# path: / # optionalThe plugin is identified as <app>-plugin-<plugin id>, here my-app-plugin-info for an app my-app. Other apps refer to it by the app ID and plugin ID, for example in permissions (my-app/<permission>) and plugin resources (my-app: info: ...).
n5i connects to the plugin over plain (unencrypted) HTTP/2 inside the cluster. Apps that contain plugins get the builtin/root permission, so only admins can install them, and they can't be installed more than once.
Protocol definitions
The gRPC services are defined in the shared/plugin-proto/protos directory of the backend. All of them are in the package n5i_plugin and share the types in common.proto (UserState, AppInfo, Setting, Permission, ...).
For Rust, the generated code is published as the n5i-plugin-proto crate, and n5i-plugin-common has helpers for writing plugins. The plugins in the backend's plugins directory are complete examples.
Shared types
message AppInfo {
optional string primary_domain = 1;
optional string json_settings = 2;
AppScope scope = 3;
map<string, string> component_primary_domains = 4;
}
message UserState {
string user_id = 1;
string user_display_name = 4;
// App ID -> information about the installed app
map<string, AppInfo> installed_apps = 5;
}