Skip to main content
Version: 0.14.0

Starting it

A Plugin starts as a Plugin project, which the composer makes from a template its family publishes. The project is a directory with one file at its root, yoke-plugin.yaml, which names the Plugin and says how it is built, and two directories beside it: plugin/, the Plugin's source in the language's own kind, and try/, a small application that runs it. The family's library is an ordinary dependency of the source, obtained the way the language obtains any other.

Write a Yoke Plugin — from a template to a supervised unit

Choose its identity​

A Plugin is known by a namespaced identity, such as com.example.greeter, written as a reversed domain you control followed by the Plugin's own name. The Manifest, the operator's grants and every application that runs the Plugin name it by that identity, so it is chosen once and kept across versions: a different identity is a different Plugin, and nothing granted to the old one reaches it (the Manifest).

Make the project​

yoke-compose new plugin com.example.greeter --language go

The composer obtains the family's template for its own release, checks it against the digest the release records, and writes it into greeter/, the last part of the identity, with the identity and the program's name filled in. It then makes try/ an application project for this machine and takes the Plugin into it, which builds it once: before running the build the template states, it shows the command, and it runs it because you asked for the project. In Go:

…
Taking com.example.greeter runs its author's build.
source: ..
commit: none: the source is not a git tree
in: plugin/
command: CGO_ENABLED=0 GOOS=linux GOARCH="$YOKE_GOARCH" GOFLAGS=-mod=mod go build -trimpath -o "$YOKE_OUT/greeter" .
Run it? yes (--yes)
greeter made: a Plugin project of com.example.greeter in go, and try/ an application taking it
OptionIs
--dir <d>where to make it, instead of greeter/; it must not exist
--program <p>the program's name, instead of the identity's last part

What it made​

greeter/
greeter/
├── yoke-plugin.yaml what the Plugin is, and how it is built
├── README.md
├── plugin/ the Plugin's source, and its Manifest kept beside it
│ └── com.example.greeter.yaml
├── try/ an application that runs the Plugin
│ ├── yoke.yaml
│ ├── manifests/
│ ├── components/
│ └── plugins.yaml
└── .github/workflows/manifest.yml

yoke-plugin.yaml is read by every step after this one, and only what it names is the Plugin. In Go:

greeter/yoke-plugin.yaml
plugin: 1
id: com.example.greeter
language: go
program: greeter
manifest: plugin/com.example.greeter.yaml
build:
in: plugin/
run: CGO_ENABLED=0 GOOS=linux GOARCH="$YOKE_GOARCH" GOFLAGS=-mod=mod go build -trimpath -o "$YOKE_OUT/greeter" .
architectures: [x86_64, aarch64]
FieldIs
idthe Plugin's identity, kept across versions
languageits family
programthe name of the executable the build writes
manifestwhere the Manifest is kept, in the source
build.in, build.runwhere the build runs, and the command, in the language's own idiom; it writes the program into $YOKE_OUT
architectureswhat its author builds it for

It names no version. A Plugin's version is the tag its source is published at (handing it on).

The family's library is already a dependency of plugin/, at the release that goes with your composer:

plugin/go.mod requires github.com/yoke-project/yoke-sdk-go, and plugin/main.go imports its plugin package. Go fetches it at the first build.

plugin/ holds a program that starts, says it is ready, and waits: a Plugin that declares nothing. The next page replaces it with the greeter.

Which template​

The template is the one published with the composer's own release, so a composer and the library it starts a Plugin with were released together. A composer you built from source is no release, and says so: name the release whose templates to use, or an archive you obtained yourself, which the composer reads without the network and whose digest it prints for you to check.

yoke-compose new plugin com.example.greeter --language go --release 0.14.0

A template's archive is published with its family's library, as yoke-plugin-template-<family>-<version>.tar.gz among the files of a release of github.com/yoke-project/yoke-sdk-<family>. The form above prints the address it obtained, which is the one to take for the same template; for Go at 0.14.0 it is the library's 0.8.1:

curl --proto '=https' --tlsv1.2 -sSfLO https://github.com/yoke-project/yoke-sdk-go/releases/download/v0.8.1/yoke-plugin-template-go-0.8.1.tar.gz
yoke-compose new plugin com.example.greeter --language go --template yoke-plugin-template-go-0.8.1.tar.gz

A Plugin to compare with: the repository github.com/yoke-project/yoke-reference holds a clock written as a Plugin in Go, in Rust and in Python, each built against its published library alone.

The same, by hand

Without the composer, a Plugin is a directory of the language's own kind — a Go module, a Cargo package, a Python program with its environment, a CMake project — with the family's library as a dependency. The later pages keep these paths too, at their end.

The Go family's library is the module github.com/yoke-project/yoke-sdk-go, and a Plugin imports its plugin package.

mkdir greeter && cd greeter
go mod init example.com/greeter
go get github.com/yoke-project/yoke-sdk-go@latest
greeter/
greeter/
├── go.mod
├── go.sum
└── main.go written on the next page

The versions shown are the families' newest at the time of writing. Each family is released on its own, and a newer one speaks the same contract (what each family offers).