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

Add TTY check and argument to disable it (#50603) #68260

Open
wants to merge 10 commits into
base: devel
Choose a base branch
from

Conversation

Soldann
Copy link

@Soldann Soldann commented Mar 16, 2020

SUMMARY

Fixes #50603

Runs a TTY check before launching the editor and raises an error if false. One can add the --no-check flag to override this check and launch the editor anyways.

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

ansible-vault create

ADDITIONAL INFORMATION

Running the command

bash $(ansible-vault --vault-password-file=key create file.yaml) 

now returns the following output instead of creating an invisible editor window.

~/ansible$ bash $(ansible-vault create --vault-password-file=key file.yaml)
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are
modifying the Ansible engine, or trying out features under development. This is a rapidly changing source of code and
can become unstable at any point.
ERROR! not a tty, editor cannot be opened
bash: usage:: No such file or directory

@ansibot ansibot added affects_2.10 bug core_review needs_triage new_contributor support:core labels Mar 16, 2020
@ansibot
Copy link
Contributor

ansibot commented Mar 16, 2020

The test ansible-test sanity --test pylint [explain] failed with 3 errors:

lib/ansible/cli/vault.py:79:39: bad-whitespace: Exactly one space required after comma         create_parser.add_argument('-n','--no-check',default=False, help='skip TTY check', dest='no_check', action='store_true')                                        ^
lib/ansible/cli/vault.py:79:52: bad-whitespace: Exactly one space required after comma         create_parser.add_argument('-n','--no-check',default=False, help='skip TTY check', dest='no_check', action='store_true')                                                     ^
lib/ansible/cli/vault.py:462:0: trailing-newlines: Trailing newlines

The test ansible-test sanity --test pep8 [explain] failed with 4 errors:

lib/ansible/cli/vault.py:79:40: E231: missing whitespace after ','
lib/ansible/cli/vault.py:79:53: E231: missing whitespace after ','
lib/ansible/cli/vault.py:433:33: E128: continuation line under-indented for visual indent
lib/ansible/cli/vault.py:462:1: W391: blank line at end of file

click here for bot help

@ansibot ansibot added needs_revision and removed core_review labels Mar 16, 2020
@ansibot ansibot added core_review needs_revision and removed needs_revision core_review labels Mar 17, 2020
Copy link
Member

@sivel sivel left a comment

This PR should also contain a changelog fragment (see changelogs/fragments) as well as tests to verify this functionality.

@@ -76,6 +76,7 @@ def init_parser(self):
create_parser = subparsers.add_parser('create', help='Create new vault encrypted file', parents=[vault_id, common])
create_parser.set_defaults(func=self.execute_create)
create_parser.add_argument('args', help='Filename', metavar='file_name', nargs='*')
create_parser.add_argument('-n', '--no-check', default=False, help='skip TTY check', dest='no_check', action='store_true')
Copy link
Member

@sivel sivel Mar 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This argument name should be more descriptive, such as --skip-tty-check. We also recommend dropping the shortopt of -n as that is overloaded and would lead to more confusion.

@sivel sivel removed the needs_triage label Mar 17, 2020
@ansibot ansibot added core_review support:community and removed needs_revision labels Mar 18, 2020
@Soldann Soldann requested a review from sivel Mar 18, 2020
@Soldann
Copy link
Author

Soldann commented Mar 18, 2020

Is AnsibleOptionsError the correct error type, or should it be changed?

@ansibot ansibot added needs_revision and removed core_review labels Mar 18, 2020
@ansibot ansibot added the stale_ci label Mar 26, 2020
@Soldann Soldann closed this Apr 4, 2020
@Soldann Soldann reopened this Apr 4, 2020
@ansibot ansibot added stale_review and removed stale_ci labels Apr 4, 2020
@ansibot ansibot added the stale_ci label Apr 16, 2020
@ansibot ansibot added pre_azp and removed stale_ci stale_review labels Dec 9, 2020
@ansibot ansibot removed the support:community label Mar 4, 2021
@mattclay
Copy link
Member

mattclay commented Jun 22, 2022

/azp run

@azure-pipelines
Copy link

azure-pipelines bot commented Jun 22, 2022

Azure Pipelines successfully started running 1 pipeline(s).

@ansibot ansibot added core_review and removed needs_revision pre_azp labels Jun 22, 2022
@ansibot ansibot added needs_revision stale_ci stale_review and removed core_review labels Jun 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.10 affects_2.13 bug needs_revision new_contributor stale_ci stale_review support:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants