Skip to content

Commit

Permalink
Warn users if they set remote cache and or/execution via config while…
Browse files Browse the repository at this point in the history
… the values are provided by the auth plugin. (pantsbuild#16165)

The plugin *can* provide those values, if it does, warn the user (so they can remove those from the config).

This is a user API change since it will prompt the users to remove some options from their pants config.

Context for this change: improving remote cache onboarding UX by reducing the number of options a user needs to configure in `pants.toml` in order to enable it.
  • Loading branch information
asherf authored Jul 18, 2022
1 parent c937154 commit 3d151fd
Showing 1 changed file with 10 additions and 34 deletions.
44 changes: 10 additions & 34 deletions src/python/pants/option/global_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,42 +300,18 @@ def from_options(
)
execution_headers = auth_plugin_result.execution_headers
store_headers = auth_plugin_result.store_headers
overridden_opt_log = (
"Overriding `{}` to instead be {} due to the plugin from "
"`--remote-auth-plugin`."
)
if (
auth_plugin_result.instance_name is not None
and auth_plugin_result.instance_name != instance_name
):
logger.debug(
overridden_opt_log.format(
f"--remote-instance-name={repr(instance_name)}",
repr(auth_plugin_result.instance_name),
)
)
plugin_provided_opt_log = "Setting `[GLOBAL].remote_{opt}` is not needed and will be ignored since it is provided by the auth plugin."
if auth_plugin_result.instance_name is not None:
if instance_name is not None:
logger.warning(plugin_provided_opt_log.format(opt="instance_name"))
instance_name = auth_plugin_result.instance_name
if (
auth_plugin_result.store_address is not None
and auth_plugin_result.store_address != store_address
):
logger.debug(
overridden_opt_log.format(
f"--remote-store-address={repr(store_address)}",
repr(auth_plugin_result.store_address),
)
)
if auth_plugin_result.store_address is not None:
if store_address is not None:
logger.warning(plugin_provided_opt_log.format(opt="store_address"))
store_address = auth_plugin_result.store_address
if (
auth_plugin_result.execution_address is not None
and auth_plugin_result.execution_address != execution_address
):
logger.debug(
overridden_opt_log.format(
f"--remote-execution-address={repr(execution_address)}",
repr(auth_plugin_result.execution_address),
)
)
if auth_plugin_result.execution_address is not None:
if execution_address is not None:
logger.warning(plugin_provided_opt_log.format(opt="execution_address"))
execution_address = auth_plugin_result.execution_address
opts = cls(
execution=execution,
Expand Down

0 comments on commit 3d151fd

Please sign in to comment.