Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions cumulusci/salesforce_api/package_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class UpgradeType(StrEnum):
DEPRECATE_ONLY = "deprecate-only"
MIXED = "mixed"

class SkipHandlers(StrEnum):
FEATURE_ENFORCEMENT = "FeatureEnforcement"

class PackageInstallOptions(CCIModel):
"""Options governing installation behavior for a managed or unlocked package."""
Expand All @@ -62,6 +64,7 @@ class PackageInstallOptions(CCIModel):
security_type: SecurityType = SecurityType.FULL
apex_compile_type: Optional[ApexCompileType] = None
upgrade_type: Optional[UpgradeType] = None
skip_handlers: SkipHandlers = None

@staticmethod
def from_task_options(task_options: dict) -> "PackageInstallOptions":
Expand All @@ -86,6 +89,8 @@ def from_task_options(task_options: dict) -> "PackageInstallOptions":
)
if "upgrade_type" in task_options:
options.upgrade_type = UpgradeType(task_options["upgrade_type"])
if "skip_handlers" in task_options:
options.skip_handlers = SkipHandlers(task_options["skip_handlers"]) # allow for multiple values in the futute.
except ValueError as e:
raise TaskOptionsError(f"Invalid task options: {e}")

Expand All @@ -111,6 +116,9 @@ def from_task_options(task_options: dict) -> "PackageInstallOptions":
"upgrade_type": {
"description": "For Unlocked Package upgrades only, whether to deprecate removed components (`deprecate-only`), delete them (`delete-only`), or delete and deprecate based on safety (`mixed`). `mixed` is the default behavior."
},
"skip_handlers": {
"description": "Specifies the handlers that are skipped when the package is installed. There's only one valid value:`FeatureEnforcement`: For package installs in scratch orgs only. Available in API version 61.0 and later."
},
}

DEFAULT_PACKAGE_RETRY_OPTIONS = {
Expand Down Expand Up @@ -171,6 +179,7 @@ def _install_package_by_version_id(
"SubscriberPackageVersionKey": version_id,
"UpgradeType": options.upgrade_type,
"ApexCompileType": options.apex_compile_type,
"SkipHandlers": options.skip_handlers,
}
)
poll(functools.partial(_wait_for_package_install, tooling, request))
Expand Down
24 changes: 24 additions & 0 deletions cumulusci/salesforce_api/tests/test_package_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
PackageInstallOptions,
SecurityType,
UpgradeType,
SkipHandlers,
install_package_by_namespace_version,
install_package_by_version_id,
)
Expand Down Expand Up @@ -217,3 +218,26 @@ def test_package_install_options_from_task_options__omitting_optionals():
apex_compile_type=ApexCompileType.PACKAGE,
upgrade_type=UpgradeType.DEPRECATE_ONLY,
)

def test_package_install_options_from_task_options__with_skip_handlers():
task_options = {
"activate_remote_site_settings": "False",
"name_conflict_resolution": "RenameMetadata",
"password": "foo",
"security_type": "PUSH",
"apex_compile_type": "package",
"upgrade_type": "deprecate-only",
"skip_handlers": "FeatureEnforcement",
}

assert PackageInstallOptions.from_task_options(
task_options
) == PackageInstallOptions(
activate_remote_site_settings=False,
name_conflict_resolution=NameConflictResolution.RENAME,
password="foo",
security_type=SecurityType.PUSH,
apex_compile_type=ApexCompileType.PACKAGE,
upgrade_type=UpgradeType.DEPRECATE_ONLY,
skip_handlers=SkipHandlers.FEATURE_ENFORCEMENT,
)