Skip to content

dryrun multiple ConfigurationPolicy #1640

@tomilho

Description

@tomilho

Hi all,

I have been using dryrun cmd to test policies. At the moment, I am creating Policy where there are extra dependencies, similar to what is below (I redacted many values and keys, but the idea is that we have some extra dependencies):

apiVersion: policy.open-cluster-management.io/v1
kind: Policy
name: acm-policy
spec:
  policy-templates:
  - objectDefinition:
      apiVersion: policy.open-cluster-management.io/v1
      kind: ConfigurationPolicy
      spec:
        object-templates:
        - complianceType: mustonlyhave
          metadataComplianceType: musthave
          objectDefinition:
            apiVersion: v1
            kind: Namespace
        pruneObjectBehavior: None
        remediationAction: enforce
        severity: low
  - extraDependencies:
    - apiVersion: policy.open-cluster-management.io/v1
      compliance: Compliant
      kind: ConfigurationPolicy
    objectDefinition:
      apiVersion: policy.open-cluster-management.io/v1
      kind: ConfigurationPolicy
      spec:
        object-templates-raw: |
  remediationAction: enforce

Unfortunately, the dryrun command only processes the first ConfigurationPolicy and ignores the rest which makes it rather cumbersome to use because I end up having to delete the top ConfigurationPolicy to dryrun the next one. :(

Looking at the source code, it looks to me that this is intended but I am not sure if you would be open if I create a PR to adapt the code to support extraDependencies?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions