Fix/output parent dir and oerpc noise - #1
Closed
stephansainleger wants to merge 3 commits into
Closed
stephansainleger wants to merge 3 commits into
stephansainleger wants to merge 3 commits into
Conversation
An Odoo user who just wants ``ssh some-machine`` to work had to install a
Python package, learn the right ``uv`` verb, and assemble a command with
four flags — all to run something they touch a few times a year.
``scripts/odoo-get-ssh-config`` does it on a machine that has nothing: it
checks for ``uv`` (whose installer needs no root) and the ``git`` that
fetching from a git reference requires, offers to install what is
missing, asks once for the Odoo server, database, login and bastion
address, saves them to the config file ``warpgate-man`` already reads,
and delegates to the published package through ``uvx``. It never runs
from a checkout, and introduces no config format of its own.
stdout carries the ssh config and nothing else, so
``odoo-get-ssh-config > ~/.ssh/config.d/warpgate`` produces a usable
file: every prompt and progress line goes to stderr, and prompts are read
from ``/dev/tty`` so that redirection stays interactive. A stray line on
stdout would corrupt the result, and ``ssh`` rejects a whole config over
one bad line.
Two details worth keeping:
- ``has_tty`` tests by OPENING ``/dev/tty``, not by ``[ -r ]``. In a
container the node exists yet opening it fails with ENXIO, and a
stat-based check would print a prompt nobody can answer.
- Piped to an interpreter (``curl ... | bash``), ``$0`` is the shell, so
a naive script calls itself ``bash`` and tells the reader to run
``bash > ~/.ssh/...``. It recognises itself instead.
The generated config declares no ``api-key`` and omits ``db`` when the
answer is left empty — the two fields just made optional — and never
stores the password: it emits a ``${ODOO_PASSWORD}`` reference and
supplies the variable for that run only. Written ``0600``.
Tests are ``sunit`` (``bin/test-sh``), since pytest cannot cover a script
whose whole point is running before the package is installed. The
fixtures put the sandbox on a CLOSED ``$PATH``: keeping ``/usr/bin``
would leave the real ``git`` visible behind the fake, and a "missing
tool" test would silently exercise the present-tool path and pass for
the wrong reason. Each behaviour was confirmed by breaking it — stdout
pollution, a stored password, a world-readable config, a swallowed
failure, a removed consent prompt, and the ``$0`` fallback all make a
test fail.
Assisted-by: Claude:claude-opus-5
The documented usage writes to ``~/.ssh/config.d/warpgate``, a directory that does not exist on a fresh machine. ``open(path, "w")`` does not create parent directories, so the command died with ``FileNotFoundError`` right after authenticating. Mirror the ``mkdir -p`` already done by ``scripts/odoo-get-ssh-config`` for its own config, so ``--output`` can target a nested path.
``oerpc.api`` imports every API module on first session use and logs an ERROR for the two that need Python 2's ``cStringIO``. They are irrelevant to the JSON-RPC transport we use, but with no logging configured Python's last-resort handler prints them to stderr, ahead of the password prompt. Attach a ``NullHandler`` to the ``oerpc.api`` logger: it stops the last-resort output while an explicitly configured root logger still receives oerpc's messages.
Member
|
rebased and merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.