mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-31 02:01:13 +00:00
Docker login (#894)
* Add docker_login rule * Add docker_login rule * Whitespace fix * Fix typo in test case * Fix typo in test case * Add test cases
This commit is contained in:
parent
1208faaabb
commit
828ae537da
@ -190,6 +190,7 @@ following rules are enabled by default:
|
|||||||
* `dirty_unzip` – fixes `unzip` command that unzipped in the current directory;
|
* `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_ghost` – adds `--delete-ghost-migrations` to failed because ghosts django south migration;
|
||||||
* `django_south_merge` – adds `--merge` to inconsistent 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`;
|
* `docker_not_command` – fixes wrong docker commands like `docker tags`;
|
||||||
* `dry` – fixes repetitions like `git git push`;
|
* `dry` – fixes repetitions like `git git push`;
|
||||||
* `fab_command_not_found` – fix misspelled fabric commands;
|
* `fab_command_not_found` – fix misspelled fabric commands;
|
||||||
|
37
tests/rules/test_docker_login.py
Normal file
37
tests/rules/test_docker_login.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from thefuck.rules.docker_login import match, get_new_command
|
||||||
|
from thefuck.types import Command
|
||||||
|
|
||||||
|
|
||||||
|
def test_match():
|
||||||
|
err_response1 = """
|
||||||
|
Sending build context to Docker daemon 118.8kB
|
||||||
|
Step 1/6 : FROM foo/bar:fdb7c6d
|
||||||
|
pull access denied for foo/bar, repository does not exist or may require 'docker login'
|
||||||
|
"""
|
||||||
|
assert match(Command('docker build -t artifactory:9090/foo/bar:fdb7c6d .', err_response1))
|
||||||
|
|
||||||
|
err_response2 = """
|
||||||
|
The push refers to repository [artifactory:9090/foo/bar]
|
||||||
|
push access denied for foo/bar, repository does not exist or may require 'docker login'
|
||||||
|
"""
|
||||||
|
assert match(Command('docker push artifactory:9090/foo/bar:fdb7c6d', err_response2))
|
||||||
|
|
||||||
|
err_response3 = """
|
||||||
|
docker push artifactory:9090/foo/bar:fdb7c6d
|
||||||
|
The push refers to repository [artifactory:9090/foo/bar]
|
||||||
|
9c29c7ad209d: Preparing
|
||||||
|
71f3ad53dfe0: Preparing
|
||||||
|
f58ee068224c: Preparing
|
||||||
|
aeddc924d0f7: Preparing
|
||||||
|
c2040e5d6363: Preparing
|
||||||
|
4d42df4f350f: Preparing
|
||||||
|
35723dab26f9: Preparing
|
||||||
|
71f3ad53dfe0: Pushed
|
||||||
|
cb95fa0faeb1: Layer already exists
|
||||||
|
"""
|
||||||
|
assert not match(Command('docker push artifactory:9090/foo/bar:fdb7c6d', err_response3))
|
||||||
|
|
||||||
|
|
||||||
|
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 .'
|
||||||
|
assert get_new_command(Command('docker push artifactory:9090/foo/bar:fdb7c6d', '')) == 'docker login && docker push 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 && {}'.format(command.script)
|
Loading…
x
Reference in New Issue
Block a user