Skip to content

Commit

Permalink
fallback for missing alias in network connection
Browse files Browse the repository at this point in the history
  • Loading branch information
lexastr committed May 7, 2024
1 parent cc8869e commit 7876e63
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Yellowbox Changelog
## NEXT
### Changed
* connecting container to network now has a fallback if `Alias` field is empty to `DNSNames`
### Removed
* dropped support for python 3.7
### Added
Expand Down
3 changes: 2 additions & 1 deletion yellowbox/containers.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def get_ports(container: Container) -> Dict[int, int]:
def get_aliases(container: Container, network: Union[str, Network]) -> Sequence[str]:
if not isinstance(network, str):
network = network.name
return container.attrs["NetworkSettings"]["Networks"][network]["Aliases"]
aliases = container.attrs["NetworkSettings"]["Networks"][network]["Aliases"]
return aliases if aliases else container.attrs["NetworkSettings"]["Networks"][network]["DNSNames"]


def short_id(container: Container) -> str:
Expand Down

0 comments on commit 7876e63

Please sign in to comment.