alexbegg opened a new pull request #19530:
URL: https://github.com/apache/airflow/pull/19530


   The `SalesforceHook` was previously requiring all connection extras, however 
with secrets backends it is now possible to provide one extra at a time. The 
current setup was directly accessing keys of the extras json which would result 
in a `KeyError` if you leave out one of them.
   
   This PR allows for just the minimum required extras to be provided for each 
Salesforce connection method as defined in the docstring of the 
`SalesforceHook`: 
https://github.com/apache/airflow/blob/e9a72a4e95e6d23bae010ad92499cd7b06d50037/airflow/providers/salesforce/hooks/salesforce.py#L55-L60
   
   It also adds an alternative of providing extras without the 
`extra__salesforce__` prefix, which is likely the case if you are using a 
secrets backend (also as shown on the bottom of the Salesforce connection 
documentation page: 
https://airflow.apache.org/docs/apache-airflow-providers-salesforce/stable/connections/salesforce.html).
 It also allows for all of the extras to be provided, such as the case 
currently when the connection is added via the UI.
   
   When making the connection the hook will explicitly default to `None` for 
all extras except for "version" (which defaults to the default API version). 
The reason for this is because `simple-salesforce` already has built-in 
authentication-choosing methods that relies on which arguments are `None` and 
without having `or None` in the code then setting this connection in the UI 
will result in the blank extras being empty strings instead of None, which 
would break the connection if `get` was used on its own.
   
   The tests for the hook are also updated to provide the following 3 sets of 
extra dictionaries for each connection type:
   
   1. all extras provided
   2. only required extras provided
   3. only required extras provided with no `extra__salesforce__` prefix
   
   Also, a thank you @gigatexal, @dstandish, @josh-fell for prior PRs and PR 
discussions regarding this fix. This PRs incorporates the discussed points.
   
   closes: #19506
   completes PR #18929 by adding tests
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: #ISSUE
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   ---
   **^ Add meaningful description above**
   
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code change, Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvements+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in 
[UPDATING.md](https://github.com/apache/airflow/blob/main/UPDATING.md).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to