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

vdk-core: add option to disable version check #876

Merged
merged 2 commits into from
Jun 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ConfigKey(str, Enum):
PACKAGE_NAME = "PACKAGE_NAME"
PACKAGE_INDEX = "PACKAGE_INDEX"
VERSION_CHECK_PLUGINS = "VERSION_CHECK_PLUGINS"
VERSION_CHECK_DISABLED = "VERSION_CHECK_DISABLED"


def new_package(package_name: str, package_index: str) -> Package:
Expand All @@ -43,12 +44,25 @@ def vdk_configure(self, config_builder: ConfigurationBuilder) -> None:
default_value=True,
description="Set to true if plugins should be checked for new version otherwise false",
)
config_builder.add(
key=ConfigKey.VERSION_CHECK_DISABLED.value,
default_value=False,
description="Set to true if version check is disabled completely. "
"It might make sense for managed/cloud executions where version is controlled.",
)

@hookimpl
def vdk_exit(self, context: CoreContext) -> None:
try:
package_list = []
cfg = context.configuration
is_disabled = cfg.get_value(ConfigKey.VERSION_CHECK_DISABLED.value)
if is_disabled:
log.debug(
"VERSION_CHECK_DISABLED is set to true, skipping version check."
)
return

package_name = cfg.get_value(ConfigKey.PACKAGE_NAME.value)
package_index = cfg.get_value(ConfigKey.PACKAGE_INDEX.value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,21 @@ def test_new_version_check_error(mock_list, mock_package):
check_plugin.vdk_exit(context)

mock_package.assert_not_called()


@patch(f"{new_package.__module__}.{new_package.__name__}", autospec=True)
@patch(
f"{version.list_installed_plugins.__module__}.{version.list_installed_plugins.__name__}",
autospec=True,
)
def test_new_version_check_disabled(mock_list, mock_package):
mock_list.return_value = [("dist", "plugin")]

check_plugin = NewVersionCheckPlugin()
context = build_core_context(
check_plugin,
{new_version_check_plugin.ConfigKey.VERSION_CHECK_DISABLED.value: True},
)
check_plugin.vdk_exit(context)

mock_package.assert_not_called()