Skip to content

Commit

Permalink
Explicitly set up Galaxy context instead of relying on deprecated fun…
Browse files Browse the repository at this point in the history
…ctionality.
  • Loading branch information
felixfontein committed Dec 24, 2023
1 parent 66f020d commit 535868b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/234-galaxy-context.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- "Explicitly set up Galaxy context instead of relying on deprecated functionality (https://github.com/ansible-community/antsibull-docs/pull/234)."
5 changes: 3 additions & 2 deletions src/antsibull_docs/cli/doc_commands/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import aiohttp
import asyncio_pool # type: ignore[import]
from antsibull_core.collections import install_together
from antsibull_core.galaxy import CollectionDownloader
from antsibull_core.galaxy import CollectionDownloader, GalaxyContext
from antsibull_core.logging import log
from antsibull_core.venv import FakeVenvRunner

Expand Down Expand Up @@ -77,11 +77,12 @@ async def retrieve(

lib_ctx = app_context.lib_ctx.get()
async with aiohttp.ClientSession() as aio_session:
context = await GalaxyContext.create(aio_session, galaxy_server=galaxy_server)
async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool:
downloader = CollectionDownloader(
aio_session,
collection_dir,
galaxy_server=galaxy_server,
context=context,
collection_cache=collection_cache,
)
for collection in collections:
Expand Down
5 changes: 3 additions & 2 deletions src/antsibull_docs/cli/doc_commands/devel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from antsibull_core.ansible_core import get_ansible_core
from antsibull_core.collections import install_together
from antsibull_core.dependency_files import parse_pieces_file
from antsibull_core.galaxy import CollectionDownloader, DownloadResults
from antsibull_core.galaxy import CollectionDownloader, DownloadResults, GalaxyContext
from antsibull_core.logging import log
from antsibull_core.venv import FakeVenvRunner, VenvRunner

Expand Down Expand Up @@ -59,6 +59,7 @@ async def retrieve(

lib_ctx = app_context.lib_ctx.get()
async with aiohttp.ClientSession() as aio_session:
context = await GalaxyContext.create(aio_session, galaxy_server=galaxy_server)
async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool:
if not use_installed_ansible_core:
requestors["_ansible_core"] = await pool.spawn(
Expand All @@ -73,7 +74,7 @@ async def retrieve(
downloader = CollectionDownloader(
aio_session,
collection_dir,
galaxy_server=galaxy_server,
context=context,
collection_cache=collection_cache,
)
for collection in collections:
Expand Down
5 changes: 3 additions & 2 deletions src/antsibull_docs/cli/doc_commands/stable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from antsibull_core.ansible_core import get_ansible_core
from antsibull_core.collections import install_together
from antsibull_core.dependency_files import DepsFile
from antsibull_core.galaxy import CollectionDownloader
from antsibull_core.galaxy import CollectionDownloader, GalaxyContext
from antsibull_core.logging import log
from antsibull_core.venv import FakeVenvRunner, VenvRunner

Expand Down Expand Up @@ -62,6 +62,7 @@ async def retrieve(

lib_ctx = app_context.lib_ctx.get()
async with aiohttp.ClientSession() as aio_session:
context = await GalaxyContext.create(aio_session, galaxy_server=galaxy_server)
async with asyncio_pool.AioPool(size=lib_ctx.thread_max) as pool:
if not use_installed_ansible_core:
requestors["_ansible_core"] = await pool.spawn(
Expand All @@ -76,7 +77,7 @@ async def retrieve(
downloader = CollectionDownloader(
aio_session,
collection_dir,
galaxy_server=galaxy_server,
context=context,
collection_cache=collection_cache,
)
for collection, version in collections.items():
Expand Down

0 comments on commit 535868b

Please sign in to comment.