what
- Add exampes and tests for validation of components with multiple hierarchical inheritance
why
-
Show that the
settings.validation
section is inherited all the way down the inheritance chain, even when using multiple abstract bae components, andatmos validate component
command executes the validation policies placed at any level of the inheritance hierarchybase-component-1
is an abstract component, and it has thesettings.validation
section defined using an OPA policybase-component-3
is an abstract component that inherits from thebase-component-1
abstract componentbase-component-4
is an abstract component that inherits from thebase-component-3
abstract component (and, by Multilevel Inheritance, from thebase-component-1
componentderived-component-3
is a real component that inherits from thebase-component-4
component (and frombase-component-3
andbase-component-1
components)
components:
terraform:
base-component-1:
metadata:
type: abstract
component: "test/test-component"
settings:
validation:
check-test-component-config-with-opa-policy:
schema_type: opa
# 'schema_path' can be an absolute path or a path relative to 'schemas.opa.base_path' defined in `atmos.yaml`
schema_path: "test-component/validate-test-component.rego"
description: Check 'test/test-component' configuration using OPA policy
vars:
service_1_name: "base-component-1-service-1"
service_2_name: "base-component-1-service-2"
base-component-3:
metadata:
type: abstract
component: "test/test-component"
inherits:
- base-component-1
vars:
service_1_name: "base-component-3-service-1"
service_2_name: "base-component-3-service-2"
base-component-4:
metadata:
type: abstract
component: "test/test-component"
inherits:
- base-component-3
vars:
service_1_name: "base-component-4-service-1"
service_2_name: "base-component-4-service-2"
derived-component-3:
metadata:
component: "test/test-component"
inherits:
- base-component-4
vars:
enabled: true
service_1_name: "bad-name"
When running the command atmos validate component derived-component-3 -s tenant1-ue2-test-1
, Atmos finds the validation
section from the inheritance chain (in base-component-1
) and outputs the following error:
Validating the component 'derived-component-3' using 'opa' file 'test-component/validate-test-component.rego'
'service_1_name' variable length must be greater than 10 chars
The settings.validation
section can be defined at any level of the inheritance chain (can be placed on base-component-1
, base-component-3
, base-component-4
or derived-component-3
, and the command atmos validate component derived-component-3 -s tenant1-ue2-test-1
finds it and outputs the same error.
The inheritance chain shown above works and produces the following final variables:
atmos describe component derived-component-3 -s tenant1-ue2-test-1
vars:
enabled: true
environment: ue2
namespace: cp
region: us-east-2
service_1_name: bad-name
service_2_name: base-component-4-service-2
stage: test-1
tenant: tenant1
references
- To test the issue described in #404