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 PartWhat It DoesExample
dependenciesReferences vocabulary owned by other extensions.https://runtimeconditions.io/extensions/rc/common-integrations/v1alpha2/runtimeconditions.extension.yaml
kindsDefines Condition categories.api, datastore, cache
interfaceTypesDefines valid interface types for a kind.http for api, key_value for cache
conditionFieldsDefines extension-owned fields on Conditions.configuration
interfaceFieldsDefines extension-owned fields inside interface.interface.engine, interface.operations
fieldValuesDefines allowed values for extension-owned fields.redis, memcached, GET, POST
schemasDefines 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 profileDefined byAs
kind: cacheCommon Integrationskinds
interface.type: key_valueCommon IntegrationsinterfaceTypes
interface.engine: redisCommon IntegrationsinterfaceFields and fieldValues
configurationEnvironment ConfigurationconditionFields 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.

catalog/rc/common-integrations/common-integrations-v1alpha2.yaml source
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.

catalog/rc/env-configuration/env-configuration-v1alpha2.yaml source
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.

Profile declaration and extension-owned fields
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.

ExtensionGo modulePython (PyPI)TypeScript (npm)Java (Maven Central)
common-integrations
rc/common-integrations v1alpha2
0.3.0 0.2.0 0.3.0 0.1.0
env-configuration
rc/env-configuration v1alpha2
0.3.0 0.2.0 0.3.0 0.1.0
source-control
rc/source-control 0.1.0
0.1.0 0.1.0 0.1.0 0.1.0
aws-s3
aws/s3 0.2.0
0.2.0 0.2.0 0.2.0 0.1.0
google-analytics
google/analytics 0.1.0
0.1.0 0.1.0 0.1.0 0.1.0
kubernetes-api
kubernetes/api 0.1.0
0.1.0 0.1.0 0.1.0 0.1.0
nats-service
nats/service 0.2.0
0.2.0 0.2.0 0.2.0 0.1.0
Install
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 toUseResult
Add a Condition categorykindskind: aws.object_store
Add an interface type for a kindinterfaceTypesinterface.type: aws.s3
Add a top-level Condition fieldconditionFieldsconfiguration, trust, access
Add a field inside interfaceinterfaceFieldsinterface.engine, interface.bucketClass
Define portable value choicesfieldValuesredis, standard, GET
Validate object shapeschemasRequired properties, arrays, conditional rules
Top-level field vs interface field
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.

Interface path
interfaceFields:
  - name: bucketClass
    targetKind: aws.object_store
    targetType: aws.s3

fieldValues:
  - field: interface.bucketClass
    targetKind: aws.object_store
    targetType: aws.s3
    values:
      - standard
      - archive
Condition field path with array traversal
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.

Cache engine values
fieldValues:
  - field: interface.engine
    targetKind: cache
    targetType: key_value
    values:
      - redis
      - memcached
HTTP method values
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.

HTTP API schema excerpt
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.

examples/extensions/aws-object-store/aws-object-store-v1alpha1.yaml source
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