Skip to content

Commit 059645f

Browse files
antixargl-pixPhlair
authored
🎉 Source File: separate secure fork (#6768)
* create a fork for the source-file connector * update docs and tests * update docs and tests * add secrets Co-authored-by: George Claireaux <[email protected]> * switching among auth methods * refactoring after reviews * correction of doc * update spec file Co-authored-by: Maksym Pavlenok <[email protected]> Co-authored-by: George Claireaux <[email protected]>
1 parent e3be3d2 commit 059645f

File tree

23 files changed

+589
-1
lines changed

23 files changed

+589
-1
lines changed

.github/workflows/test-command.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ jobs:
9292
EXCHANGE_RATES_TEST_CREDS: ${{ secrets.EXCHANGE_RATES_TEST_CREDS }}
9393
FACEBOOK_MARKETING_TEST_INTEGRATION_CREDS: ${{ secrets.FACEBOOK_MARKETING_TEST_INTEGRATION_CREDS }}
9494
FACEBOOK_PAGES_INTEGRATION_TEST_CREDS: ${{ secrets.FACEBOOK_PAGES_INTEGRATION_TEST_CREDS }}
95+
FILE_SECURE_HTTPS_TEST_CREDS: ${{ secrets.FILE_SECURE_HTTPS_TEST_CREDS }}
9596
FRESHDESK_TEST_CREDS: ${{ secrets.FRESHDESK_TEST_CREDS }}
9697
GITLAB_INTEGRATION_TEST_CREDS: ${{ secrets.GITLAB_INTEGRATION_TEST_CREDS }}
9798
GH_NATIVE_INTEGRATION_TEST_CREDS: ${{ secrets.GH_NATIVE_INTEGRATION_TEST_CREDS }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build
2+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM airbyte/source-file:0.2.6
2+
3+
WORKDIR /airbyte/integration_code
4+
5+
ENV CODE_PATH="source_file_secure"
6+
ENV AIRBYTE_IMPL_MODULE="source_file_secure"
7+
ENV AIRBYTE_IMPL_PATH="SourceFileSecure"
8+
9+
COPY $CODE_PATH ./$CODE_PATH
10+
RUN sed -i 's/source_file/source_file_secure/g' setup.py
11+
RUN pip install .
12+
13+
LABEL io.airbyte.name=airbyte/source-file-secure
14+
LABEL io.airbyte.version=0.1.0
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# File Source Secure
2+
This is the repository for the File source connector, written in Python.
3+
This is modificaion of another connector Source File. This version has only one difference with the origin version is this one doesn't support local file storages and is orientated for cloud and cluster platforms.
4+
More details about dependencies and requirement are available [here](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-file/README.md)
5+
6+
#### Build & Activate Virtual Environment and install dependencies
7+
From this connector directory, create a virtual environment:
8+
```
9+
python -m venv .venv
10+
```
11+
12+
This will generate a virtualenv for this module in `.venv/`. Make sure this venv is active in your
13+
development environment of choice. To activate it from the terminal, run:
14+
```
15+
source .venv/bin/activate
16+
pip install -r requirements.txt
17+
```
18+
If you are in an IDE, follow your IDE's instructions to activate the virtualenv.
19+
20+
Note that while we are installing dependencies from `requirements.txt`, you should only edit `setup.py` for your dependencies. `requirements.txt` is
21+
used for editable installs (`pip install -e`) to pull in Python dependencies from the monorepo and will call `setup.py`.
22+
If this is mumbo jumbo to you, don't worry about it, just put your deps in `setup.py` but install using `pip install -r requirements.txt` and everything
23+
should work as you expect.
24+
25+
#### Building via Gradle
26+
From the Airbyte repository root, run:
27+
```
28+
./gradlew :airbyte-integrations:connectors:source-file-secure:build
29+
```
30+
31+
#### Create credentials
32+
Details are explained [here](https://github.com/airbytehq/airbyte/blob/master/airbyte-integrations/connectors/source-file/README.md#create-credentials)
33+
34+
Note that the `secrets` directory is gitignored by default, so there is no danger of accidentally checking in sensitive information.
35+
See `sample_files/sample_config.json` for a sample config file.
36+
37+
38+
39+
**If you are an Airbyte core member**, copy the credentials in Lastpass under the secret name `source file test creds`
40+
and place them into `secrets/config.json`.
41+
42+
43+
### Locally running the connector
44+
```
45+
python main_dev.py spec
46+
python main_dev.py check --config secrets/config.json
47+
python main_dev.py discover --config secrets/config.json
48+
python main_dev.py read --config secrets/config.json --catalog sample_files/configured_catalog.json
49+
```
50+
51+
### Unit Tests
52+
To run unit tests locally, from the connector directory run:
53+
```
54+
python -m pytest unit_tests
55+
```
56+
57+
### Locally running the connector docker image
58+
59+
#### Build
60+
First, make sure you build the latest Docker image:
61+
```
62+
docker build . -t airbyte/source-file-secure:dev
63+
```
64+
65+
You can also build the connector image via Gradle:
66+
```
67+
./gradlew :airbyte-integrations:connectors:source-file-secure:airbyteDocker
68+
```
69+
When building via Gradle, the docker image name and tag, respectively, are the values of the `io.airbyte.name` and `io.airbyte.version` `LABEL`s in
70+
the Dockerfile.
71+
72+
#### Run
73+
Then run any of the connector commands as follows:
74+
```
75+
docker run --rm airbyte/source-file-secure:dev spec
76+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-file-secure:dev check --config /secrets/config.json
77+
docker run --rm -v $(pwd)/secrets:/secrets airbyte/source-file-secure:dev discover --config /secrets/config.json
78+
docker run --rm -v $(pwd)/secrets:/secrets -v $(pwd)/sample_files:/sample_files airbyte/source-file-secure:dev read --config /secrets/config.json --catalog /sample_files/configured_catalog.json
79+
```
80+
81+
### Integration Tests
82+
1. From the airbyte project root, run `./gradlew :airbyte-integrations:connectors:source-file-secure:integrationTest` to run the standard integration test suite.
83+
1. To run additional integration tests, place your integration tests in a new directory `integration_tests` and run them with `python -m pytest -s ../source-file/integration_tests`.
84+
Make sure to familiarize yourself with [pytest test discovery](https://docs.pytest.org/en/latest/goodpractices.html#test-discovery) to know how your test files and methods should be named.
85+
86+
## Dependency Management
87+
All of your dependencies should go in `setup.py`, NOT `requirements.txt`. The requirements file is only used to connect internal Airbyte dependencies in the monorepo for local development.
88+
89+
### Publishing a new version of the connector
90+
You've checked out the repo, implemented a million dollar feature, and you're ready to share your changes with the world. Now what?
91+
1. Make sure your changes are passing unit and integration tests
92+
1. Bump the connector version in `Dockerfile` -- just increment the value of the `LABEL io.airbyte.version` appropriately (we use SemVer).
93+
1. Create a Pull Request
94+
1. Pat yourself on the back for being an awesome contributor
95+
1. Someone from Airbyte will take a look at your PR and iterate with you to merge it into master
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# See [Source Acceptance Tests](https://docs.airbyte.io/connector-development/testing-connectors/source-acceptance-tests-reference)
2+
# for more information about how to configure these tests
3+
4+
# Here we tries to test a basic tests only.
5+
# The main part of tests should be executed for the source-file connector
6+
connector_image: airbyte/source-file-secure:dev
7+
tests:
8+
spec:
9+
- spec_path: "integration_tests/spec.json"
10+
connection:
11+
- config_path: "integration_tests/invalid_config.json"
12+
status: "failed"
13+
# for https
14+
- config_path: "integration_tests/https_config.json"
15+
status: "succeed"
16+
# for local should be failed
17+
- config_path: "integration_tests/local_config.json"
18+
status: "exception"
19+
20+
discovery:
21+
# for https
22+
- config_path: "integration_tests/https_config.json"
23+
24+
basic_read:
25+
# for https
26+
- config_path: "integration_tests/https_config.json"
27+
configured_catalog_path: "integration_tests/configured_https_catalog.json"
28+
29+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env sh
2+
3+
# Build latest connector image
4+
source_image=$(cat acceptance-test-config.yml | grep "connector_image" | head -n 1 | cut -d: -f2-)
5+
echo "try to build the source image: ${source_image}"
6+
docker build -t ${source_image} .
7+
8+
# Pull latest acctest image
9+
docker pull airbyte/source-acceptance-test:latest
10+
11+
docker run --rm -it \
12+
-v /var/run/docker.sock:/var/run/docker.sock \
13+
-v /tmp:/tmp \
14+
-v $(pwd):/test_input \
15+
airbyte/source-acceptance-test \
16+
--acceptance-test-config /test_input
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
plugins {
3+
id 'airbyte-python'
4+
id 'airbyte-docker'
5+
id 'airbyte-source-acceptance-test'
6+
}
7+
8+
airbytePython {
9+
moduleDirectory 'source_file_secure'
10+
}
11+
12+
dependencies {
13+
implementation files(project(':airbyte-integrations:bases:source-acceptance-test').airbyteDocker.outputs)
14+
implementation files(project(':airbyte-integrations:bases:base-python').airbyteDocker.outputs)
15+
}

airbyte-integrations/connectors/source-file-secure/integration_tests/__init__.py

Whitespace-only changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#
2+
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
3+
#
4+
5+
6+
import pytest
7+
8+
pytest_plugins = ("source_acceptance_test.plugin",)
9+
10+
11+
@pytest.fixture(scope="session", autouse=True)
12+
def connector_setup():
13+
""" This fixture is a placeholder for external resources that acceptance test might require."""
14+
yield
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"streams": [
3+
{
4+
"stream": {
5+
"name": "test",
6+
"json_schema": {},
7+
"supported_sync_modes": ["full_refresh"]
8+
},
9+
"sync_mode": "full_refresh",
10+
"destination_sync_mode": "overwrite"
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)