Skip to content

Commit

Permalink
add r2dbc detecting (#952)
Browse files Browse the repository at this point in the history
Co-authored-by: kaiqianyang <kaiqianyang@microsoftcom>
  • Loading branch information
KaiqianYang and kaiqianyang committed May 22, 2023
1 parent 0a238ac commit f87d51b
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,24 @@
<rules>
<rule id="spring-boot-to-azure-database-jdbc-01000">
<when>
<filecontent filename="application{*}.{extensions}" pattern="jdbc:"/>
<or>
<filecontent filename="application{*}.{extensions}" pattern="jdbc:"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.url"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.u-r-l"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.jdbc-url"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.username"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.user"/>
<filecontent filename="application{*}.{extensions}" pattern="datasource.password"/>
<filecontent filename="application{*}.{extensions}" pattern="jdbc.url"/>
<filecontent filename="application{*}.{extensions}" pattern="jdbc.username"/>
<filecontent filename="application{*}.{extensions}" pattern="jdbc.password"/>
</or>
</when>
<perform>
<hint title="JDBC connection found in configuration file" category-id="information" effort="0">
<message>
<![CDATA[
The application uses a JDBC connection string.
The application uses a JDBC connection string, username or password in the configuration file.
Checkout the different types of databases that are fully managed on Azure.
]]>
Expand All @@ -45,7 +56,12 @@
</rule>
<rule id="spring-boot-to-azure-database-mongodb-02000">
<when>
<filecontent filename="application{*}.{extensions}" pattern="mongodb:"/>
<or>
<filecontent filename="application{*}.{extensions}" pattern="mongodb:"/>
<filecontent filename="application{*}.{extensions}" pattern="mongodb.uri"/>
<filecontent filename="application{*}.{extensions}" pattern="mongodb.username"/>
<filecontent filename="application{*}.{extensions}" pattern="mongodb.password"/>
</or>
</when>
<perform>
<hint title="MongoDB connection found in configuration file" category-id="information" effort="0">
Expand All @@ -67,5 +83,35 @@
<matches pattern="(properties|yaml|yml)"/>
</where>
</rule>
<rule id="spring-boot-to-azure-database-r2dbc-03000">
<when>
<or>
<filecontent filename="application{*}.{extensions}" pattern="r2dbc:"/>
<filecontent filename="application{*}.{extensions}" pattern="r2dbc.username"/>
<filecontent filename="application{*}.{extensions}" pattern="r2dbc.password"/>
<filecontent filename="application{*}.{extensions}" pattern="r2dbc.url"/>
</or>
</when>
<perform>
<hint title="R2DBC connection found in configuration file" category-id="information" effort="0">
<message>
<![CDATA[
The application uses a R2DBC connection string, username or password in the configuration file.
Checkout the different types of databases that are fully managed on Azure.
]]>
</message>
<link title="R2DBC connection string found in configuration file" href="https://learn.microsoft.com/azure/developer/java/migration/migrate-spring-boot-to-azure-spring-apps#databases"/>
<link title="Types of Databases on Azure" href="https://azure.microsoft.com/product-categories/databases/"/>
<link title="Use Spring Data R2DBC with Azure Database for MySQL" href="https://learn.microsoft.com/azure/developer/java/spring-framework/configure-spring-data-r2dbc-with-azure-mysql"/>
<link title="Use Spring Data R2DBC with Azure Database for PostgreSQL" href="https://learn.microsoft.com/azure/developer/java/spring-framework/configure-spring-data-r2dbc-with-azure-postgresql" />
<link title="Use Spring Data R2DBC with Azure SQL Database" href="https://learn.microsoft.com/azure/developer/java/spring-framework/configure-spring-data-r2dbc-with-azure-sql-server"/>
<tag>r2dbc</tag>
</hint>
</perform>
<where param="extensions">
<matches pattern="(properties|yaml|yml)"/>
</where>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
spring.datasource.url=mongodb://mongouser:deepsecret@mongoserver.contoso.com:27017
spring.datasource.username=dbuser
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.data.mongodb.uri=mongodb://mongouser:deepsecret@mongoserver.contoso.com:27017/mydatabase
spring.data.mongodb.username=dbuser
spring.data.mongodb.password=dbpass
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
spring.r2dbc.url=r2dbc:mysql://localhost:3306/mysql_db
spring.r2dbc.username=root
spring.r2dbc.password=root

Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
spring:
data:
jdbc:
uri: jdbc:mysql://localhost:3306/mysql_db
pwd: admin1234567890
datasource:
url: jdbc:mysql://localhost:3306/mysql_db
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<rule id="spring-boot-to-azure-database-jdbc-test-01000">
<when>
<not>
<iterable-filter size="3">
<iterable-filter size="2">
<hint-exists message="The application uses a JDBC connection string"/>
</iterable-filter>
</not>
Expand All @@ -29,6 +29,18 @@
<fail message="Mongo hint was not found!"/>
</perform>
</rule>
<rule id="spring-boot-to-azure-database-r2dbc-test-02000">
<when>
<not>
<iterable-filter size="1">
<hint-exists message="The application uses a R2DBC connection string"/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="r2dbc hint was not found!"/>
</perform>
</rule>
</rules>
</ruleset>
</ruletest>

0 comments on commit f87d51b

Please sign in to comment.