nzw921rx opened a new pull request, #11122:
URL: https://github.com/apache/seatunnel/pull/11122
## Purpose of this pull request
Related #11007
1. Migrate Elasticsearch connector validation from imperative checks to
declarative `OptionRule + Conditions`
2. Remove redundant runtime validation in Source/Auth providers where checks
are now covered by `optionRule()`
3. Add factory-level unit tests for Source/Sink/Catalog to cover positive
and negative validation paths
**Scope migrated:**
- `ElasticsearchSourceFactory`
- `ElasticsearchSinkFactory`
- `ElasticSearchCatalogFactory`
- `ElasticsearchSource` (remove constructor-side config checks now handled
by `optionRule`)
- `BasicAuthProvider` / `ApiKeyAuthProvider` / `ApiKeyEncodedAuthProvider`
(remove redundant validate checks)
- New shared validator utility: `ElasticsearchValidators`
## Does this PR introduce _any_ user-facing change?
Yes, minor validation behavior improvements:
1. **Earlier and clearer submission-time validation**
- Rejects invalid configs at submission time instead of failing later at
runtime.
- Examples:
- Source requires at least one of `index` / `index_list`
- `search_type=SQL` requires non-blank `sql_query`
- `username` / `password` must appear together
- `auth_type=api_key` requires non-blank `auth.api_key_id` and
`auth.api_key`
- `auth_type=api_key_encoded` requires non-blank and valid Base64
`id:key` format
2. **Aggregated validation errors**
- New `ConditionExtension` validators return `false` (instead of
throwing), so multiple config issues can be returned together in one validation
result.
3. **Catalog validation is now fully declared**
- `ElasticSearchCatalogFactory` now defines
required/optional/auth-related rules in `optionRule()`, enabling consistent
validation metadata export via REST API and CLI.
## How was this patch tested?
```bash
./mvnw spotless:apply -pl seatunnel-connectors-v2/connector-elasticsearch
./mvnw test -pl seatunnel-connectors-v2/connector-elasticsearch \
-Dtest="ElasticsearchSourceFactoryTest,ElasticsearchSinkFactoryTest,ElasticSearchCatalogFactoryTest,ElasticsearchFactoryTest"
\
-DfailIfNoTests=false
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]