mirror of
https://github.com/nvbn/thefuck.git
synced 2025-04-15 07:10:52 +01:00
Add docker_login rule
This commit is contained in:
parent
1208faaabb
commit
c41dfe842d
@ -190,6 +190,7 @@ following rules are enabled by default:
|
||||
* `dirty_unzip` – fixes `unzip` command that unzipped in the current directory;
|
||||
* `django_south_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration;
|
||||
* `django_south_merge` – adds `--merge` to inconsistent django south migration;
|
||||
* `docker_login` – executes a `docker login` and repeats the previous command;
|
||||
* `docker_not_command` – fixes wrong docker commands like `docker tags`;
|
||||
* `dry` – fixes repetitions like `git git push`;
|
||||
* `fab_command_not_found` – fix misspelled fabric commands;
|
||||
|
16
tests/rules/test_docker_login.py
Normal file
16
tests/rules/test_docker_login.py
Normal file
@ -0,0 +1,16 @@
|
||||
from thefuck.rules.docker_login import match, get_new_command
|
||||
from thefuck.types import Command
|
||||
|
||||
|
||||
def test_match():
|
||||
err_response = """
|
||||
Sending build context to Docker daemon 118.8kB
|
||||
Step 1/6 : FROM baz/baz:nightly
|
||||
pull access denied for baz/baz, repository does not exist or may require 'docker login'
|
||||
"""
|
||||
assert match(Command('docker build -t artifactory:9090/foo/bar:fdb7c6d .', err_response))
|
||||
assert not match(Command('', ''))
|
||||
|
||||
|
||||
def test_get_new_command():
|
||||
assert get_new_command(Command('docker build -t artifactory:9090/foo/bar:fdb7c6d .', '')) == 'docker login && docker build -t artifactory:9090/foo/bar:fdb7c6d .'
|
12
thefuck/rules/docker_login.py
Normal file
12
thefuck/rules/docker_login.py
Normal file
@ -0,0 +1,12 @@
|
||||
from thefuck.utils import for_app
|
||||
|
||||
|
||||
@for_app('docker')
|
||||
def match(command):
|
||||
return ('docker' in command.script
|
||||
and "access denied" in command.output
|
||||
and "may require 'docker login'" in command.output)
|
||||
|
||||
|
||||
def get_new_command(command):
|
||||
return "docker login && %s" % command.script
|
Loading…
x
Reference in New Issue
Block a user