Skip to content

Commit

Permalink
Merge pull request #941 from vmware/policygen-default-types
Browse files Browse the repository at this point in the history
Fix boolean default type in policygen script
  • Loading branch information
annakhm authored Aug 14, 2023
2 parents 3fdab9f + ba02ab2 commit f4192f8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion tools/policygen.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,19 @@ def get_value_for_const(attr, num=1):
if num == 0:
return value


def convert_value_to_hcl(attr_type, attr_value):
if attr_type == "string":
return "\"%s\"" % attr_value

if attr_type == "bool":
if attr_value:
return "true"
return "false"

# int and other
return attr_value

def build_schema_attr(attr):

result = ""
Expand Down Expand Up @@ -197,7 +210,7 @@ def build_schema_attr(attr):
result += "Required: true,\n"

if attr['default']:
result += "Default: %s,\n" % attr['default']
result += "Default: %s,\n" % convert_value_to_hcl(attr['type'], attr['default'])

result += "},\n"

Expand Down

0 comments on commit f4192f8

Please sign in to comment.