def validate_tfvars()

in radlab-launcher/radlab.py [0:0]


def validate_tfvars(varcontents, module_name):
    keys = list(varcontents.keys())
    if keys:
        print("Variables in file:")
        print(keys)

    for key in keys:
        status = False
        try:
            with open(os.path.dirname(os.getcwd()) + '/modules/' + module_name + '/variables.tf', 'r') as myfile:
                for line in myfile:
                    if ('variable "' + key + '"' in line):
                        # print (key + ": Found")
                        status = True
                        break
        except:
            sys.exit(Fore.RED + 'variables.tf missing for module: ' + module_name)

        # Check if an invalid variable is passed! 
        if (status == False):
            sys.exit(
                Fore.RED + 'Variable: ' + key + ' passed in input file, do not exist in variables.tf file of ' + module_name + ' module.')
    # print(varcontents)
    return True