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

Bmoric/convert source definition micronaut #20338

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
b42d814
tmp
benmoriceau Nov 23, 2022
5da2868
Fix build
benmoriceau Nov 28, 2022
83c3edc
tmp
benmoriceau Nov 28, 2022
27ccea0
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Nov 28, 2022
e3323ee
Tmp
benmoriceau Nov 29, 2022
648494e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Nov 30, 2022
9f4fee5
tmp
benmoriceau Dec 1, 2022
2391852
tmp
benmoriceau Dec 1, 2022
453f2fd
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 5, 2022
9032d55
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 5, 2022
212dd86
Tmp
benmoriceau Dec 5, 2022
8fd0939
tmp
benmoriceau Dec 6, 2022
d378aab
tmp
benmoriceau Dec 6, 2022
0ff5a15
Clean up
benmoriceau Dec 6, 2022
8dcef2e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
4ad415e
tmp
benmoriceau Dec 7, 2022
58d51db
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
c982867
Convert Connection Api Controller
benmoriceau Dec 7, 2022
8de361a
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 7, 2022
fccb967
PR Comments
benmoriceau Dec 8, 2022
e0730b3
convert openapiapicontroller to micronaut (#20258)
colesnodgrass Dec 8, 2022
df5a30e
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 8, 2022
0024dff
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 8, 2022
4d8d7c2
Fix build
benmoriceau Dec 8, 2022
abbf357
Format
benmoriceau Dec 8, 2022
c053aa7
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
7490f23
Remove media type
benmoriceau Dec 9, 2022
556e7d3
Format
benmoriceau Dec 9, 2022
8209043
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
a2f97d1
Tmp
benmoriceau Dec 9, 2022
339f985
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 9, 2022
abda88e
tmp
benmoriceau Dec 9, 2022
fcdaa8b
Build
benmoriceau Dec 9, 2022
67b1166
missing bean
benmoriceau Dec 9, 2022
03add10
Tmp
benmoriceau Dec 9, 2022
953be1f
Add Beans
benmoriceau Dec 9, 2022
06a3066
fix Bean
benmoriceau Dec 9, 2022
1aab7c4
Add passthrough
benmoriceau Dec 9, 2022
f40e899
Clean up
benmoriceau Dec 9, 2022
77c61c1
Missing path
benmoriceau Dec 10, 2022
3a13b8f
Merge branch 'master' of github.com:airbytehq/airbyte into bmoric/con…
benmoriceau Dec 12, 2022
6ab034c
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 12, 2022
a520c33
FIx typo
benmoriceau Dec 12, 2022
f288b26
Fix conflicts
benmoriceau Dec 12, 2022
ce0bbb6
Merge branch 'bmoric/convert-health-micronaut' of github.com:airbyteh…
benmoriceau Dec 12, 2022
b1104ef
for mat
benmoriceau Dec 12, 2022
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
2 changes: 1 addition & 1 deletion airbyte-proxy/nginx-auth.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ http {
}
}

location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_definition_specifications|destination_oauths|operations|source_definitions|sources|scheduler|state)/.* {
location ~ ^/api/v1/(connections|destinations|destination_definitions|destination_definition_specifications|destination_oauths|operations
|scheduler|source_definitions|sources|state)/.* {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand Down
1 change: 1 addition & 0 deletions airbyte-server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
testImplementation libs.postgresql
testImplementation libs.platform.testcontainers.postgresql
testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1'
testImplementation 'org.mockito:mockito-inline:4.7.0'
}

// we want to be able to access the generated db files from config/init when we build the server docker image.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,8 @@ public static ServerRunnable getServer(final ServerFactory apiFactory,
schemaValidator,
connectionsHandler);

final SourceDefinitionsHandler sourceDefinitionsHandler = new SourceDefinitionsHandler(configRepository, syncSchedulerClient, sourceHandler);
final SourceDefinitionsHandler sourceDefinitionsHandler =
new SourceDefinitionsHandler(configRepository, syncSchedulerClient, sourceHandler, configs);

