in tools/utils.py [0:0]
def print_tf_ali_ros_mapping(ros_types=None):
alicloud_local = os.getenv("TERRAFORM_PROVIDER_ALICLOUD")
if not alicloud_local:
return {}
tf_types = set()
path = os.path.join(alicloud_local, "alicloud")
pattern = re.compile(r"resource_(alicloud_[\w\W]+).go$")
for filename in os.listdir(path):
result = pattern.match(filename)
if result:
tf_type = result.group(1)
if not tf_type.endswith("_test"):
tf_types.add(tf_type)
if not ros_types:
ros_types = list_ros_types()
ros_types = set(ros_types)
mapping = TF_ALI_ROS_GENERATE_MAPPINGS.copy()
for tf_type in tf_types:
if tf_type in mapping:
continue
partial_tf_type = tf_type.replace("alicloud_", "")
index = partial_tf_type.find("_")
if not index:
continue
tf_prod = partial_tf_type[:index]
ros_prod = TF_ALI_ROS_PROD_MAPPINGS.get(tf_prod) or tf_prod.upper()
ros_type = "ALIYUN::{}::{}".format(
ros_prod, snake_to_camel(partial_tf_type[index + 1 :])
)
if ros_type not in ros_types:
mapping[tf_type] = None
else:
mapping[tf_type] = ros_type
_print_mapping_orderly(mapping)