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

🎉 Source Kustomer: Clarify setup fields #8738

Merged
merged 19 commits into from
Dec 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 31 additions & 7 deletions airbyte-integrations/connectors/source-kustomer-singer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
FROM python:3.7-slim
FROM python:3.7.11-alpine3.14 as base

# build and load all requirements
FROM base as builder
WORKDIR /airbyte/integration_code

# upgrade pip to the latest version
RUN apk --no-cache upgrade \
&& pip install --upgrade pip \
&& apk --no-cache add tzdata \
&& apk --no-cache add git \
&& apk --no-cache add build-base

# Bash is installed for more convenient debugging.
RUN apt-get update && apt-get install -y bash && apt-get install -y gcc && rm -rf /var/lib/apt/lists/*

COPY setup.py ./
# install necessary packages to a temporary folder
RUN pip install --prefix=/install .

# build a clean environment
FROM base
WORKDIR /airbyte/integration_code
COPY source_kustomer_singer ./source_kustomer_singer

# copy all loaded and built libraries to a pure basic image
COPY --from=builder /install /usr/local
# add default timezone settings
COPY --from=builder /usr/share/zoneinfo/Etc/UTC /etc/localtime
RUN echo "Etc/UTC" > /etc/timezone

# bash is installed for more convenient debugging.
RUN apk --no-cache add bash

# copy payload code only
COPY main.py ./
COPY setup.py ./
RUN pip install .
COPY source_kustomer_singer ./source_kustomer_singer

ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.1.0
LABEL io.airbyte.version=0.1.1
LABEL io.airbyte.name=airbyte/source-kustomer
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ tests:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
validate_output_from_all_streams: yes
# TODO uncomment this block to specify that the tests should assert the connector outputs the records provided in the input file a file
# expect_records:
# path: "integration_tests/expected_records.txt"
# extra_fields: no
# exact_order: no
# extra_records: yes
incremental: # TODO if your connector does not implement incremental sync, remove this block
incremental:
- config_path: "secrets/config.json"
configured_catalog_path: "integration_tests/configured_catalog.json"
future_state_path: "integration_tests/abnormal_state.json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,4 @@

@pytest.fixture(scope="session", autouse=True)
def connector_setup():
"""This fixture is a placeholder for external resources that acceptance test might require."""
# TODO: setup test dependencies
yield
# TODO: clean up test dependencies
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"api_token": "api_token",
"start_date": "2021-01-01T00:00:00Z",
"user_agent": "tap-kustomer <test@test.com>",
"date_window_size": "60",
"page_size_limit": "100"
"api_token": "invalid_api_token",
"start_date": "0000-01-01T00:00:00Z"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"todo-stream-name": {
"todo-field-name": "value"
"bookmarks": {
"conversations": "2021-12-25T18:00:00Z",
"customers": "2021-12-25T18:00:00Z",
"kobjects": "2021-12-25T18:00:00Z",
"messages": "2021-12-25T18:00:00Z",
"notes": "2021-12-25T18:00:00Z",
"shortcuts": "2021-12-25T18:00:00Z",
"tags": "2021-12-25T18:00:00Z",
"teams": "2021-12-25T18:00:00Z",
"users": "2021-12-25T18:00:00Z"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# This file is autogenerated -- only edit if you know what you are doing. Use setup.py for declaring dependencies.
-e ../../bases/source-acceptance-test
# -e ../../bases/source-acceptance-test
-e .
55 changes: 52 additions & 3 deletions airbyte-integrations/connectors/source-kustomer-singer/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,59 @@
# Copyright (c) 2021 Airbyte, Inc., all rights reserved.
#

import os
import shutil
from pathlib import Path
from setuptools import find_packages, setup
from setuptools.command.develop import develop
from setuptools.command.egg_info import egg_info
from setuptools.command.install import install
from subprocess import check_call


def check_singer():
tmp_dir = "/tmp/singer-python"
if not os.path.exists(tmp_dir):
check_call(f"git clone -b v5.8.1 https://github.com/singer-io/singer-python.git {tmp_dir}".split())
setup_py = Path(tmp_dir) / "setup.py"
setup_py.write_text(setup_py.read_text().replace("jsonschema==", "jsonschema>="))
setup_py.write_text(setup_py.read_text().replace("backoff==", "backoff>="))
setup_py.write_text(setup_py.read_text().replace("requests==", "backoff>="))
check_call(f"pip install -U {tmp_dir}".split())


class CustomInstallCommand(install):

def run(self):
check_singer()
install.run(self)
if os.path.exists("/tmp/singer-python"):
shutil.rmtree("/tmp/singer-python")


class CustomDevelopCommand(develop):
def run(self):
check_singer()
develop.run(self)
if os.path.exists("/tmp/singer-python"):
shutil.rmtree("/tmp/singer-python")


class CustomEggInfoCommand(egg_info):
def run(self):
check_singer()
egg_info.run(self)
if os.path.exists("/tmp/singer-python"):
shutil.rmtree("/tmp/singer-python")


MAIN_REQUIREMENTS = [
"tap-kustomer",
"airbyte-cdk",
"tap-kustomer==1.0.2"
]

TEST_REQUIREMENTS = [
"pytest~=6.1",
"source-acceptance-test",
"pytest~=6.1"
]

setup(
Expand All @@ -21,8 +64,14 @@
author_email="contact@airbyte.io",
packages=find_packages(),
install_requires=MAIN_REQUIREMENTS,
cmdclass={
'install': CustomInstallCommand,
'develop': CustomDevelopCommand,
'egg_info': CustomEggInfoCommand,
},
package_data={"": ["*.json"]},
extras_require={
"tests": TEST_REQUIREMENTS,
},

)
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,16 @@
"additionalProperties": true,
"properties": {
"api_token": {
"title": "API Token",
"type": "string",
"description": "The API token for your Kustomer account",
"airbyte_secret": true
},
"start_date": {
"title": "Start Date",
"type": "string",
"description": "The date from which you'd like to replicate the data",
"examples": ["2019-01-01T00:00:00Z"]
},
"user_agent": {
"type": "string",
"examples": "tap-kustomer <api_user_email@your_company.com>"
},
"date_window_size": {
"type": "string",
"description": "The integer number of days (between the from and to dates) for date-windowing through the date-filtered endpoints"
},
"page_size_limit": {
"type": "string",
"description": "The integer number of records to return per API request"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/integrations/sources/kustomer.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ Kustomer has some [rate limit restrictions](https://developer.kustomer.com/kusto

| Version | Date | Pull Request | Subject |
| :--- | :--- | :--- | :--- |
| 0.1.1 | 2021-12-13 | [8738](https://github.com/airbytehq/airbyte/pull/8738) | Deleted `user-agent`, `date_window_size`, `page_size_limit` from `spec.json` file |
| 0.1.0 | 2021-07-22 | [4550](https://github.com/airbytehq/airbyte/pull/4550) | Add Kustomer Source Connector |