How Can I Check If a File Has Been Uploaded?

One of the field types available in KOTS’ Config Kind is a file. This allows the end user to upload the file, and the application is able to consume the contents via our templating.

But, what if you want to check if the file is there at all? In that case you can use the eq operator to check the file against an empty string. In the example below, a label is displayed when a file is not uploaded:

apiVersion: kots.io/v1beta1
kind: Config
metadata:
  name: config-sample
spec:
  groups:
    - name: example_settings
      title: My Example Config
      description: Configuration example to show the file config
      items:
        - name: file
          title: Upload File
          help_text: upload a file
          type: file
        - name: label
          type: label
          title: File Not Uploaded
          when: repl{{ eq (ConfigOption "file") "" }}

Below is the screenshots of the rendered page when there is no file uploaded:

Below is the screenshot of the rendered page when the file has been uploaded: