Skip to content

Commit

Permalink
ename check_channel_allowlist to validate_channels
Browse files Browse the repository at this point in the history
* Rename check_channel_allowlist to validate_channels to better reflect its
  purpose of validating both allowlist and denylist configurations
* Update function to return the validated channels tuple
* Update all references in code to use the new name
* Update deprecation notice in check_allowlist to reference new name
* Fix news entry formatting for consistency

Fixes conda#14405
  • Loading branch information
jezdez committed Nov 28, 2024
1 parent 1d18a93 commit 3e3c94b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions conda/base/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,7 @@ def channels(self):
raise OperationNotAllowed("Overriding channels has been disabled.")

if cli_channels:
return check_channel_allowlist(
IndexedSet((*local_channels, *cli_channels))
)
return validate_channels(IndexedSet((*local_channels, *cli_channels)))
else:
from ..exceptions import ArgumentError

Expand All @@ -976,7 +974,7 @@ def channels(self):
)
if cli_channels and not channel_in_config_files:
_warn_defaults_deprecation()
return check_channel_allowlist(
return validate_channels(
IndexedSet((*local_channels, *cli_channels, DEFAULTS_CHANNEL_NAME))
)

Expand All @@ -986,7 +984,7 @@ def channels(self):
_warn_defaults_deprecation()
channels = [DEFAULTS_CHANNEL_NAME]

return check_channel_allowlist(IndexedSet((*local_channels, *channels)))
return validate_channels(IndexedSet((*local_channels, *channels)))

@property
def config_files(self):
Expand Down Expand Up @@ -2057,12 +2055,12 @@ def locate_prefix_by_name(name, envs_dirs=None):
raise EnvironmentNameNotFound(name)


def check_channel_allowlist(channels: Iterator[str]) -> None:
def validate_channels(channels: Iterator[str]) -> None:
"""
Check if the given channel URLs are allowed by the context's allowlist
and denylist.
Validate if the given channel URLs are allowed based on the context's allowlist
and denylist configurations.
:param channels: A list of channels (either URLs or names) to check against the allowlist.
:param channels: A list of channels (either URLs or names) to validate.
:raises ChannelNotAllowed: If any URL is not in the allowlist.
:raises ChannelDenied: If any URL is in the denylist.
"""
Expand Down Expand Up @@ -2093,6 +2091,8 @@ def check_channel_allowlist(channels: Iterator[str]) -> None:
):
raise ChannelNotAllowed(channel)

return tuple(channels)


def validate_prefix_name(prefix_name: str, ctx: Context, allow_base=True) -> str:
"""Run various validations to make sure prefix_name is valid"""
Expand Down
6 changes: 3 additions & 3 deletions conda/core/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from boltons.setutils import IndexedSet

from ..base.context import check_channel_allowlist, context
from ..base.context import validate_channels, context
from ..common.io import ThreadLimitedThreadPoolExecutor, time_recorder
from ..deprecations import deprecated
from ..exceptions import (
Expand Down Expand Up @@ -42,7 +42,7 @@
@deprecated(
"25.9",
"26.3",
addendum="Use `conda.base.context.check_channel_alllowlist` instead.",
addendum="Use `conda.base.context.validate_channels` instead.",
)
def check_allowlist(channel_urls: list[str]) -> None:
"""
Expand All @@ -51,7 +51,7 @@ def check_allowlist(channel_urls: list[str]) -> None:
:raises ChannelNotAllowed: If any URL is not in the allowlist.
:raises ChannelDenied: If any URL is in the denylist.
"""
check_channel_allowlist(channel_urls)
validate_channels(channel_urls)


class Index(UserDict):
Expand Down
2 changes: 1 addition & 1 deletion news/14405-bugfix-for-denylist-channels
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Bug fixes

* Fixes a bug where the setting `denylist_channels` was not being recognized in certain cases (#14405)
* Fix a bug where the setting `denylist_channels` was not being recognized in certain cases. (#14405)

### Deprecations

Expand Down

0 comments on commit 3e3c94b

Please sign in to comment.