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

ValidateUri configured in CosmosProperties #23641

Merged
merged 6 commits into from
Aug 30, 2021
Merged

ValidateUri configured in CosmosProperties #23641

merged 6 commits into from
Aug 30, 2021

Conversation

backwind1233
Copy link
Contributor

@backwind1233 backwind1233 commented Aug 18, 2021

azure-spring-data-cosmos does not support mongdb, if azure.cosmos.uri configured with mongdb, thrown an exception.

Reference

github repo: azure-spring-data-cosmos

Azure Spring Data Cosmos provides Spring Data support for Azure Cosmos DB using the SQL API, based on Spring Data framework. Azure Cosmos DB is a globally-distributed database service which allows developers to work with data using a variety of standard APIs, such as SQL, MongoDB, Cassandra, Graph, and Table.

Azure Cosmos DB Resource URI Syntax for REST

@@ -137,4 +144,10 @@ public ConnectionMode getConnectionMode() {
public void setConnectionMode(ConnectionMode connectionMode) {
this.connectionMode = connectionMode;
}

private void validateUri() {
if (StringUtils.startsWithIgnoreCase(uri, "mongodb://")) {

Choose a reason for hiding this comment

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

How about using allow list instead of blocking list?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

which blocking list? I don't understand you.

Choose a reason for hiding this comment

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

Your current implementation is blocking mongodb://.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

can you give me an example?😂

Choose a reason for hiding this comment

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

private static final List<String> SUPPORTED_URI_PREFIX = Arrays.asList("foo", "bar", ...);

@backwind1233
Copy link
Contributor Author

Hi @chenrujun, please help review this PR, I will handle the pipeline error.😀

Copy link

@chenrujun chenrujun left a comment

Choose a reason for hiding this comment

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

LGTM except the variable name.


private static final Logger LOGGER = LoggerFactory.getLogger(CosmosProperties.class);

public static final String URIPATTERN = "http[s]{0,1}://.*.documents.azure.com.*";

Choose a reason for hiding this comment

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

nit : URIPATTERN -> URI_REGEX

@backwind1233 backwind1233 merged commit bad2166 into Azure:main Aug 30, 2021
@backwind1233 backwind1233 deleted the 210812_mongdb_gzh branch August 30, 2021 09:23
@backwind1233
Copy link
Contributor Author

Hi @kushagraThapar,could you please help reivew this PR, help check the uri pattern for cosmosdb? did I miss something?

azure-sdk pushed a commit to azure-sdk/azure-sdk-for-java that referenced this pull request Apr 20, 2023
mgmt, add "timeCreated" to "VirtualMachineScaleSetVMProperties" (Azure#23641)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
azure-spring All azure-spring related issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't configure uri to cosmos mongo db using: mongodb://username:password@host:10255/database?ssl=true
2 participants