-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
DockerOperator extra_hosts argument support added #10546
DockerOperator extra_hosts argument support added #10546
Conversation
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you rebase your PR on latest master please
7265839
to
0093e7f
Compare
@kaxil rebased. I have also fixed up codereview-related commit. So the code is now ready to be merged. |
0093e7f
to
22b561c
Compare
hosts_obj = mock.Mock() | ||
operator = \ | ||
DockerOperator(task_id='test', image='test', extra_hosts=hosts_obj) | ||
operator.execute(None) | ||
self.client_mock.create_container.assert_called_once() | ||
self.assertIn( | ||
'host_config', | ||
self.client_mock.create_container.call_args.kwargs, | ||
) | ||
self.assertIn( | ||
'extra_hosts', | ||
self.client_mock.create_host_config.call_args.kwargs, | ||
) | ||
self.assertIs( | ||
hosts_obj, | ||
self.client_mock.create_host_config.call_args.kwargs['extra_hosts'], | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of passing mock object to hosts_obj
why not pass a dictionary and check that it is used in mock_call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we do not need to know which type extra_hosts
argument is of.just need to check that it is successfully passed to create_host_config
call whatever the type is.
22b561c
to
58dbd8e
Compare
Rerun black to pass CI/CD check. |
Awesome work, congrats on your first merged pull request! |
Woooo, guys, thank you, it's an awesome experience ^_^ |
Good work @bryzgaloff , hope to see more of your contributions and thank you for this PR :) |
Added support for
extra_hosts
argument (docs) which is equivalent to--add-host
flag fordocker run
command (docs).Covered with tests. Also includes minor enhancements to
DockerOperator
tests: common code is moved to asetUp
method which makes code cleaner and reduces duplication.