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)- GetterInvocation (optional): A custom function invocation for reading the attribute value. Required for
resource-nameentries with provided paths (IsProvided: true), where it must useget-resources-of-typewith aresource-typeargument. - SetterInvocation (optional): A custom function invocation for writing the attribute value. Required for
resource-nameentries with needed paths (IsNeeded: true), where it must useset-references-of-typewith aresource-typeargument.
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, each ResourceTypePaths entry must specify:
- For entries with provided paths (
IsProvided: true): AGetterInvocationusingget-resources-of-typewith aresource-typeargument matching the entry's resource type. - For entries with needed paths (
IsNeeded: true): ASetterInvocationusingset-references-of-typewith aresource-typeargument identifying the resource type that provides the referenced value.
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 requiring a separate entry with its own SetterInvocation.
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 uses the special $visitor setter invocation to embed default values directly in the path definitions. When a path's Details.SetterInvocations uses $visitor with a value argument, 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 the $visitor arguments in 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, since the $visitor setter works with strings, ints, and bools.
Defaults mode is detected automatically when any path in ResourceTypePaths has Details.SetterInvocations containing a $visitor invocation. The Parameters list should be empty since the setter takes no value arguments.
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.