open-cluster-management-io / policy-generator-plugin

A Kustomize generator plugin to generate Open Cluster Management policies
Apache License 2.0
29 stars 31 forks source link

Change clusterSelector type to metav1.labelSelector allowing more option to define match expression #97

Closed serngawy closed 1 year ago

openshift-ci[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: serngawy Once this PR has been reviewed and has the lgtm label, please assign willkutler for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/stolostron/policy-generator-plugin/blob/main/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

90.9% 90.9% Coverage
0.0% 0.0% Duplication

dhaiducek commented 1 year ago

@serngawy Thanks for the PR, but providing a MatchExpression direcly is already implemented in:

We did it this way using map[string]interface{} so that the old way (providing key: value pairs) would still be supported and it wouldn't be a breaking change.

Please try what you'd like to using a new version of the generator and let us know if there are gaps.

dhaiducek commented 1 year ago

/hold

serngawy commented 1 year ago

@dhaiducek Would you give example how to do it, I'm looking to have Value NotIn expression ?

dhaiducek commented 1 year ago

It looks like there's a bug with the way we're handling the deprecated placement.clusterSelectors. It works to have a PolicyGenerator manifest with:

policyDefaults:
  namespace: policies
  placement:
    clusterSelectors:
      matchExpressions:
      - key: cloud
        operator: NotIn
        values:
        - red hat

Result:

spec:
  clusterSelector:
    matchExpressions:
    - key: cloud
      operator: NotIn
      values:
      - red hat

But using clusterSelector results in an empty array:

spec:
  clusterSelector:
    matchExpressions: []

I'll work on a fix.