Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for SkipHandlers #3802

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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 = SkipHandlers.FEATURE_ENFORCEMENT
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

±: We don't want to silently change behavior, so it shouldn't be a default. Instead, it should be an optional Option set to None.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated to 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"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭: Implementation note: The sf flag allows multiple values and combines them into a comma-separated string for PackageInstallCreateRequest. We don't need to do this here now, but we might need to if they add more SkipHandlers in the future.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment for future consideration.

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,
)
Loading