Use this rule to control that the YAML documents do contain a required key (parameter required-key-name). Parameters can be defined as a regular expression.

Because not all documents are certainly expected to contain the indicated key, an initial "filter" key/value (the parameters parent-key-name and parent-key-value) is used to identify the documents that must be checked. Use the parameter parent-key-name-root to tell where this so-called parent key must be located in the document.

Parameters

parent-key-name
Regular expression that matches prerequisite key name
parent-key-value
Regular expression that matches the value for the prerequisite key name
parent-key-name-root
Tells if the filter parent key must be located at the root level of the document (yescode>), if itmust not be located at the root level of the document (not) or if it can be located anywhere in the document (anywhere)
required-key-name
Regular expression that matches the required key name

Examples

With parent-key-name = kind and parent-key-value = Pod and parent-key-name-root = yes and required-key-name = readinessProbe the following code snippet would PASS:

    apiVersion: v1
    kind: Pod
    metadata:
        labels:
            test: liveness
        name: liveness-http
    spec:
        containers:
            - name: liveness
              image: k8s.gcr.io/liveness
              args:
              - /server
              readinessProbe:
                  httpGet:
                      path: /healthz
                      port: 8080
                      httpHeaders:
                      - name: Custom-Header
                      value: Awesome
                  initialDelaySeconds: 3
                  periodSeconds: 3

the following code snippets would FAIL:

    apiVersion: v1
    kind: Pod
    metadata:
        labels:
            test: liveness
        name: liveness-http
    spec:
        containers:
            - name: liveness
              image: k8s.gcr.io/liveness
              args:
                  - /server
              initialDelaySeconds: 3
              periodSeconds: 3