Skip to content

Commit 90cb262

Browse files
btkcodedevdarynaishchenkokatmarkham
authored
✨Source Xero: Migrate Python CDK to Low-code CDK (#36956)
Co-authored-by: Daryna Ishchenko <[email protected]> Co-authored-by: katmarkham <[email protected]>
1 parent da518b2 commit 90cb262

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3444
-4180
lines changed

airbyte-integrations/connectors/source-xero/.dockerignore

-6
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,66 @@
11
# Xero source connector
22

33

4-
This is the repository for the Xero source connector, written in Python.
4+
This is the repository for the Xero configuration based source connector.
55
For information about how to use this connector within Airbyte, see [the documentation](https://docs.airbyte.com/integrations/sources/xero).
66

77
## Local development
88

99
### Prerequisites
10-
* Python (~=3.9)
11-
* Poetry (~=1.7) - installation instructions [here](https://python-poetry.org/docs/#installation)
10+
11+
* Python (`^3.9`)
12+
* Poetry (`^1.7`) - installation instructions [here](https://python-poetry.org/docs/#installation)
13+
1214

1315

1416
### Installing the connector
17+
1518
From this connector directory, run:
1619
```bash
1720
poetry install --with dev
1821
```
1922

2023

2124
### Create credentials
25+
2226
**If you are a community contributor**, follow the instructions in the [documentation](https://docs.airbyte.com/integrations/sources/xero)
23-
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `source_xero/spec.yaml` file.
27+
to generate the necessary credentials. Then create a file `secrets/config.json` conforming to the `spec` inside `manifest.yaml` file.
2428
Note that any directory named `secrets` is gitignored across the entire Airbyte repo, so there is no danger of accidentally checking in sensitive information.
25-
See `sample_files/sample_config.json` for a sample config file.
29+
See `integration_tests/sample_config.json` for a sample config file.
2630

2731

2832
### Locally running the connector
33+
34+
2935
```
3036
poetry run source-xero spec
3137
poetry run source-xero check --config secrets/config.json
3238
poetry run source-xero discover --config secrets/config.json
33-
poetry run source-xero read --config secrets/config.json --catalog sample_files/configured_catalog.json
39+
poetry run source-xero read --config secrets/config.json --catalog integration_tests/configured_catalog.json
3440
```
3541

36-
### Running unit tests
37-
To run unit tests locally, from the connector directory run:
42+
### Running tests
43+
44+
To run tests locally, from the connector directory run:
45+
3846
```
39-
poetry run pytest unit_tests
47+
poetry run pytest tests
4048
```
4149

4250
### Building the docker image
51+
4352
1. Install [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md)
4453
2. Run the following command to build the docker image:
4554
```bash
4655
airbyte-ci connectors --name=source-xero build
4756
```
4857

4958
An image will be available on your host with the tag `airbyte/source-xero:dev`.
59+
An image will be available on your host with the tag `airbyte/source-xero:dev`.
5060

5161

5262
### Running as a docker container
63+
5364
Then run any of the connector commands as follows:
5465
```
5566
docker run --rm airbyte/source-xero:dev spec
@@ -59,16 +70,19 @@ docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/integration_tests:/integrat
5970
```
6071

6172
### Running our CI test suite
73+
6274
You can run our full test suite locally using [`airbyte-ci`](https://github.com/airbytehq/airbyte/blob/master/airbyte-ci/connectors/pipelines/README.md):
6375
```bash
6476
airbyte-ci connectors --name=source-xero test
6577
```
6678

6779
### Customizing acceptance Tests
80+
6881
Customize `acceptance-test-config.yml` file to configure acceptance tests. See [Connector Acceptance Tests](https://docs.airbyte.com/connector-development/testing-connectors/connector-acceptance-tests-reference) for more information.
6982
If your connector requires to create or destroy resources for use during acceptance tests create fixtures for it and place them inside integration_tests/acceptance.py.
7083

7184
### Dependency Management
85+
7286
All of your dependencies should be managed via Poetry.
7387
To add a new dependency, run:
7488
```bash
@@ -78,14 +92,20 @@ poetry add <package-name>
7892
Please commit the changes to `pyproject.toml` and `poetry.lock` files.
7993

8094
## Publishing a new version of the connector
95+
8196
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
8297
1. Make sure your changes are passing our test suite: `airbyte-ci connectors --name=source-xero test`
98+
2. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
99+
- bump the `dockerImageTag` value in in `metadata.yaml`
100+
- bump the `version` value in `pyproject.toml`
83101
2. Bump the connector version (please follow [semantic versioning for connectors](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#semantic-versioning-for-connectors)):
84102
- bump the `dockerImageTag` value in in `metadata.yaml`
85103
- bump the `version` value in `pyproject.toml`
86104
3. Make sure the `metadata.yaml` content is up to date.
87105
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/xero.md`).
106+
4. Make sure the connector documentation and its changelog is up to date (`docs/integrations/sources/xero.md`).
88107
5. Create a Pull Request: use [our PR naming conventions](https://docs.airbyte.com/contributing-to-airbyte/resources/pull-requests-handbook/#pull-request-title-convention).
89108
6. Pat yourself on the back for being an awesome contributor.
90109
7. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master.
110+
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.
91111
8. Once your PR is merged, the new version of the connector will be automatically published to Docker Hub and our connector registry.

airbyte-integrations/connectors/source-xero/acceptance-test-config.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ acceptance_tests:
77
tests:
88
- spec_path: "source_xero/spec.yaml"
99
backward_compatibility_tests_config:
10-
disable_for_version: "0.1.0"
10+
disable_for_version: "0.2.5"
1111
connection:
1212
tests:
1313
- config_path: "secrets/config.json"
@@ -18,7 +18,7 @@ acceptance_tests:
1818
tests:
1919
- config_path: "secrets/config.json"
2020
backward_compatibility_tests_config:
21-
disable_for_version: "0.1.0"
21+
disable_for_version: "0.2.5"
2222
basic_read:
2323
tests:
2424
- config_path: "secrets/config.json"
@@ -42,6 +42,7 @@ acceptance_tests:
4242
bypass_reason: "Empty stream, further investigation is required"
4343
fail_on_extra_columns: false
4444
incremental:
45+
# bypass_reason: "Xero only supports date-precision filtering and our sandbox does not have enough data to properly test incremental reads"
4546
tests:
4647
- config_path: "secrets/config.json"
4748
configured_catalog_path: "integration_tests/configured_catalog.json"

airbyte-integrations/connectors/source-xero/integration_tests/acceptance.py

+2
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,6 @@
1111
@pytest.fixture(scope="session", autouse=True)
1212
def connector_setup():
1313
"""This fixture is a placeholder for external resources that acceptance test might require."""
14+
# TODO: setup test dependencies if needed. otherwise remove the TODO comments
1415
yield
16+
# TODO: clean up test dependencies
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
2-
"client_id": "client_id",
3-
"client_secret": "client_secret",
4-
"tenant_id": "tenant_id",
5-
"scopes": "scope1, scope2",
6-
"authentication": {
7-
"auth_type": null
8-
},
9-
"start_date": "2020-01-01T00:00:00Z"
2+
"access_token": "xxxxxxxxxxxxxxxxxxxx",
3+
"tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
4+
"start_date": "2021-01-01T00:00:00Z"
105
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
{
2-
"client_id": "389D15E4EE7D4EC09F91F2926EDE5B9B",
3-
"client_secret": "rumSF2vR4wGY-bhNOTqo1lttMgi0h_XobxyrKYBzrRUxj9nR",
4-
"tenant_id": "22b6dfc8-a47d-4e3d-a4ab-a30f22a5681d",
5-
"scopes": "accounting.attachments accounting.contacts accounting.transactions assets.read accounting.attachments.read accounting.contacts.read accounting.settings accounting.settings.read accounting.journals.read accounting.budgets.read accounting.reports.tenninetynine.read accounting.reports.read assets accounting.transactions.read",
6-
"authentication": {
7-
"auth_type": "custom_connection"
8-
},
2+
"access_token": "xxxxxxxxxxxxxxxxxxxx",
3+
"tenant_id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
94
"start_date": "2021-01-01T00:00:00Z"
105
}

airbyte-integrations/connectors/source-xero/metadata.yaml

+25-14
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,46 @@ data:
22
allowedHosts:
33
hosts:
44
- api.xero.com
5+
registries:
6+
oss:
7+
enabled: true
8+
cloud:
9+
enabled: false
10+
remoteRegistries:
11+
pypi:
12+
enabled: true
13+
packageName: airbyte-source-xero
14+
releases:
15+
breakingChanges:
16+
1.0.0:
17+
upgradeDeadline: "2024-06-30"
18+
message:
19+
The source Xero connector is being migrated from the Python CDK to our declarative low-code CDK. The authorization method was changed from OAuth 2.0 to Access Token. Due to changes in authorization, users will need to generate an access token within source Xero and reset source configuration. For more information, see our migration documentation for source Xero.
20+
Important - The authentication scheme is using access_token instead of Oauth 2.0 from this version.
21+
connectorBuildOptions:
22+
# Please update to the latest version of the connector base image.
23+
# https://hub.docker.com/r/airbyte/python-connector-base
24+
# Please use the full address with sha256 hash to guarantee build reproducibility.
25+
baseImage: docker.io/airbyte/python-connector-base:1.2.0@sha256:c22a9d97464b69d6ef01898edf3f8612dc11614f05a84984451dde195f337db9
526
connectorSubtype: api
627
connectorType: source
728
definitionId: 6fd1e833-dd6e-45ec-a727-ab917c5be892
8-
dockerImageTag: 0.2.6
29+
dockerImageTag: 1.0.0
930
dockerRepository: airbyte/source-xero
1031
githubIssueLabel: source-xero
1132
icon: xero.svg
1233
license: MIT
1334
name: Xero
14-
remoteRegistries:
15-
pypi:
16-
enabled: true
17-
packageName: airbyte-source-xero
18-
registries:
19-
cloud:
20-
enabled: false
21-
oss:
22-
enabled: true
35+
releaseDate: 2021-11-11
2336
releaseStage: beta
37+
supportLevel: community
2438
documentationUrl: https://docs.airbyte.com/integrations/sources/xero
2539
tags:
2640
- language:python
27-
- cdk:python
41+
- cdk:low-code
2842
ab_internal:
2943
sl: 100
3044
ql: 300
31-
supportLevel: community
3245
connectorTestSuitesOptions:
3346
- suite: unitTests
3447
- suite: acceptanceTests
@@ -38,6 +51,4 @@ data:
3851
secretStore:
3952
type: GSM
4053
alias: airbyte-connector-testing-secret-store
41-
connectorBuildOptions:
42-
baseImage: docker.io/airbyte/python-connector-base:1.2.0@sha256:c22a9d97464b69d6ef01898edf3f8612dc11614f05a84984451dde195f337db9
4354
metadataSpecVersion: "1.0"

0 commit comments

Comments
 (0)