-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a runtime check for V3 migration (#484)
- Loading branch information
Showing
3 changed files
with
59 additions
and
4 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
onyxia-api/src/main/java/fr/insee/onyxia/api/configuration/checks/V3Checks.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package fr.insee.onyxia.api.configuration.checks; | ||
|
||
import fr.insee.onyxia.api.configuration.properties.RegionsConfiguration; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.event.ContextRefreshedEvent; | ||
import org.springframework.context.event.EventListener; | ||
|
||
@Configuration | ||
public class V3Checks { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(V3Checks.class); | ||
|
||
private final RegionsConfiguration regionsConfiguration; | ||
|
||
private final Runnable exitHandler; | ||
|
||
@Autowired | ||
public V3Checks(RegionsConfiguration regionsConfiguration) { | ||
this(regionsConfiguration, () -> System.exit(0)); | ||
} | ||
|
||
public V3Checks(RegionsConfiguration regionsConfiguration, Runnable exitHandler) { | ||
this.regionsConfiguration = regionsConfiguration; | ||
this.exitHandler = exitHandler; | ||
} | ||
|
||
@EventListener(ContextRefreshedEvent.class) | ||
public void checkDefaultConfigurationIsNoLongerSupported() { | ||
regionsConfiguration | ||
.getResolvedRegions() | ||
.forEach( | ||
region -> { | ||
if (region.getServices().getDefaultConfiguration() != null) { | ||
LOGGER.error( | ||
"FATAL : Setting defaultConfiguration in region is no longer supported and has been replaced by JSONSchema support. See migration guide at https://docs.onyxia.sh/admin-doc/migration-guides/v8-greater-than-v9"); | ||
exitHandler.run(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters