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

add restricted config rule for azure spring apps #1017

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruleset id="spring-boot-to-azure-restricted-config"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<metadata>
<description>
This ruleset identifies restricted configurations in Spring Boot applications for migration to Azure Spring Apps.
</description>
<dependencies>
<addon id="org.jboss.windup.rules,windup-rules-xml,3.0.0.Final" />
</dependencies>
<sourceTechnology id="springboot"/>
<targetTechnology id="azure-spring-apps"/>
</metadata>
<rules>
<rule id="spring-boot-to-azure-restricted-config-01000">
<when>
<or>
<filecontent filename="{*}.{extensions}" pattern="{pattern}"/>
</or>
</when>
<perform>
<hint title="Restricted configurations found" category-id="information" effort="0">
<message>
The application uses restricted configurations for Azure Spring Apps.
These properties are automatically injected into your application environment by Azure Spring Apps to access Config Server and Service Discovery.
Please remove them from your application, including configuration files, config server files, command line parameters, Java system attributes, and environment variables.

If configured in **configuration files**: they will be ignored and overrided by Azure Spring Apps.

If configured in **Config Server files**, **command line parameters**, **Java system attribute**, **environment variable**: they need to be removed or you might experience conflicts and unexpected behavior.
</message>
<link title="Remove restricted configurations" href="http://aka.ms/spring-cloud-to-asa?toc=%2Fazure%2Fspring-apps%2Ftoc.json&amp;bc=%2Fazure%2Fspring-apps%2Fbreadcrumb%2Ftoc.json&amp;pivots=sc-standard-tier#remove-restricted-configurations"/>
<link title="Set up a Config server" href="https://learn.microsoft.com/azure/spring-apps/how-to-config-server"/>
<link title="Enable Service Registration" href="https://learn.microsoft.com/azure/spring-apps/how-to-service-registration?pivots=programming-language-java"/>
</hint>
</perform>
<where param="extensions">
<matches pattern="(properties|yaml|yml)"/>
</where>
<where param="pattern">
<matches pattern="(eureka\.client\.(serviceUrl\.defaultZone|service-url\.defaultZone))|(eureka\.client\.tls\.keystore)|(eureka\.instance\.preferIpAddress)|(eureka\.instance\.instance-id)|(server\.port)|(spring\.cloud\.config\.tls\.keystore)|(spring\.config\.import)|(spring\.application\.name)|(spring\.jmx\.enabled)|(management\.endpoints\.jmx\.exposure\.include)"/>
</where>
</rule>
</rules>
</ruleset>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eureka.client.service-url.defaultZone = https://localhost:8761/eureka/
eureka.client.tls.keystore = classpath:keystore.jks
fake.fake = fake
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
eureka.instance.preferIpAddress = true
server.port = 8761
spring.cloud.config.tls.keystore = classpath:configserver.jks
spring.config.import = configserver:http://localhost:8888
spring.jmx.enabled = true
management.endpoints.jmx.exposure.include=*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
spring.application.name: demo
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<ruletest id="spring-boot-to-azure-restricted-config-test"
xmlns="http://windup.jboss.org/schema/jboss-ruleset"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://windup.jboss.org/schema/jboss-ruleset http://windup.jboss.org/schema/jboss-ruleset/windup-jboss-ruleset.xsd">
<testDataPath>data/spring-boot-to-azure-restricted-config</testDataPath>
<rulePath>../spring-boot-to-azure-restricted-config.windup.xml</rulePath>
<target>azure-spring-apps</target>
<ruleset>
<rules>
<rule id="spring-boot-to-azure-restricted-config-test-01000">
<when>
<not>
<iterable-filter size="9">
<hint-exists message="The application uses restricted configurations for Azure Spring Apps."/>
</iterable-filter>
</not>
</when>
<perform>
<fail message="spring-boot-to-azure-restricted-config hint was not found!"/>
</perform>
</rule>
</rules>
</ruleset>
</ruletest>