|
| 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 |
0 commit comments