From 897ebbb92d37f13d8a0f710af5bf2001d48ad50d Mon Sep 17 00:00:00 2001 From: Bryan Leboff Date: Wed, 15 May 2024 11:13:38 -0400 Subject: [PATCH] add installation key if one is provided --- cumulusci/core/config/org_config.py | 23 +++++++++++++-------- cumulusci/core/dependencies/dependencies.py | 2 +- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/cumulusci/core/config/org_config.py b/cumulusci/core/config/org_config.py index b7d6f1505a..0783ba3df9 100644 --- a/cumulusci/core/config/org_config.py +++ b/cumulusci/core/config/org_config.py @@ -307,24 +307,29 @@ def has_minimum_package_version(self, package_identifier, version_identifier): ) return installed_version[0].number >= version_identifier - - def get_package_from_version(self, package_version_id): - """Fetch and return the package details based on a provided package version ID. + + def get_package_from_version(self, package_version_id, installationkey=None): + """Fetch and return the package details based on a provided package version ID. Find the SubscriberPackageVersion for the 04t Id provided in package_version_id If no package is found return None. If a package is found return the first record (assuming that the query will only return one record for a specific Id).""" - query = ("tooling/query/?q=SELECT Id, SubscriberPackageId, MajorVersion, " - "MinorVersion, PatchVersion, BuildNumber from SubscriberPackageVersion " - f"WHERE Id = '{package_version_id}'") + query = ( + "tooling/query/?q=SELECT Id, SubscriberPackageId, MajorVersion, " + "MinorVersion, PatchVersion, BuildNumber from SubscriberPackageVersion " + f"WHERE Id = '{package_version_id}'" + ) + if installationkey: + query += f" AND InstallationKey = '{installationkey}'" + response = self.salesforce_client.restful(query) - + if not response or "records" not in response or not response["records"]: return None - + package = response["records"][0] return package - + @property def installed_packages(self): """installed_packages is a dict mapping a namespace or package Id (033*) to the installed package diff --git a/cumulusci/core/dependencies/dependencies.py b/cumulusci/core/dependencies/dependencies.py index bb09e94b8a..c987eb0ad7 100644 --- a/cumulusci/core/dependencies/dependencies.py +++ b/cumulusci/core/dependencies/dependencies.py @@ -519,7 +519,7 @@ def install( ) return - package = org.get_package_from_version(self.version_id) + package = org.get_package_from_version(self.version_id, options.password) if package: package_id = package["SubscriberPackageId"]