Chapter 4
Extensions give a profile its words.
A profile has a fixed shape, and extensions fill it in. An extension defines the kinds, interface types, fields, and allowed values a profile can use, and the JSON Schema that checks them.
What an extension owns
An extension is a YAML definition. These are the parts it can have, and each one is a word in a profile: cache is a kind, key_value is an interface type, and redis is a field value.
| Extension Part | What It Does | Example |
|---|---|---|
dependencies | References vocabulary owned by other extensions. | https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml |
kinds | Defines Condition categories. | api, datastore, cache |
interfaceTypes | Defines valid interface types for a kind. | http for api, key_value for cache |
conditionFields | Defines extension-owned fields on Conditions. | configuration |
interfaceFields | Defines extension-owned fields inside interface. | interface.engine, interface.operations |
fieldValues | Defines allowed values for extension-owned fields. | redis, memcached, GET, POST |
schemas | Defines machine-readable validation. | JSON Schema for HTTP API Conditions |
The extensions behind the example
The profile in Profile shape uses two extensions, and every word in it comes from one of them.
| Word in the profile | Defined by | As |
|---|---|---|
kind: cache | Common Integrations | kinds |
interface.type: key_value | Common Integrations | interfaceTypes |
interface.engine: redis | Common Integrations | interfaceFields and fieldValues |
configuration | Environment Configuration | conditionFields and fieldValues |
The two sections below show their definitions. Environment Configuration depends on Common Integrations, so a profile that uses configuration declares both, as Extension declaration shows.
First-party extension: Common Integrations
The Common Integrations extension defines standard integration vocabulary for APIs, datastores, and caches. Profiles that use kind: cache or interface.type: http depend on this extension.
metadata:
id: https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml
version: v1alpha2
spec:
kinds:
- name: api
- name: datastore
- name: cache
interfaceTypes:
- name: http
targetKind: api
- name: relational
targetKind: datastore
- name: document
targetKind: datastore
- name: key_value
targetKind: cache
- name: smtp
targetKind: api
First-party extension: Environment Configuration
The Environment Configuration extension adds the configuration field to common integration Conditions. It depends on Common Integrations and scopes its field to common-owned kinds and interface types.
spec:
dependencies:
- https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml
conditionFields:
- name: configuration
appliesToKinds:
- api
appliesToInterfaceTypes:
- http
- name: configuration
appliesToKinds:
- datastore
appliesToInterfaceTypes:
- relational
- document
- name: configuration
appliesToKinds:
- cache
appliesToInterfaceTypes:
- key_value
- name: configuration
appliesToKinds:
- api
appliesToInterfaceTypes:
- smtp
fieldValues:
- field: configuration.env[].property
targetKind: cache
targetType: key_value
values:
- url
- hostname
- port
- scheme
- username
- password
- database
- token
- tls
How a profile uses extensions
The profile declares every extension required to interpret its vocabulary. Transitive dependencies are resolved by validators and tooling, but generated profiles should still declare the vocabulary they directly use. The validator checks every word against these extensions, in the order shown under Validation order.
extensions:
- https://runtimeconditions.io/extensions/rc/common-integrations:v1alpha2
- https://runtimeconditions.io/extensions/rc/env-configuration:v1alpha2
conditions:
- name: request-cache
kind: cache # common-integrations
interface:
type: key_value # common-integrations
engine: redis # common-integrations field value
configuration: # env-configuration
alternatives:
- env:
- property: url # env-configuration field value
name: REDIS_URL
From extension to code: binding packages
An extension is a definition, and rc bindings generate turns it into packages you can import. Code to profile shows how to use them in your code.
Every first-party extension has a generated binding package in four languages. Each is built from the extension, so a declaration written against it is checked by the compiler, and each carries the resources a profiler verifies. The versions are the latest published; each name links to its registry page.
| Extension | Go module | Python (PyPI) | TypeScript (npm) | Java (Maven Central) |
|---|---|---|---|---|
common-integrationsrc/common-integrations v1alpha2 |
0.3.0 | 0.2.0 | 0.3.0 | 0.1.0 |
env-configurationrc/env-configuration v1alpha2 |
0.3.0 | 0.2.0 | 0.3.0 | 0.1.0 |
source-controlrc/source-control 0.1.0 |
0.1.0 | 0.1.0 | 0.1.0 | 0.1.0 |
aws-s3aws/s3 0.2.0 |
0.2.0 | 0.2.0 | 0.2.0 | 0.1.0 |
google-analyticsgoogle/analytics 0.1.0 |
0.1.0 | 0.1.0 | 0.1.0 | 0.1.0 |
kubernetes-apikubernetes/api 0.1.0 |
0.1.0 | 0.1.0 | 0.1.0 | 0.1.0 |
nats-servicenats/service 0.2.0 |
0.2.0 | 0.2.0 | 0.2.0 | 0.1.0 |
go get runtimeconditions.io/x/rc/common@v0.3.0
pip install runtimeconditions-common-integrations
npm install @runtimeconditions/common-integrations
The Go modules are named runtimeconditions.io/x/<extension>, the Python and npm packages runtimeconditions-<package> and @runtimeconditions/<package>, and the Java artifacts io.runtimeconditions.bindings:runtimeconditions-<package>. The source of every package is under bindings/ in the extensions repository.
Writing an extension
Everything above is how extensions are used. The rest is for writing one, whether for your own company or to share. The FAQ lists the steps, and the extension authoring guide has the rules.
Choosing vocabulary keywords
Each extension keyword answers a different authoring question. Use the smallest keyword that owns the vocabulary you are adding, then use schemas for shape.
| Author wants to | Use | Result |
|---|---|---|
| Add a Condition category | kinds | kind: aws.object_store |
| Add an interface type for a kind | interfaceTypes | interface.type: aws.s3 |
| Add a top-level Condition field | conditionFields | configuration, trust, access |
Add a field inside interface | interfaceFields | interface.engine, interface.bucketClass |
| Define portable value choices | fieldValues | redis, standard, GET |
| Validate object shape | schemas | Required properties, arrays, conditional rules |
conditionFields:
- name: configuration
appliesToKinds:
- cache
appliesToInterfaceTypes:
- key_value
interfaceFields:
- name: engine
targetKind: cache
targetType: key_value
Field paths point to owned fields
fieldValues names allowed values for a field path. It does not create the field; the path must resolve to interface.type, an interfaceFields entry, or a scoped conditionFields entry.
interfaceFields:
- name: bucketClass
targetKind: aws.object_store
targetType: aws.s3
fieldValues:
- field: interface.bucketClass
targetKind: aws.object_store
targetType: aws.s3
values:
- standard
- archive
conditionFields:
- name: configuration
appliesToKinds:
- cache
appliesToInterfaceTypes:
- key_value
fieldValues:
- field: configuration.env[].property
targetKind: cache
targetType: key_value
values:
- url
- hostname
- port
Field values make vocabulary deterministic
The extension does not merely say an engine field may exist. It also owns the shared values that validators and adapters can rely on.
fieldValues:
- field: interface.engine
targetKind: cache
targetType: key_value
values:
- redis
- memcached
fieldValues:
- field: interface.operations[].method
targetKind: api
targetType: http
values:
- GET
- HEAD
- POST
- PUT
- PATCH
- DELETE
- OPTIONS
- TRACE
Extensions define JSON Schema validation
Schema rules make extension validation portable. The validator can evaluate the profile without interpreting prose. This is the last step of Validation order.
schemas:
- id: api-http-interface
appliesToKind: api
appliesToInterfaceType: http
description: Validates HTTP API integration conditions.
schema:
type: object
required:
- kind
- interface
properties:
kind:
const: api
interface:
type: object
required:
- type
properties:
type:
const: http
operations:
type: array
items:
required:
- method
- path
Third-party extensions follow the same rules
The AWS Object Store extension is treated as a third-party example. Any company can publish one like it: see Can a company write its own catalog? It defines aws.object_store, aws.s3, S3-specific fields, and its own scoped configuration properties.
metadata:
id: https://aws.example.com/runtimeconditions/object-store/v1alpha1/runtimeconditions.extension.yaml
version: v1alpha1
spec:
kinds:
- name: aws.object_store
interfaceTypes:
- name: aws.s3
targetKind: aws.object_store
conditionFields:
- name: configuration
appliesToKinds:
- aws.object_store
appliesToInterfaceTypes:
- aws.s3