'How to validate variables in ducttape files?

I have two ducttape files: globals.tape and myfile.tape and I am importing globals.tape in myfile.tape as shown below:

globals.tape

global {
    ducttape_experimental_imports=enable
    ducttape_experimental_packages=true

    num_days=(NumDays: 1="1" 2="2")
}

myfile.tape

import "../tapes/globals.tape"
plan planA {
    reach do_some_task via (NumDays: 5)
}

Since NumDays can only take values 1 and 2, I want to add a validation step which will make sure that NumDays always take one of the available/valid values.

How do I do the validation? For example, is there any parsing tool that loads all imported tape files and checks if the variables resolve correctly? Alternatively, is there any ducttape API that can be used to do the validation?



Solution 1:[1]

I recommend just adding a task that does the validation directly in bash. You can make the task that consumes those params depend on that task.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jhclark