Skip to content

Commit 429ebe8

Browse files
authored
Merge pull request #912 from tableau/pv/taco-version-name
Packaged tacos have version in file name
2 parents 6c6bcf8 + 1a51e52 commit 429ebe8

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed

connector-packager/connector_packager/package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ def main():
125125
return
126126

127127
package_dest_path = Path(args.dest)
128-
package_name = xmlparser.class_name + PACKAGED_EXTENSION
128+
package_name = xmlparser.class_name + "-v" + xmlparser.connector_version + PACKAGED_EXTENSION
129129

130130
if not jdk_create_jar(path_from_args, files_to_package, package_name, package_dest_path):
131131
logger.info("Taco packaging failed. Check " + str(log_file) + " for more information.")

connector-packager/connector_packager/xml_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, path_to_folder: Path):
3939
self.class_name = None # Get this from the class name in the manifest file
4040
self.file_list = [] # list of files to package
4141
self.loc_strings = [] # list of loc strings so we can make sure they are covered in the resource files.
42+
self.connector_version = None # Get ths from the plugin-version attribute in the manifest
4243
self.null_oauth_config_found = False # whether or not we found a null oauth config
4344
self.num_oauth_configs_found = 0 # number of oauth configs found, so we can fail the connector if there are non-null cconfigs and a null config
4445

@@ -245,6 +246,11 @@ def parse_file(self, file_to_parse: ConnectorFile) -> bool:
245246
file_to_parse.file_name)
246247
return False
247248

249+
# Set the connector version
250+
if 'plugin-version' in child.attrib:
251+
logging.debug("Found connector version: " + child.attrib['plugin-version'])
252+
self.connector_version = child.attrib['plugin-version']
253+
248254
# If an attribute has @string, then add that string to the loc_strings list.
249255
for key, value in child.attrib.items():
250256
if value.startswith(TRANSLATABLE_STRING_PREFIX):

connector-packager/tests/test_package.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class TestPackage(unittest.TestCase):
1313

1414
def test_package_main(self):
1515

16-
expected_package_name = "postgres_odbc"
16+
expected_package_name = "postgres_odbc-v0.0.0"
1717
expected_dest_directory = Path("tests/test_resources/jars")
1818
files_directory = Path("tests/test_resources/valid_connector")
1919

connector-packager/tests/test_xml_parser.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def test_generate_file_list(self):
1313

1414
# Test valid connector
1515
expected_class_name = "postgres_odbc"
16+
expected_connector_version = "0.0.0"
1617
expected_file_list = [
1718
ConnectorFile("manifest.xml", "manifest"),
1819
ConnectorFile("connection-dialog.tcd", "connection-dialog"),
@@ -21,40 +22,43 @@ def test_generate_file_list(self):
2122
ConnectorFile("connectionResolver.tdr", "connection-resolver"),
2223
ConnectorFile("resources-en_US.xml", "resource")]
2324

24-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("valid_connector"),
25+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("valid_connector"),
2526
expected_file_list, expected_class_name)
2627

2728
self.assertTrue(actual_file_list, "Valid connector did not return a file list")
2829
self.assertTrue(sorted(actual_file_list) == sorted(expected_file_list),
2930
"Actual file list does not match expected for valid connector")
3031
self.assertTrue(actual_class_name == expected_class_name,
3132
"Actual class name does not match expected for valid connector")
33+
self.assertTrue(actual_connector_version == expected_connector_version,
34+
"Actual connector version does not match expected for valid connector")
3235

3336
print("\nTest invalid connector. Throws XML validation error.")
3437

35-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("broken_xml"),
38+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("broken_xml"),
3639
expected_file_list, expected_class_name)
3740
self.assertFalse(actual_file_list, "Invalid connector returned a file list when it should not have")
3841

3942
print("\nTest connector with class name mismatch. Throws XML validation error.")
40-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("wrong_class"),
43+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("wrong_class"),
4144
expected_file_list, expected_class_name)
4245
self.assertFalse(actual_file_list, "Connector with class name mismatch returned a file list when it shouldn't")
4346

4447
# Test connector with non-https url
45-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("non_https"),
48+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("non_https"),
4649
expected_file_list, expected_class_name)
4750
self.assertFalse(actual_file_list, "Connector with non-https urls returned a file list when it shouldn't")
48-
49-
# Test connector with missing English translation
50-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("missing_english_translation"),
51+
52+
# Test connector with missing English transaltion
53+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("missing_english_translation"),
5154
expected_file_list, expected_class_name)
5255
self.assertFalse(actual_file_list, "Connector with localized strings but without a resources-en_US.xml file "
5356
"returned a file list when it shouldn't")
5457

5558
def test_generate_file_list_mcd(self):
5659
# Test modular dialog connector
5760
expected_class_name = "postgres_mcd"
61+
expected_connector_version = "0.0.1"
5862
expected_file_list = [
5963
ConnectorFile("manifest.xml", "manifest"),
6064
ConnectorFile("connectionFields.xml", "connection-fields"),
@@ -64,18 +68,21 @@ def test_generate_file_list_mcd(self):
6468
ConnectorFile("connectionResolver.xml", "connection-resolver"),
6569
ConnectorFile("connectionProperties.js", "script")]
6670

67-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("modular_dialog_connector"),
71+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("modular_dialog_connector"),
6872
expected_file_list, expected_class_name)
6973

7074
self.assertTrue(actual_file_list, "Valid connector did not return a file list")
7175
self.assertTrue(sorted(actual_file_list) == sorted(expected_file_list),
7276
"Actual file list does not match expected for valid connector")
7377
self.assertTrue(actual_class_name == expected_class_name,
7478
"Actual class name does not match expected for valid connector")
79+
self.assertTrue(actual_connector_version == expected_connector_version,
80+
"Actual connector version does not match expected for valid connector")
7581

7682
def test_generate_file_list_oauth(self):
7783
# Test oauth connector
7884
expected_class_name = "test_oauth"
85+
expected_connector_version = "0.0.1"
7986
expected_file_list = [
8087
ConnectorFile("manifest.xml", "manifest"),
8188
ConnectorFile("connectionFields.xml", "connection-fields"),
@@ -86,20 +93,23 @@ def test_generate_file_list_oauth(self):
8693
ConnectorFile("connectionResolver.xml", "connection-resolver"),
8794
ConnectorFile("connectionProperties.js", "script")]
8895

89-
actual_file_list, actual_class_name = self.parser_test_case(TEST_FOLDER / Path("oauth_connector"),
96+
actual_file_list, actual_class_name, actual_connector_version = self.parser_test_case(TEST_FOLDER / Path("oauth_connector"),
9097
expected_file_list, expected_class_name)
9198

9299
self.assertTrue(actual_file_list, "Valid connector did not return a file list")
93100
self.assertTrue(sorted(actual_file_list) == sorted(expected_file_list),
94101
"Actual file list does not match expected for valid connector")
95102
self.assertTrue(actual_class_name == expected_class_name,
96103
"Actual class name does not match expected for valid connector")
104+
self.assertTrue(actual_connector_version == expected_connector_version,
105+
"Actual connector version does not match expected for valid connector")
97106

98107
def parser_test_case(self, test_folder, expected_file_list, expected_class_name):
99108

100109
xml_parser = XMLParser(test_folder)
101110

102111
actual_file_list = xml_parser.generate_file_list()
103112
actual_class_name = xml_parser.class_name
113+
actual_connector_version = xml_parser.connector_version
104114

105-
return actual_file_list, actual_class_name
115+
return actual_file_list, actual_class_name, actual_connector_version

0 commit comments

Comments
 (0)