Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/cfengine_cli/cfengine_wrapper/cfengine_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
)
from cfengine_cli.cfengine_wrapper.cfengine_utils import (
extract_agent_file,
has_known_hubs,
prompt_two_options,
prompt_yes_no,
require_executable,
Expand Down Expand Up @@ -249,6 +250,10 @@ def build(hub=None, non_interactive=False) -> int:
rc = build_command()
if rc != 0:
return rc
if not hub and not has_known_hubs():
# Nothing to deploy to, so don't ask. Mirrors the check cf-remote's
# deploy does (it errors with "No hub to deploy to" in this case).
return 0
if prompt_yes_no(
"Deploy the built policy set now?",
default=True,
Expand Down
5 changes: 5 additions & 0 deletions src/cfengine_cli/cfengine_wrapper/cfengine_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ def _known_hosts(role_filter=None) -> Iterator[tuple[str, list[str]]]:
yield host_id, aliases


def has_known_hubs() -> bool:
"""True if cf-remote knows about any saved/spawned hub (without connecting)."""
return any(True for _ in _known_hosts("hub"))


@lru_cache(maxsize=None)
def _host_info(host: str):
try:
Expand Down
Loading