apiVersion: nfd.k8s-sigs.io/v1alpha1
kind: NodeFeatureRule
metadata:
  name: e2e-test-1
spec:
  rules:
    #
    # Simple test rules for flag features
    #
    - name: "e2e-flag-test-1"
      labels:
        e2e-flag-test-1: "true"
      vars:
        e2e-flag-test-1.not: "false"
      matchFeatures:
        - feature: "fake.flag"
          matchExpressions:
            "flag_1": {op: Exists}

    - name: "e2e-flag-test-2"
      labels:
        e2e-flag-test-2: "true"
      matchFeatures:
        - feature: "fake.flag"
          matchName: {op: In, value: ["flag_2"]}

    # Negative test not supposed to create a label
    - name: "e2e-flag-test-neg-1"
      labels:
        e2e-flag-test-neg-1: "true"
      matchFeatures:
        - feature: "fake.flag"
          matchExpressions:
            "flag_1": {op: DoesNotExist}

    - name: "e2e-flag-test-neg-2"
      labels:
        e2e-flag-test-neg-2: "true"
      matchFeatures:
        - feature: "fake.flag"
          matchName: {op: In, value: ["flag_x"]}

    #
    # Simple test rules for attribute features
    #
    - name: "e2e-attribute-test-1"
      labels:
        e2e-attribute-test-1: "true"
      vars:
        e2e-attribute-test-1.not: "false"
      matchFeatures:
        - feature: "fake.attribute"
          matchExpressions:
            "attr_1": {op: IsTrue}
            "attr_2": {op: IsFalse}

    - name: "e2e-attribute-test-2"
      labels:
        e2e-attribute-test-2: "true"
      matchFeatures:
        - feature: "fake.attribute"
          matchName: {op: In, value: ["attr_2", "attr_x"]}

    # Negative test not supposed to create a label
    - name: "e2e-attribute-test-neg-1"
      labels:
        e2e-attribute-test-neg-1: "true"
      matchFeatures:
        - feature: "fake.attribute"
          matchExpressions:
            "attr_1": {op: IsTrue}
            "attr_2": {op: IsTrue}

    - name: "e2e-attribute-test-neg-2"
      labels:
        e2e-attribute-test-neg-2: "true"
      matchFeatures:
        - feature: "fake.attribute"
          matchName: {op: In, value: ["attr_x"]}

    #
    # Simple test rules for instance features
    #
    - name: "e2e-instance-test-1"
      labels:
        e2e-instance-test-1: "true"
      vars:
        e2e-instance-test-1.not: "false"
        e2e-instance-test-1.123: "123"
      matchFeatures:
        - feature: "fake.instance"
          matchExpressions:
            "attr_1": {op: In, value: ["true"]}
            "attr_3": {op: Gt, value: ["10"]}

    - name: "e2e-instance-test-2"
      labels:
        e2e-instance-test-2: "true"
      matchFeatures:
        - feature: "fake.instance"
          matchName: {op: In, value: ["attr_1", "attr_x"]}

    # Negative test not supposed to create a label
    - name: "e2e-instance-test-neg-1"
      labels:
        e2e-instance-test-neg-1: "true"
      matchFeatures:
        - feature: "fake.instance"
          matchExpressions:
            "attr_1": {op: In, value: ["true"]}
            "attr_3": {op: Lt, value: ["10"]}

    - name: "e2e-instance-test-neg-2"
      labels:
        e2e-instance-test-neg-2: "true"
      matchFeatures:
        - feature: "fake.instance"
          matchName: {op: In, value: ["attr_x"]}