final JobHistoryHandler jobHistoryHandler = new JobHistoryHandler(
jobPersistence,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@
import io.airbyte.server.apis.JobsApiController;
import io.airbyte.server.apis.LogsApiController;
import io.airbyte.server.apis.NotificationsApiController;
import io.airbyte.server.apis.OpenapiApiController;
import io.airbyte.server.apis.OperationApiController;
import io.airbyte.server.apis.SourceApiController;
import io.airbyte.server.apis.SourceDefinitionApiController;
import io.airbyte.server.apis.SourceDefinitionSpecificationApiController;
import io.airbyte.server.apis.SourceOauthApiController;
import io.airbyte.server.apis.StateApiController;
Expand Down Expand Up @@ -152,10 +148,6 @@ public ServerRunnable create(final SynchronousSchedulerClient synchronousSchedul
JobsApiController.class,
LogsApiController.class,
NotificationsApiController.class,
OpenapiApiController.class,
OperationApiController.class,
SourceApiController.class,
SourceDefinitionApiController.class,
SourceDefinitionSpecificationApiController.class,
SourceOauthApiController.class,
StateApiController.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
import io.airbyte.api.model.generated.SourceDefinitionUpdate;
import io.airbyte.api.model.generated.WorkspaceIdRequestBody;
import io.airbyte.server.handlers.SourceDefinitionsHandler;
import io.micronaut.context.annotation.Context;
import io.micronaut.http.annotation.Controller;
import io.micronaut.http.annotation.Post;

@Controller("/api/v1/source_definitions")
@Context
public class SourceDefinitionApiController implements SourceDefinitionApi {

private final SourceDefinitionsHandler sourceDefinitionsHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import io.airbyte.commons.features.FeatureFlags;
import io.airbyte.commons.temporal.TemporalClient;
import io.airbyte.commons.temporal.config.WorkerMode;
import io.airbyte.commons.version.AirbyteProtocolVersionRange;
import io.airbyte.commons.version.AirbyteVersion;
import io.airbyte.commons.version.Version;
import io.airbyte.config.Configs.DeploymentMode;
import io.airbyte.config.Configs.TrackingStrategy;
import io.airbyte.config.persistence.ConfigRepository;
Expand Down Expand Up @@ -111,6 +113,13 @@ public AirbyteGithubStore airbyteGithubStore() {
return AirbyteGithubStore.production();
}

@Singleton
public AirbyteProtocolVersionRange airbyteProtocolVersionRange(
@Value("${airbyte.protocol.min-version}") final String minVersion,
@Value("${airbyte.protocol.max-version}") final String maxVersion) {
return new AirbyteProtocolVersionRange(new Version(minVersion), new Version(maxVersion));
}

private <T> T convertToEnum(final String value, final Function<String, T> creatorFunction, final T defaultValue) {
return StringUtils.isNotEmpty(value) ? creatorFunction.apply(value.toUpperCase(Locale.ROOT)) : defaultValue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import io.airbyte.config.ActorDefinitionResourceRequirements;
import io.airbyte.config.ActorType;
import io.airbyte.config.Configs;
import io.airbyte.config.EnvConfigs;
import io.airbyte.config.StandardSourceDefinition;
import io.airbyte.config.persistence.ConfigNotFoundException;
import io.airbyte.config.persistence.ConfigRepository;
Expand All @@ -43,6 +42,7 @@
import io.airbyte.server.scheduler.SynchronousSchedulerClient;
import io.airbyte.server.services.AirbyteGithubStore;
import io.airbyte.validation.json.JsonValidationException;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import java.io.IOException;
import java.net.URI;
Expand All @@ -65,26 +65,29 @@ public class SourceDefinitionsHandler {
private final SourceHandler sourceHandler;
private final AirbyteProtocolVersionRange protocolVersionRange;

// TODO: remove this contructor after the migration is done
@Deprecated(forRemoval = true)
public SourceDefinitionsHandler(final ConfigRepository configRepository,
final SynchronousSchedulerClient schedulerSynchronousClient,
final SourceHandler sourceHandler) {
this(configRepository, UUID::randomUUID, schedulerSynchronousClient, AirbyteGithubStore.production(), sourceHandler);
final SourceHandler sourceHandler,
final Configs configs) {
this(configRepository, UUID::randomUUID, schedulerSynchronousClient, AirbyteGithubStore.production(), sourceHandler,
new AirbyteProtocolVersionRange(configs.getAirbyteProtocolVersionMin(), configs.getAirbyteProtocolVersionMax()));
}

@Inject
public SourceDefinitionsHandler(final ConfigRepository configRepository,
final Supplier<UUID> uuidSupplier,
final SynchronousSchedulerClient schedulerSynchronousClient,
final AirbyteGithubStore githubStore,
final SourceHandler sourceHandler) {
final SourceHandler sourceHandler,
final AirbyteProtocolVersionRange protocolVersionRange) {
this.configRepository = configRepository;
this.uuidSupplier = uuidSupplier;
this.schedulerSynchronousClient = schedulerSynchronousClient;
this.githubStore = githubStore;
this.sourceHandler = sourceHandler;

// TODO inject protocol min and max once this handler is being converted to micronaut
final Configs configs = new EnvConfigs();
protocolVersionRange = new AirbyteProtocolVersionRange(configs.getAirbyteProtocolVersionMin(), configs.getAirbyteProtocolVersionMax());
this.protocolVersionRange = protocolVersionRange;
}

@VisibleForTesting
Expand Down
3 changes: 3 additions & 0 deletions airbyte-server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ airbyte:
url: ${WEBAPP_URL:}
workspace:
root: ${WORKSPACE_ROOT}
protocol:
min-version: ${AIRBYTE_PROTOCOL_VERSION_MIN:0.0.0}
max-version: ${AIRBYTE_PROTOCOL_VERSION_MAX:0.3.0}

temporal:
cloud:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import io.airbyte.commons.docker.DockerUtils;
import io.airbyte.commons.json.Jsons;
import io.airbyte.commons.version.AirbyteProtocolVersionRange;
import io.airbyte.commons.version.Version;
import io.airbyte.config.ActorDefinitionResourceRequirements;
import io.airbyte.config.ActorType;
import io.airbyte.config.Configs;
Expand Down Expand Up @@ -77,6 +78,7 @@ class SourceDefinitionsHandlerTest {
private AirbyteGithubStore githubStore;
private SourceHandler sourceHandler;
private UUID workspaceId;
private AirbyteProtocolVersionRange protocolVersionRange;

@SuppressWarnings("unchecked")
@BeforeEach
Expand All @@ -90,7 +92,10 @@ void setUp() {

sourceDefinition = generateSourceDefinition();

sourceDefinitionsHandler = new SourceDefinitionsHandler(configRepository, uuidSupplier, schedulerSynchronousClient, githubStore, sourceHandler);
protocolVersionRange = new AirbyteProtocolVersionRange(new Version("0.0.0"), new Version("0.3.0"));

sourceDefinitionsHandler = new SourceDefinitionsHandler(configRepository, uuidSupplier, schedulerSynchronousClient, githubStore, sourceHandler,
protocolVersionRange);
}

private StandardSourceDefinition generateSourceDefinition() {
Expand Down