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

DiscordWebhookOperator - add webhook_endpoint to templated fields #22570

Merged
merged 2 commits into from
Mar 31, 2022

Conversation

ttomasz
Copy link
Contributor

@ttomasz ttomasz commented Mar 28, 2022

Added webhook_endpoint to templated fields in DiscordWebhookOperator.

User might want to leverage templates for that field. In my case I wanted to use token saved in password field of a connection to avoid leaking the token to logs:

send_discord_message_task = DiscordWebhookOperator(
        task_id="send_discord_message",
        http_conn_id="discord_webhook",
        webhook_endpoint="webhooks/{{ conn.discord_webhook.login }}/{{ conn.discord_webhook.password }}",
        message="...",
)

It's possible to overwrite templated fields later but this seems like a good default.


^ Add meaningful description above

Read the Pull Request Guidelines for more information.
In case of fundamental code change, Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in UPDATING.md.

@boring-cyborg
Copy link

boring-cyborg bot commented Mar 28, 2022

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/main/CONTRIBUTING.rst)
Here are some useful points:

  • Pay attention to the quality of your code (flake8, mypy and type annotations). Our pre-commits will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example DAG that shows how users should use it.
  • Consider using Breeze environment for testing locally, it’s a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@potiuk
Copy link
Member

potiuk commented Mar 29, 2022

I rebased to check if the static code was just accidental main merge.

@eladkal
Copy link
Contributor

eladkal commented Mar 30, 2022

The test failing is:

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/bin/black", line 8, in <module>
    sys.exit(patched_main())
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/black/__init__.py", line 1423, in patched_main
    patch_click()
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/black/__init__.py", line 1409, in patch_click
    from click import _unicodefun
ImportError: cannot import name '_unicodefun' from 'click' (/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/click/__init__.py)
Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/bin/black", line 8, in <module>
    sys.exit(patched_main())
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/black/__init__.py", line 1423, in patched_main
    patch_click()
  File "/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/black/__init__.py", line 1409, in patch_click
    from click import _unicodefun
ImportError: cannot import name '_unicodefun' from 'click' (/home/runner/.cache/pre-commit/repo9lrx9zpk/py_env-python3/lib/python3.7/site-packages/click/__init__.py)

related to click releasing version 8.1.0
pallets/click#2232
which effect black
psf/black#2964

@eladkal
Copy link
Contributor

eladkal commented Mar 30, 2022

It should be fixed by #22599

@eladkal eladkal merged commit dae5640 into apache:main Mar 31, 2022
@boring-cyborg
Copy link

boring-cyborg bot commented Mar 31, 2022

Awesome work, congrats on your first merged pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants