Skip to content

Simplify Github and Postgres forms #2 #24255

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

Merged
merged 17 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,32 @@
import io.airbyte.commons.resources.MoreResources;
import io.airbyte.protocol.models.v0.ConnectorSpecification;
import java.io.IOException;
import java.util.Optional;

public class SshHelpers {

public static ConnectorSpecification getSpecAndInjectSsh() throws IOException {
return getSpecAndInjectSsh(Optional.empty());
}

public static ConnectorSpecification getSpecAndInjectSsh(final Optional<String> group) throws IOException {
final ConnectorSpecification originalSpec = Jsons.deserialize(MoreResources.readResource("spec.json"), ConnectorSpecification.class);
return injectSshIntoSpec(originalSpec);
return injectSshIntoSpec(originalSpec, group);
}

public static ConnectorSpecification injectSshIntoSpec(final ConnectorSpecification connectorSpecification) throws IOException {
return injectSshIntoSpec(connectorSpecification, Optional.empty());
}

public static ConnectorSpecification injectSshIntoSpec(final ConnectorSpecification connectorSpecification, final Optional<String> group)
throws IOException {
final ConnectorSpecification originalSpec = Jsons.clone(connectorSpecification);
final ObjectNode propNode = (ObjectNode) originalSpec.getConnectionSpecification().get("properties");
propNode.set("tunnel_method", Jsons.deserialize(MoreResources.readResource("ssh-tunnel-spec.json")));
final ObjectNode tunnelMethod = (ObjectNode) Jsons.deserialize(MoreResources.readResource("ssh-tunnel-spec.json"));
if (group.isPresent()) {
tunnelMethod.put("group", group.get());
}
propNode.set("tunnel_method", tunnelMethod);
return originalSpec;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import io.airbyte.protocol.models.v0.ConfiguredAirbyteCatalog;
import io.airbyte.protocol.models.v0.ConnectorSpecification;
import java.util.List;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -25,16 +26,25 @@ public class SshWrappedSource implements Source {
private final Source delegate;
private final List<String> hostKey;
private final List<String> portKey;
private final Optional<String> sshGroup;

public SshWrappedSource(final Source delegate, final List<String> hostKey, final List<String> portKey) {
this.delegate = delegate;
this.hostKey = hostKey;
this.portKey = portKey;
this.sshGroup = Optional.empty();
}

public SshWrappedSource(final Source delegate, final List<String> hostKey, final List<String> portKey, final String sshGroup) {
this.delegate = delegate;
this.hostKey = hostKey;
this.portKey = portKey;
this.sshGroup = Optional.of(sshGroup);
}

@Override
public ConnectorSpecification spec() throws Exception {
return SshHelpers.injectSshIntoSpec(delegate.spec());
return SshHelpers.injectSshIntoSpec(delegate.spec(), sshGroup);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion airbyte-integrations/connectors/source-github/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ RUN pip install .
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]

LABEL io.airbyte.version=0.4.3
LABEL io.airbyte.version=0.4.4
LABEL io.airbyte.name=airbyte/source-github
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"description": "Choose how to authenticate to GitHub",
"type": "object",
"order": 0,
"group": "auth",
"oneOf": [
{
"type": "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-postgres-strict-encrypt

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=2.0.3
LABEL io.airbyte.version=2.0.4
LABEL io.airbyte.name=airbyte/source-postgres-strict-encrypt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ ENV APPLICATION source-postgres

COPY --from=build /airbyte /airbyte

LABEL io.airbyte.version=2.0.3
LABEL io.airbyte.version=2.0.4
LABEL io.airbyte.name=airbyte/source-postgres
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class PostgresSource extends AbstractJdbcSource<PostgresType> implements
private static final Set<String> INVALID_CDC_SSL_MODES = ImmutableSet.of("allow", "prefer");

public static Source sshWrappedSource() {
return new SshWrappedSource(new PostgresSource(), JdbcUtils.HOST_LIST_KEY, JdbcUtils.PORT_LIST_KEY);
return new SshWrappedSource(new PostgresSource(), JdbcUtils.HOST_LIST_KEY, JdbcUtils.PORT_LIST_KEY, "security");
}

PostgresSource() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"title": "Host",
"description": "Hostname of the database.",
"type": "string",
"order": 0
"order": 0,
"group": "db"
},
"port": {
"title": "Port",
Expand All @@ -20,13 +21,15 @@
"maximum": 65536,
"default": 5432,
"examples": ["5432"],
"order": 1
"order": 1,
"group": "db"
},
"database": {
"title": "Database Name",
"description": "Name of the database.",
"type": "string",
"order": 2
"order": 2,
"group": "db"
},
"schemas": {
"title": "Schemas",
Expand All @@ -38,39 +41,47 @@
"minItems": 0,
"uniqueItems": true,
"default": ["public"],
"order": 3
"order": 3,
"group": "db"
},
"username": {
"title": "Username",
"description": "Username to access the database.",
"type": "string",
"order": 4
"order": 4,
"group": "auth"
},
"password": {
"title": "Password",
"description": "Password associated with the username.",
"type": "string",
"airbyte_secret": true,
"order": 5
"order": 5,
"group": "auth",
"always_show": true
},
"jdbc_url_params": {
"description": "Additional properties to pass to the JDBC URL string when connecting to the database formatted as 'key=value' pairs separated by the symbol '&'. (Eg. key1=value1&key2=value2&key3=value3). For more information read about <a href=\"https://jdbc.postgresql.org/documentation/head/connect.html\">JDBC URL parameters</a>.",
"title": "JDBC URL Parameters (Advanced)",
"type": "string",
"order": 6
"order": 6,
"group": "advanced"
},
"ssl": {
"title": "Connect using SSL",
"description": "Encrypt data using SSL. When activating SSL, please select one of the connection modes.",
"type": "boolean",
"default": false,
"order": 7
"order": 7,
"group": "security",
"always_show": true
},
"ssl_mode": {
"title": "SSL Modes",
"description": "SSL connection modes. \n Read more <a href=\"https://jdbc.postgresql.org/documentation/head/ssl-client.html\"> in the docs</a>.",
"type": "object",
"order": 7,
"order": 8,
"group": "security",
"oneOf": [
{
"title": "disable",
Expand Down Expand Up @@ -218,7 +229,8 @@
"type": "object",
"title": "Replication Method",
"description": "Replication method for extracting data from the database.",
"order": 8,
"order": 9,
"group": "advanced",
"oneOf": [
{
"title": "Standard",
Expand Down Expand Up @@ -276,14 +288,33 @@
"type": "string",
"title": "LSN commit behaviour",
"description": "Determines when Airbtye should flush the LSN of processed WAL logs in the source database. `After loading Data in the destination` is default. If `While reading Data` is selected, in case of a downstream failure (while loading data into the destination), next sync would result in a full sync.",
"enum": ["While reading Data", "After loading Data in the destination"],
"enum": [
"While reading Data",
"After loading Data in the destination"
],
"default": "After loading Data in the destination",
"order": 6
}
}
}
]
}
}
},
"groups": [
{
"id": "db"
},
{
"id": "auth"
},
{
"id": "security",
"title": "Security"
},
{
"id": "advanced",
"title": "Advanced"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.airbyte.integrations.io.airbyte.integration_tests.sources;

import io.airbyte.integrations.base.ssh.SshHelpers;
import io.airbyte.integrations.standardtest.source.SourceAcceptanceTest;
import io.airbyte.protocol.models.v0.ConnectorSpecification;
import java.util.Optional;

public abstract class AbstractPostgresSourceAcceptanceTest extends SourceAcceptanceTest {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created this abstract class so that I didn't need to repeat the "security" group string in every test

@Override
protected String getImageName() {
return "airbyte/source-postgres:dev";
}

@Override
protected ConnectorSpecification getSpec() throws Exception {
return SshHelpers.getSpecAndInjectSsh(Optional.of("security"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;

@ExtendWith(SystemStubsExtension.class)
public abstract class AbstractPostgresSourceSSLCertificateAcceptanceTest extends SourceAcceptanceTest {
public abstract class AbstractPostgresSourceSSLCertificateAcceptanceTest extends AbstractPostgresSourceAcceptanceTest {

private static final String STREAM_NAME = "id_and_name";
private static final String STREAM_NAME2 = "starships";
Expand Down Expand Up @@ -103,16 +103,6 @@ protected void tearDown(final TestDestinationEnv testEnv) {
container.close();
}

@Override
protected String getImageName() {
return "airbyte/source-postgres:dev";
}

@Override
protected ConnectorSpecification getSpec() throws Exception {
return SshHelpers.getSpecAndInjectSsh();
}

@Override
protected JsonNode getConfig() {
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;

@ExtendWith(SystemStubsExtension.class)
public abstract class AbstractSshPostgresSourceAcceptanceTest extends SourceAcceptanceTest {
public abstract class AbstractSshPostgresSourceAcceptanceTest extends AbstractPostgresSourceAcceptanceTest {

private static final String STREAM_NAME = "id_and_name";
private static final String STREAM_NAME2 = "starships";
Expand Down Expand Up @@ -105,16 +105,6 @@ protected void tearDown(final TestDestinationEnv testEnv) {
bastion.stopAndCloseContainers(db);
}

@Override
protected String getImageName() {
return "airbyte/source-postgres:dev";
}

@Override
protected ConnectorSpecification getSpec() throws Exception {
return SshHelpers.getSpecAndInjectSsh();
}

@Override
protected JsonNode getConfig() {
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
// todo (cgardens) - Sanity check that when configured for CDC that postgres performs like any other
// incremental source. As we have more sources support CDC we will find a more reusable way of doing
// this, but for now this is a solid sanity check.
public class CdcPostgresSourceAcceptanceTest extends SourceAcceptanceTest {
public class CdcPostgresSourceAcceptanceTest extends AbstractPostgresSourceAcceptanceTest {

protected static final String SLOT_NAME_BASE = "debezium_slot";
protected static final String NAMESPACE = "public";
Expand Down Expand Up @@ -106,16 +106,6 @@ protected void tearDown(final TestDestinationEnv testEnv) {
container.close();
}

@Override
protected String getImageName() {
return "airbyte/source-postgres:dev";
}

@Override
protected ConnectorSpecification getSpec() throws Exception {
return SshHelpers.getSpecAndInjectSsh();
}

@Override
protected JsonNode getConfig() {
return config;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import org.jooq.DSLContext;
import org.jooq.SQLDialect;
import org.junit.jupiter.api.Test;
Expand All @@ -43,7 +44,7 @@
import uk.org.webcompere.systemstubs.jupiter.SystemStubsExtension;

@ExtendWith(SystemStubsExtension.class)
public class PostgresSourceAcceptanceTest extends SourceAcceptanceTest {
public class PostgresSourceAcceptanceTest extends AbstractPostgresSourceAcceptanceTest {

private static final String STREAM_NAME = "id_and_name";
private static final String STREAM_NAME2 = "starships";
Expand Down Expand Up @@ -114,16 +115,6 @@ protected void tearDown(final TestDestinationEnv testEnv) {
container.close();
}

@Override
protected String getImageName() {
return "airbyte/source-postgres:dev";
}

@Override
protected ConnectorSpecification getSpec() throws Exception {
return SshHelpers.getSpecAndInjectSsh();
}

@Override
protected JsonNode getConfig() {
return config;
Expand Down
Loading