Make compose CLI fail on unanswered questions

Is there a way to make the compose CLI fail/exit if there are questions with no answers, rather than prompting for them?

What do you mean by no answers? I would assume that if there was a question with no answer it could be blank. So if you tried to make it fail, we’d lose the use case of being able to have empty answers. We could add in some kind of required field to support both use cases.

Do you have an example rancher-compose.yml and what you expect to happen?

My use case is that I’m calling rancher-compose through a script called by a CI application, and providing an answers.txt file. I’m trying to get the script to fail if the provided answers.txt doesn’t have the answers for all of the questions in the rancher-compose.yml (i.e. the developer forgot to put the answer in the file)

rancher-compose.yml

.catalog:
  name: sample-stack
  version: 0.1.0
  description: pass
  uuid: sample-stack-1
  minimum_rancher_version: 1.0.0
  questions:
    - variable: running_env
      description: "The environment to run in"
      label: "Environment Name"
      type: string
      required: true
      default: "stage"

    - variable: port_number
      label: "Port Number"
      description: "The port to listen on"
      type: number
      required: true
      default: "8080"

.......

answers.txt

running_env: production

calling rancher-compose -e answers.txt up --upgrade -d results in a prompt for port_number. I’m wondering if there’s a way to fail instead of prompting

But in your rancher-compose.yml, you have a default value for one of your questions, so it would never fail as you always have an answer?

A default doesn’t have to be specified…

Even with the default specified, I get a prompt for the value. Tested with rancher-compose 0.7.4.

I think you’ll always get prompted for a value, but you can make an enhancement request for having this option in CLI.