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

Use a craft-providers callback hook to set the apt proxy by an app config #493

Open
lengau opened this issue Sep 25, 2024 · 1 comment
Open
Labels
Enhancement New feature or request triaged

Comments

@lengau
Copy link
Contributor

lengau commented Sep 25, 2024

What needs to get done

In the provider service, when creating an instance, send a callback to craft-providers (see: canonical/craft-providers#665).

The default implementation of this callback should use the config service to get the app's apt_proxy configuration and use it to configure the proxy in apt. This is roughly what's done in

def _configure_apt(instance: craft_providers.Executor, net_info: NetInfo) -> None:
apt_config = f'Acquire::http::Proxy "{net_info.http_proxy}";\n'
apt_config += f'Acquire::https::Proxy "{net_info.http_proxy}";\n'
instance.push_file_io(
destination=pathlib.Path("/etc/apt/apt.conf.d/99proxy"),
content=io.BytesIO(apt_config.encode("utf-8")),
file_mode="0644",
)
instance.execute_run( # pyright: ignore[reportUnknownMemberType]
["/bin/rm", "-Rf", "/var/lib/apt/lists"],
check=True,
)
env = cast(dict[str, str | None], net_info.env)
with emit.open_stream() as fd:
instance.execute_run( # pyright: ignore[reportUnknownMemberType]
["apt", "update"], env=env, check=True, stdout=fd, stderr=fd
)

When doing this, have the fetch service use this.

Why it needs to get done

Allow apt proxies in craft apps

@lengau lengau added Enhancement New feature or request triaged labels Sep 25, 2024
Copy link

Thank you for reporting us your feedback!

The internal ticket has been created: https://warthogs.atlassian.net/browse/CRAFT-3462.

This message was autogenerated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request triaged
Projects
None yet
Development

No branches or pull requests

1 participant