Search and contents

Starting points

A configuration rarely begins from nothing. A starting point is a config skeleton for one kind of target system (an OPC UA server on a PLC, an ERP's REST interface, a PostgreSQL table of production events) with placeholders for what differs from site to site: the endpoint, the node ids, the account and its password. It is one JSON file, kept in a repository. An integrator applies it to the appliance's draft, fills in the placeholders, and the draft is checked and staged like any other. Kindred ships a small public set, and an integrator keeps their own in the repository that holds their site's configs.

Nothing about a starting point is kept on the appliance. The appliance has no library of them: it reads the file you give it, or fetches it from the configured repository when you ask, and it never commits or pushes. A starting point is not a licence and carries no tier; the format has no field for either.

The public set

Kindred's repository holds one starting point for each kind of connector a Node Type uses, under examples/starting-points/:

FileNode TypeReadsWhat it leaves for the site
plc-opcua.json PLC / Generic Device An OPC UA server The endpoint, the node to watch, the account and its password
plc-mqtt.json PLC / Generic Device An MQTT broker The broker, its CA file, the account and password, the topic filter and the payload's id field
erp-rest-polling.json ERP An ERP's REST interface, polled The base URL, the API key, the two paths and the address this Node listens on
mes-database-log.json MES A PostgreSQL table of events The server, the database, the account and password, the CA file and the table

Each is the shape of a working config for that connector with the site-specific values taken out. They are starting points and not finished configs: the field names, the mapping and the intervals are the ones the connector's own guide describes, and you will change them for your plant. Every file is checked against the current Node Types by Kindred's own tests, so one that falls behind a Node Type version fails there and not at a site.

Using one

On the configuration page, under Start from a starting point, choose the file from your laptop (Start from this file), or give a path of the configured repository and, optionally, a ref (Read it from the repository). The draft is replaced (the page asks first if there is one), and a list of places to fill in appears: each by the label the starting point gave it, with Go to it to jump to its field. A field that is open shows its label beside whether it has a value yet, and an example, when the file carries one, as the hint in the box. A credential is set with the field's own control, as any credential is: the page empties the box before the request leaves and keeps no copy. Save the draft, and when no place is open, stage it.

The draft cannot be staged or exported while a place is open. The service refuses, naming each one by its path and label, and nothing is staged:

the draft still has placeholders to fill in: config.rest.endpoint (The ERP's base URL), config.rest.api_key (The API key the ERP gave this Node)

The service counts the saved draft, so fill the places and save. The page marks a value typed and not yet saved as such. A place left empty (no value, an empty text, or null) is still open; a 0 or false is a value. A draft cannot drop a place it was started with: if the starting point offers a part you do not use, leave it out of your own copy of the file (see below) and start again, or start over with replace.

The same from a shell (BASE is the appliance's address, and the token carries configure; add sync to read the file from the repository):

# From a file on this machine:
jq '{starting_point: {document: .}}' examples/starting-points/erp-rest-polling.json \
  | curl -sS -X PUT "$BASE/v1/config/draft" -H "Authorization: Bearer $TOKEN" \
      -H 'Content-Type: application/json' --data-binary @-

# From the configured repository (add "replace": true to replace a draft):
curl -sS -X PUT "$BASE/v1/config/draft" -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"starting_point": {"ref": "main", "path": "templates/erp-rest-polling.json"}}'

Either answers with the draft and its placeholders; each has a filled flag. See Starting points in the Management API guide for the rules the routes follow: the scopes, what is refused, and what is recorded in the Activity Log.

A starting point is for one Node Type at one exact version. If the appliance runs another version the file is refused with both versions named. Update the file (see below) rather than applying it and mending the draft.

The file

A starting point is a JSON object with these fields and no others:

Field
starting_point_format 1. The format this reader reads
target_system What it is a start for, in a few words. Shown when the file is chosen
description Optional. A sentence
node_type The Node Type's name, as its definition spells it
node_type_version Its version, exactly: the check compares it with the Node Type's own
config_version The config's own version number, as in any config file (1)
placeholders The places to fill in: a list of at most 64 (below)
config The skeleton: the config section of a config file, with nothing at a placeholder's place

Each placeholder has:

Field
path Where it is, from the document's root: config.rest.endpoint, config.mqtt.subscriptions[0].topic. Keys are letters, digits, _ and -; a list position is [0]; the path ends at a key
label What a person fills it in by, up to 120 characters. It is what the page and the refusal show
kind value (a site's own value) or credential (a field the Node Type's Configuration Schema marks x-sensitive)
example Optional, for a value: a sample, shown as the hint in the box. It is also what a check fills in to prove the file still produces a valid config. Write it as JSON where it is not text. A credential never has one
{
  "starting_point_format": 1,
  "target_system": "An ERP's REST interface, polled",
  "node_type": "ERP",
  "node_type_version": "0.1.0",
  "config_version": 1,
  "placeholders": [
    {"path": "config.rest.endpoint", "label": "The ERP's base URL", "kind": "value",
     "example": "https://erp.example.test"},
    {"path": "config.rest.api_key", "label": "The API key the ERP gave this Node", "kind": "credential"}
  ],
  "config": {"rest": {"poll_path": "/data", "field_map": {"material_id": "lot_number"}}}
}

The rules a file must keep, each checked when it is applied and by the check:

  • A placeholder's place is empty in the skeleton, and the section above it is there (config.rest must exist for config.rest.endpoint). Filling a placeholder sets the key; nothing else moves.
  • No credential is in the file, in any form. Not a value, not a sample, not an encrypted value. A credential is a placeholder of kind credential at a place the Node Type marks x-sensitive, and a value placeholder may not sit at one. A field named like a credential where the schema places none is refused. The file is public by design: it is committed, uploaded from laptops and read from a repository.
  • A placeholder does not contain another, and a path is named once.
  • The Node Type and its version are exact.

engine/starting_point.py holds the reader, and STARTING_POINT_SCHEMA in it is a JSON Schema of the file for an editor or another tool. The reader is stricter than a schema can be: the places, the kinds and the examples are judged against the Node Type, which a schema file does not know.

Writing your own

Copy a file of the public set and change it, or save a working draft as a template. When a draft is a config that works, Save as a template on the page (or POST /v1/config/draft/export) turns it into a starting point: you say what it is a start for and name the places that differ from site to site, each with a path, a label and, for a value, an example. Every credential the draft holds becomes a credential placeholder, whether you name it or not, and its value is never read. The page then offers the file to download. Commit it to your repository, with the configs, under its own directory (such as templates/).

What the template leaves out is the work: the values at the places you named are taken out of the skeleton, and every other field stays as it is in the working config. Name the endpoints, hosts, ids, topics and accounts, and leave the mapping, the rules and the intervals that are the same across your sites. Applying the file and filling each placeholder gives the config again.

A credential kept by a list position cannot be a placeholder. Name the places in a list by index only where the list's length is fixed.

Keeping your templates current

A Node Type's version moves, and a template for the old one is no longer a start for anything. Check them in the same pipeline that checks your configs: check_config_repo.sh --template templates/ reads each file, checks it against the Node Type it names at its exact version, fills in its examples and runs the result through the offline check. See Checking a configuration repository in CI. A value placeholder with no example is reported, because the filled config cannot be checked without one.

Run the same check on a workstation:

python3 -m engine.starting_point_cli node-types/ templates/

Its exit codes are 0 (every file is sound), 1 (at least one is not) and 2 (the check could not run: a file or directory that cannot be read, a directory with no *.json file in it, or a Node Type directory that cannot be used). A file that can be read and is not JSON is not sound (1). The text it prints is for a person and is not a promise; it never carries a value from a file.

What it does not do

It does not keep a library of starting points on the appliance, and it does not commit or push one. It does not read a licence or a site, and the format has no field that says which a file belongs to. It does not change a draft that has no starting point, and a start over drops the placeholders a draft had. It does not check that a value you filled in is right for the plant: the usual check judges the config against the Node Type's schema, and GET /v1/status tests the connectors of the staged config.

Release: v0.11.0