Skip to content

Commit

Permalink
Remove lookup by profile when updating configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Jan 25, 2023
1 parent 8c95e20 commit ce0e690
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package io.quarkus.vertx.http.deployment.devmode.console;

import static io.quarkus.runtime.LaunchMode.DEVELOPMENT;

import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.file.Files;
Expand Down Expand Up @@ -46,7 +44,6 @@
import io.quarkus.devconsole.runtime.spi.DevConsolePostHandler;
import io.quarkus.devconsole.spi.DevConsoleRouteBuildItem;
import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem;
import io.quarkus.runtime.configuration.ConfigUtils;
import io.quarkus.vertx.http.runtime.devmode.ConfigDescription;
import io.quarkus.vertx.http.runtime.devmode.ConfigDescriptionsManager;
import io.quarkus.vertx.http.runtime.devmode.ConfigDescriptionsRecorder;
Expand Down Expand Up @@ -215,25 +212,18 @@ static void updateConfig(Map<String, String> values) {
if (values != null && !values.isEmpty()) {
try {
Path configPath = getConfigPath();
List<String> profiles = ConfigUtils.getProfiles();
List<String> lines = Files.readAllLines(configPath);
for (Map.Entry<String, String> entry : values.entrySet()) {
String name = entry.getKey();
String value = entry.getValue();
int nameLine = -1;
for (int i = 0, linesSize = lines.size(); i < linesSize; i++) {
String line = lines.get(i);
for (String profile : profiles) {
String profileName = !profile.equals(DEVELOPMENT.getDefaultProfile()) ? "%" + profile + "." + name
: name;
if (line.startsWith(profileName + "=")) {
name = profileName;
nameLine = i;
break;
}
if (line.startsWith(name + "=")) {
nameLine = i;
break;
}
}

if (nameLine != -1) {
if (value.isEmpty()) {
lines.remove(nameLine);
Expand Down

0 comments on commit ce0e690

Please sign in to comment.