Code Monkey home page Code Monkey logo

Comments (4)

yuumasato avatar yuumasato commented on June 12, 2024

Hi, could you tell us how have you tried to escape the < sign? Have you tried the xml way? &lt;

Regardless, there is another approach that you can take

Instead of using the jqfilter to check that the inequality deschedulingIntervalSeconds < 3600 is true.
You can do the comparison in the template:

I have not tested, but the following may work:

{{% set jqfilter = '[.spec.deschedulingIntervalSeconds]' %}}

template:
  name: yamlfile_value
  vars:
    ocp_data: "true"
    filepath: {{{ openshift_filtered_path('/apis/operator.openshift.io/v1/namespaces/openshift-kube-descheduler-operator/kubedeschedulers/cluster', jqfilter) }}}
    yamlpath: "[:]"
    check_existence: "all_exist"
    entity_check: "all"
    values:
      - value: 3600
        type: "int"
        operation: "less than"

For more info about the template's capability, check https://complianceascode.readthedocs.io/en/latest/templates/template_reference.html#yamlfile-value

from content.

ermeratos avatar ermeratos commented on June 12, 2024

I think I tried these options "<" '<' and \<

Thanks for the suggestion. The problem is that I am also checking for another key and only if both statements are true the check is compliant. This is my full jqfilter:
{{% set jqfilter = '[if (any(.spec.profiles[]; . =="LifecycleAndUtilization")) == true and ((.spec.deschedulingIntervalSeconds <= {{.kube_descheduler_interval}}) == true) then true else false end]' %}}

from content.

yuumasato avatar yuumasato commented on June 12, 2024

@ermeratos You might want to separate the two checks into their own rules; or,
if one of the checks can be considered an applicability condition for the other check, it could be made into a platform check. When the applicability check is false, the rule results is not applicable, instead of PASS/FAIL.
I'm just not sure how well the applicability check will work with jqfilters.

Did the xml escaping suggestion work for you?

from content.

ermeratos avatar ermeratos commented on June 12, 2024

I wanted to prevent the two checks from being separated. Thank you for the tip about the platform check, I might try that out.

I completely missed your info about the XML escape, otherwise I could have tested it earlier. Because it actually works with &lt;. Even &lt;= seems to be working.

from content.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.