From aea69f203fd442c1dbdbb1479875f4de58d184d2 Mon Sep 17 00:00:00 2001 From: Liudmila Molkova Date: Wed, 31 Jul 2024 04:54:14 +0900 Subject: [PATCH] Add editorconfig for yaml, rego and makefile, fix rego tabs (#1286) --- .editorconfig | 16 ++++++++++++++++ policies/registry.rego | 38 +++++++++++++++++++------------------- 2 files changed, 35 insertions(+), 19 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000000..dfcc411892 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*.{yaml,yml}] +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.rego] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true +insert_final_newline = true + +[Makefile] +indent_style = tab diff --git a/policies/registry.rego b/policies/registry.rego index 1c73ef450a..cc30c75f48 100644 --- a/policies/registry.rego +++ b/policies/registry.rego @@ -6,37 +6,37 @@ package before_resolution # Helper to create attribute registry violations. attr_registry_violation(violation_id, group_id, attr_id) = violation { - violation := { - "id": violation_id, - "type": "semantic_convention_policies", - "category": "attribute_registry_checks", - "group": group_id, - "attr": attr_id, - } + violation := { + "id": violation_id, + "type": "semantic_convention_policies", + "category": "attribute_registry_checks", + "group": group_id, + "attr": attr_id, + } } # We only allow attribute groups in the attribute registry. deny[attr_registry_violation("attribute_registry_can_only_contain_attribute_groups", group.id, "")] { - group := input.groups[_] - startswith(group.id, "registry.") - group.type != "attribute_group" + group := input.groups[_] + startswith(group.id, "registry.") + group.type != "attribute_group" } # Any group that is NOT in the attribute registry that has an attribute id is # in violation of not using the attribute registry. deny[attr_registry_violation("attributes_must_be_defined_in_attribute_registry", group.id, attr.id)] { - group := input.groups[_] - not startswith(group.id, "registry.") - attr := group.attributes[_] - attr.id != null + group := input.groups[_] + not startswith(group.id, "registry.") + attr := group.attributes[_] + attr.id != null } # A registry `attribute_group` containing at least one `ref` attribute is # considered invalid if it's not in the registry group. deny[attr_registry_violation("attributes_in_registry_cannot_reference_each_other", group.id, attr.ref)] { - # TODO - this will need to be updated to support `embed` in the future. - group := input.groups[_] - startswith(group.id, "registry.") - attr := group.attributes[_] - attr.ref != null + # TODO - this will need to be updated to support `embed` in the future. + group := input.groups[_] + startswith(group.id, "registry.") + attr := group.attributes[_] + attr.ref != null }