Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule level message [Feature] #426

Open
1 task done
anushkamittal2001 opened this issue Jul 16, 2024 · 0 comments
Open
1 task done

Add rule level message [Feature] #426

anushkamittal2001 opened this issue Jul 16, 2024 · 0 comments
Labels
enhancement New feature or request triage Default label assigned to all new issues indicating label curation is needed to fully organize.

Comments

@anushkamittal2001
Copy link
Contributor

Problem Statement

Today we dont have a rule level message for policies:

apiVersion: json.kyverno.io/v1alpha1
kind: ValidatingPolicy
metadata:
  name: check-cost-center-tagging
  annotations:
    policies.kyverno.io/title: Ensure Cost Center tags are enabled
    policies.kyverno.io/category: OCI Best Practices
    policies.kyverno.io/severity: medium
    policies.kyverno.io/description: >-
      Ensure resources are tagged appropriately for specific purposes, which include cost management, aggregation, reporting, and bulk action.
      Reference: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformbestpractices_topic-Tagging_Resources.htm
    policies.nirmata.io/remediation-docs: "https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformbestpractices_topic-Tagging_Resources.htm"
      
spec:
  rules:
    - name: check-cost-center-tag
      match:
        all:
        - ($analyzer.resource.type): terraform-config
        - (resource.oci_identity_compartment != null): true
      assert:
        all:
        - message: Ensure Cost Center tag CostCenter are enabled.
          check:
            ~.resource:
              ~.(values(@)[].defined_tags):
                ("Operations.CostCenter" != null): true
        - message: Ensure Cost Center tag Department are enabled.
          check:
            ~.resource:
                ~.(values(@)[].freeform_tags):
                  ("Department" != null): true

Solution Description

I would suggest we have a rule level message for our policies for better understanding and UX

apiVersion: json.kyverno.io/v1alpha1
kind: ValidatingPolicy
metadata:
  name: check-cost-center-tagging
  annotations:
    policies.kyverno.io/title: Ensure Cost Center tags are enabled
    policies.kyverno.io/category: OCI Best Practices
    policies.kyverno.io/severity: medium
    policies.kyverno.io/description: >-
      Ensure resources are tagged appropriately for specific purposes, which include cost management, aggregation, reporting, and bulk action.
      Reference: https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformbestpractices_topic-Tagging_Resources.htm
    policies.nirmata.io/remediation-docs: "https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/terraformbestpractices_topic-Tagging_Resources.htm"
      
spec:
  rules:
    - name: check-cost-center-tag
      *message: Ensure cost center tags are enabled*
      match:
        all:
        - ($analyzer.resource.type): terraform-config
        - (resource.oci_identity_compartment != null): true
      assert:
        all:
        - message: Ensure Cost Center tag CostCenter are enabled.
          check:
            ~.resource:
              ~.(values(@)[].defined_tags):
                ("Operations.CostCenter" != null): true
        - message: Ensure Cost Center tag Department are enabled.
          check:
            ~.resource:
                ~.(values(@)[].freeform_tags):
                  ("Department" != null): true

Alternatives

No response

Additional Context

No response

Slack discussion

No response

Research

  • I have searched other issues in this repository and mine is not recorded.
@anushkamittal2001 anushkamittal2001 added enhancement New feature or request triage Default label assigned to all new issues indicating label curation is needed to fully organize. labels Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request triage Default label assigned to all new issues indicating label curation is needed to fully organize.
Projects
None yet
Development

No branches or pull requests

1 participant