Attributes
What is an Attribute?
An Attribute is a ConfigHub entity that defines a dynamic configuration property within a Space. When you create an Attribute, ConfigHub automatically registers getter and setter functions (named get-<slug> and set-<slug>) in the Space's function executor. These functions can then read and write values at specified paths within your configuration resources.
Attributes enable per-Space customization of the function registry without modifying ConfigHub's core code. They are the mechanism by which Spaces gain the ability to work with custom configuration paths beyond the built-in set.
How Attributes Work
- Define an Attribute with a slug, toolchain type, data type, and a set of resource type paths.
- ConfigHub registers functions
get-<slug>andset-<slug>in the Space's function executor. - Triggers, invocations, and other entities can reference these getter/setter functions to automate configuration management on the specified paths.
For example, creating an attribute with slug cert-secret-name for Kubernetes/YAML automatically makes get-cert-secret-name and set-cert-secret-name available as functions in that Space.
Key Concepts
ToolchainType
Specifies which toolchain the attribute applies to. Currently the primary toolchain type is Kubernetes/YAML. The toolchain type determines which resource parser and path resolution logic is used.
DataType
The data type of the attribute's value. Must be one of:
string-- text values (most common)int-- integer valuesbool-- boolean values
ResourceTypePaths
A list of entries, each corresponding to one resource type path registration. Each entry specifies:
- ResourceType: The resource type this entry applies to (e.g.,
cert-manager.io/v1/Certificate). A resource type can appear in multiple entries with different paths or invocations. - Paths: A map of configuration paths within the resource type where the attribute's value can be read or written. Each path entry includes:
Path: The path pattern (must match the map key)AttributeName: Must match the attribute's slugDataType: Must match the attribute's data typeIsNeeded(optional): Set totrueif this path represents a value the resource needs from another resource (used in needs/provides resolution)IsProvided(optional): Set totrueif this path represents a value the resource provides to other resources (used in needs/provides resolution)NeededRequired(optional): Properties a provided value must have to match this needed path. For aresource-namepath,ResourceTypenames the type it refers to.ProvidedProperties(optional): Properties this provided value offers, which needed paths match against.NeededPreferred(optional): Properties that improve a match without being required, used to choose between candidates.DefaultValue(optional): The value a defaults attribute writes at this path.
Parameters
Function parameters for the generated getter and setter functions. Each parameter has:
ParameterName: The parameter name in kebab-caseDataType: The parameter's data typeDescription: Human-readable descriptionRequired: Whether the parameter is mandatory
Parameters are required for custom attributes so that ConfigHub can register the getter and setter functions with the correct signatures. Built-in attributes (such as resource-name and container-image) do not need Parameters because their getter/setter functions are already registered by the standard executor.
Hash
A read-only SHA256 hash of the attribute's defining properties (toolchain type, data type, resource type paths, parameters). Two attributes with the same hash are functionally equivalent.
Built-in vs Custom Attributes
ConfigHub ships with several built-in attributes (such as resource-name for needs/provides dependency resolution, and container-image for container image tracking). These are registered globally and available in all Spaces.
Custom attributes extend the built-in set for specific Spaces. When a custom attribute's slug matches a built-in attribute name, the Space-level definition adds additional resource type paths without re-registering the built-in getter/setter functions.
The resource-name Attribute
The resource-name attribute is a special built-in attribute that powers ConfigHub's needs/provides dependency resolution. By adding ResourceTypePaths for custom resource types to a resource-name attribute in your Space, you can extend dependency tracking to resources that ConfigHub doesn't natively understand.
For resource-name, every path must say which resource type it names:
- A provided path (
IsProvided: true) statesProvidedPropertieswith aResourceTypematching its own resource type — that is what it offers. - A needed path (
IsNeeded: true) statesNeededRequiredwith theResourceTypeit refers to. A field that accepts more than one type lists them comma-separated, and any of them satisfies it.
That property is how a needed path is matched to a provided one. Without it a needed path would match any name of any type, so ConfigHub rejects a resource-name path that omits it.
A resource type can appear in multiple entries — for example, a RouteTable might need references to both VPC (via spec.vpcRef) and InternetGateway (via spec.routes.*.gatewayRef), each path naming the type it refers to.
For example, adding an Istio VirtualService path to resource-name would allow ConfigHub to track which Services a VirtualService references, enabling automatic dependency resolution across your service mesh configuration.
Defaults Attributes
A defaults attribute embeds default values directly in the path definitions, as each path's Details.DefaultValue. When any path carries one, ConfigHub registers three functions instead of the usual two:
get-<slug>: Returns current values at the registered paths (any type).set-<slug>: Applies the embedded default values, but only to fields that still contain placeholder values (confighubplaceholderfor strings,999999999for ints). Fields already set to real values are left untouched.vet-<slug>: Validates that current values match the expected defaults, returning validation failures for any mismatches.
The setter does not take a value parameter — the default values come from each path's Details. This makes defaults attributes useful for enforcing organizational standards (security contexts, resource requests, probe configurations) across many resources without overwriting intentional customizations.
Each path can specify a different default value and even a different type: strings, ints, and bools are all supported.
Defaults mode is detected automatically when any path in ResourceTypePaths carries a DefaultValue. The Parameters list should be empty since the setter takes no value arguments.
Examples
Each example is an Attribute definition in YAML, created with cub attribute create --filename.
Example 1: Creating a custom attribute for cert-manager Certificate secretName
Suppose you want ConfigHub to track the spec.secretName field in cert-manager Certificate resources. Create a YAML definition file:
# cert-secret-name.yaml
Slug: cert-secret-name
ToolchainType: Kubernetes/YAML
DataType: string
Description: Tracks the secretName field in cert-manager Certificate resources
ResourceTypePaths:
- ResourceType: cert-manager.io/v1/Certificate
Paths:
spec.secretName:
Path: spec.secretName
AttributeName: cert-secret-name
DataType: string
Parameters:
- ParameterName: secret-name
Required: true
Description: Name of the TLS secret
DataType: string
Create the attribute:
cub attribute create --space my-space --filename cert-secret-name.yaml
After creation, the functions get-cert-secret-name and set-cert-secret-name are available in the Space. You can use them in triggers or invoke them directly.
Example 2: Adding resource-name paths for Istio VirtualService
To extend ConfigHub's needs/provides dependency resolution to Istio VirtualService resources, create an attribute that registers paths where service references appear:
# istio-resource-name.yaml
Slug: resource-name
ToolchainType: Kubernetes/YAML
DataType: string
Description: Extends resource-name tracking to Istio VirtualService
ResourceTypePaths:
# VirtualService needs Service references via destination.host
- ResourceType: networking.istio.io/v1/VirtualService
Paths:
spec.http.*.route.*.destination.host:
Path: spec.http.*.route.*.destination.host
AttributeName: resource-name
DataType: string
Details:
IsNeeded: true
NeededRequired:
ResourceType: v1/Service
cub attribute create --space my-space --filename istio-resource-name.yaml
Now ConfigHub can automatically detect which Services an Istio VirtualService references, enabling dependency-aware operations like sequenced rollouts.
Note: For
resource-nameattributes, every path must say which resource type it names: a needed path (IsNeeded: true) statesNeededRequired.ResourceType, and a provided one (IsProvided: true) statesProvidedProperties.ResourceType. That property is what matches a needed path to a provided one, so ConfigHub rejects aresource-namepath that omits it. The same resource type can appear in several entries, each naming what it refers to. See the AWS ACK example below for a complete multi-resource-type configuration.
Example 3: Extending container-image to a custom CRD
If you have a custom CRD (e.g., MLModel/ml.example.com/v1) with a container image field, extend the container-image attribute:
# ml-container-image.yaml
Slug: container-image
ToolchainType: Kubernetes/YAML
DataType: string
Description: Extends container-image tracking to MLModel CRD
ResourceTypePaths:
- ResourceType: ml.example.com/v1/MLModel
Paths:
spec.serving.image:
Path: spec.serving.image
AttributeName: container-image
DataType: string
Parameters:
- ParameterName: container-name
Required: true
Description: Name of the container whose image to set
DataType: string
- ParameterName: container-image
Required: true
Description: Full container image
DataType: string
cub attribute create --space my-space --filename ml-container-image.yaml
Example 4: AWS ACK resource-name with multiple resource types
This example demonstrates a complete resource-name attribute for AWS ACK custom resources, showing how a single attribute can register needs/provides paths across multiple resource types. Each resource type can appear multiple times when it references different upstream resource types.
Slug: resource-name
ToolchainType: Kubernetes/YAML
DataType: string
ResourceTypePaths:
# VPC provides metadata.name
- ResourceType: services.k8s.aws/v1alpha1/VPC
Paths:
metadata.name:
Path: metadata.name
AttributeName: resource-name
DataType: string
Details:
IsProvided: true
ProvidedProperties:
ResourceType: services.k8s.aws/v1alpha1/VPC
# Subnet provides metadata.name
- ResourceType: services.k8s.aws/v1alpha1/Subnet
Paths:
metadata.name:
Path: metadata.name
AttributeName: resource-name
DataType: string
Details:
IsProvided: true
ProvidedProperties:
ResourceType: services.k8s.aws/v1alpha1/Subnet
# Subnet needs VPC references
- ResourceType: services.k8s.aws/v1alpha1/Subnet
Paths:
spec.vpcRef.from.name:
Path: spec.vpcRef.from.name
AttributeName: resource-name
DataType: string
Details:
IsNeeded: true
NeededRequired:
ResourceType: services.k8s.aws/v1alpha1/VPC
# Subnet needs RouteTable references
- ResourceType: services.k8s.aws/v1alpha1/Subnet
Paths:
spec.routeTableRefs.*.from.name:
Path: spec.routeTableRefs.*.from.name
AttributeName: resource-name
DataType: string
Details:
IsNeeded: true
NeededRequired:
ResourceType: services.k8s.aws/v1alpha1/RouteTable
cub attribute create --space my-space --from-stdin resource-name Kubernetes/YAML string < ack-resource-name.yaml
With this attribute, linking a Subnet unit to a VPC unit with --update-type NeedsProvides --auto-update will automatically resolve spec.vpcRef.from.name to the VPC's metadata.name.
Example 5: Defaults attribute for container resource requests
A defaults attribute embeds default values directly in the path definitions, as each path's DefaultValue. ConfigHub applies these defaults only to fields that still contain placeholder values, leaving intentionally configured values untouched.
# resource-defaults.yaml
Slug: resource-defaults
ToolchainType: Kubernetes/YAML
DataType: string
Description: Default CPU and memory requests for containers
ResourceTypePaths:
- ResourceType: apps/v1/Deployment
Paths:
spec.template.spec.containers.*.resources.requests.cpu:
Path: spec.template.spec.containers.*.resources.requests.cpu
AttributeName: resource-defaults
DataType: string
Details:
DefaultValue: "100m"
spec.template.spec.containers.*.resources.requests.memory:
Path: spec.template.spec.containers.*.resources.requests.memory
AttributeName: resource-defaults
DataType: string
Details:
DefaultValue: "128Mi"
cub attribute create --space my-space --from-stdin resource-defaults Kubernetes/YAML string < resource-defaults.yaml
This registers three functions:
get-resource-defaults— reads current values at all registered pathsset-resource-defaults— applies defaults only where placeholders existvet-resource-defaults— validates that current values match the expected defaults
The set-resource-defaults function takes no value arguments. To apply defaults to a unit:
cub function set --space my-space --where "Slug = 'my-deploy'" set-resource-defaults
Relationship to Other Entities
- Spaces: Attributes are scoped to a Space. Each Space has its own set of registered attributes.
- Triggers: Triggers can invoke the getter/setter functions created by attributes.
- Invocations: Custom getter/setter invocations can reference existing invocations for more complex attribute behavior.
- Functions: Attributes generate functions in the Space's function executor that can be called during configuration processing.