-
Notifications
You must be signed in to change notification settings - Fork 174
[backend/frontend] feat(catalog): add catalog connector ingestion data (#4311) #4379
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
Conversation
904924e to
59a39d5
Compare
a7dc269 to
4dbcc90
Compare
openaev-api/src/main/java/io/openaev/runner/CatalogConnectorIngestionRunner.java
Outdated
Show resolved
Hide resolved
openaev-api/src/main/java/io/openaev/runner/CatalogConnectorIngestionRunner.java
Outdated
Show resolved
Hide resolved
openaev-api/src/main/java/io/openaev/runner/CatalogConnectorIngestionRunner.java
Outdated
Show resolved
Hide resolved
openaev-api/src/main/java/io/openaev/rest/catalog_connector/CatalogConnectorApi.java
Outdated
Show resolved
Hide resolved
openaev-front/src/admin/components/integrations/catalog_connectors/ConnectorDetails.tsx
Outdated
Show resolved
Hide resolved
openaev-front/src/admin/components/integrations/catalog_connectors/ConnectorDetails.tsx
Outdated
Show resolved
Hide resolved
openaev-api/src/main/java/io/openaev/service/CatalogConnectorService.java
Outdated
Show resolved
Hide resolved
4081880 to
4625d5e
Compare
| return fileName; | ||
| } catch (Exception e) { | ||
| log.error("Error upload image MinIO", e); | ||
| return "img/icon-connector-default.png"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have default image yet
openaev-api/src/main/java/io/openaev/rest/catalog_connector/CatalogConnectorApi.java
Outdated
Show resolved
Hide resolved
openaev-front/src/admin/components/integrations/catalog_connectors/Index.tsx
Outdated
Show resolved
Hide resolved
openaev-api/src/main/java/io/openaev/rest/catalog_connector/dto/CatalogConnectorOutput.java
Show resolved
Hide resolved
6d54eab to
e5608a5
Compare
| @Slf4j | ||
| @Service | ||
| @Transactional | ||
| public class CatalogConnectorIngestionService { | ||
| private static final Set<String> PROTECTED_KEYS = Set.of( | ||
| "COLLECTOR_ID", | ||
| "INJECTOR_ID", | ||
| "EXECUTOR_ID" | ||
| ); | ||
| private final CatalogConnectorService catalogConnectorService; | ||
| private final FileService fileService; | ||
| private final ConnectorInstanceService connectorInstanceService; | ||
| private final ConnectorInstanceConfigurationRepository connectorInstanceConfigurationRepository; | ||
|
|
||
| public CatalogConnectorIngestionService( | ||
| CatalogConnectorService catalogConnectorService, | ||
| FileService fileService, | ||
| ConnectorInstanceService connectorInstanceService, | ||
| ConnectorInstanceConfigurationRepository connectorInstanceConfigurationRepository) { | ||
| this.catalogConnectorService = catalogConnectorService; | ||
| this.fileService = fileService; | ||
| this.connectorInstanceService = connectorInstanceService; | ||
| this.connectorInstanceConfigurationRepository = connectorInstanceConfigurationRepository; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: to keep source code cleaner (or more "magical"), Lombok provides class annotations to hide constructors such as this one which only assigns instance fields.
@RequiredArgsConstructor on the class allows you to delete this constructor (Lombok will autogenerate it).
| @Slf4j | |
| @Service | |
| @Transactional | |
| public class CatalogConnectorIngestionService { | |
| private static final Set<String> PROTECTED_KEYS = Set.of( | |
| "COLLECTOR_ID", | |
| "INJECTOR_ID", | |
| "EXECUTOR_ID" | |
| ); | |
| private final CatalogConnectorService catalogConnectorService; | |
| private final FileService fileService; | |
| private final ConnectorInstanceService connectorInstanceService; | |
| private final ConnectorInstanceConfigurationRepository connectorInstanceConfigurationRepository; | |
| public CatalogConnectorIngestionService( | |
| CatalogConnectorService catalogConnectorService, | |
| FileService fileService, | |
| ConnectorInstanceService connectorInstanceService, | |
| ConnectorInstanceConfigurationRepository connectorInstanceConfigurationRepository) { | |
| this.catalogConnectorService = catalogConnectorService; | |
| this.fileService = fileService; | |
| this.connectorInstanceService = connectorInstanceService; | |
| this.connectorInstanceConfigurationRepository = connectorInstanceConfigurationRepository; | |
| } | |
| @Slf4j | |
| @Service | |
| @Transactional | |
| @RequiredArgsConstructor | |
| public class CatalogConnectorIngestionService { | |
| private static final Set<String> PROTECTED_KEYS = Set.of( | |
| "COLLECTOR_ID", | |
| "INJECTOR_ID", | |
| "EXECUTOR_ID" | |
| ); | |
| private final CatalogConnectorService catalogConnectorService; | |
| private final FileService fileService; | |
| private final ConnectorInstanceService connectorInstanceService; | |
| private final ConnectorInstanceConfigurationRepository connectorInstanceConfigurationRepository; |
| for (JsonNode contract : contracts) { | ||
| CatalogConnector catalogConnector = buildCatalogConnector(contract); | ||
| catalogConnectorList.add(catalogConnector); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: no error handling here. A lot of things can go wrong in deserialisation situations, so are we prepared for an all-or-nothing ingestion (because the process is transactional) ?
I'm asking because functionally, what are we expecting to see if there is, for example, a single contract throwing an error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm with @jborozco !
| byte[] imageBytes = Base64.getDecoder().decode(base64Data); | ||
| InputStream dataStream = new ByteArrayInputStream(imageBytes); | ||
|
|
||
| String fileName = connectorSlug + "-logo.png"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like this would have the potential for collisions, but not terribly dangerous apart if we accidentally upload the same path elsewhere in the codebase.
Suggestion: using the DB-generated ID for the persisted catalog connector object as one of the filename fragments.
This would have you remove the use of .saveAll(List<CatalogConnector>) in favour of a loop with .save(CatalogConnector) in extractCatalog; but that's OK because we are already within a transaction scope (the overhead of using a loop+save is to create a new transaction scope for each iteration)
@Override
@Transactional
public <S extends T> List<S> saveAll(Iterable<S> entities) {
Assert.notNull(entities, ENTITIES_MUST_NOT_BE_NULL);
List<S> result = new ArrayList<>();
for (S entity : entities) {
result.add(save(entity));
}
return result;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, as discuss we'll not do it now.
| List<CatalogConnector> saved = catalogConnectorService.saveAll(catalogConnectorList); | ||
|
|
||
| for (CatalogConnector connector : saved) { | ||
| cleanupInstanceConfigurations(connector); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good thinking
| // Configuration changed to "PASSWORD" format but the stored value is not encrypted: | ||
| // - schemaConf exists | ||
| // - format is PASSWORD | ||
| // - must be deleted for security | ||
| boolean mustDeleteBecausePassword = | ||
| schemaConf != null && isFormastPasswordButNotEncrypted(schemaConf, instConf); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we should make an effort to encrypt the currently plaintext value with the known XTM Composer public key instead of nuking the config line altogether. What are your thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todo : another PR when the method to encrypt will be merged
|
|
||
| CatalogConnector connector = ingestion.buildCatalogConnector(contract); | ||
|
|
||
| assertThat(connector.getContainerType()).isNull(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this correct? This looks like this could cause issues down the line. What are the impacts of this occurrence?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We keep it like this as discussed
| // required | ||
| boolean isRequired = false; | ||
| if (required != null && required.isArray()) { | ||
| for (JsonNode req : required) { | ||
| if (req.asText().equals(key)) { | ||
| isRequired = true; | ||
| break; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be concerned that perhaps there is an entry in [required] that doesn't match any listed properties? Thoughts?
Note this would meant the contract is malformed. Consider adding some logging.
Signed-off-by: Antoine MAZEAS <[email protected]>
cb3305c to
c9f9b17
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/current #4379 +/- ##
===================================================
Coverage 50.89% 50.89%
- Complexity 3762 3785 +23
===================================================
Files 914 919 +5
Lines 27396 27621 +225
Branches 2059 2098 +39
===================================================
+ Hits 13942 14058 +116
- Misses 12608 12697 +89
- Partials 846 866 +20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Proposed changes
Testing Instructions
Related issues
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...