Skip to content

Commit

Permalink
Merge pull request #317 from emmartins/CMTOOL-368
Browse files Browse the repository at this point in the history
[CMTOOL-368] only adds subsystem configs to leaf profiles
  • Loading branch information
emmartins authored May 14, 2024
2 parents 986fced + c7c641b commit 596171b
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import org.jboss.migration.core.task.ServerMigrationTaskName;
import org.jboss.migration.core.task.ServerMigrationTaskResult;
import org.jboss.migration.core.task.TaskContext;
import org.jboss.migration.wfly10.config.management.ProfileResource;
import org.jboss.migration.wfly10.config.management.SubsystemResource;
import org.jboss.migration.wfly10.config.task.management.resource.ManageableResourceBuildParameters;
import org.jboss.migration.wfly10.config.task.management.resource.ManageableResourceLeafTask;
Expand All @@ -38,10 +39,19 @@ public AddSubsystemResourceSubtaskBuilder(String subsystem) {
nameBuilder(parameters -> new ServerMigrationTaskName.Builder("subsystem."+subsystem+".add-config").addAttribute("name", parameters.getResource().getResourceAbsoluteName()).build());
runBuilder(params -> taskContext -> {
SubsystemResource.Parent parent = params.getResource();
// skip if subsystem already exists in current "profile"
if (parent.hasSubsystemResource(subsystem)) {
taskContext.getLogger().debugf("Skipped adding subsystem config %s, already exists.", parent.getSubsystemResourceAbsoluteName(subsystem));
return ServerMigrationTaskResult.SKIPPED;
}
// skip if parent is a profile that includes another profile, we only add configurations to leaf profiles (prevents CMTOOL-368)
if (parent.getResourceType() == ProfileResource.RESOURCE_TYPE) {
final String includes = parent.getResourceConfiguration().get("includes").asStringOrNull();
if (includes != null) {
taskContext.getLogger().warnf("Subsystem to be added on profile %s, which includes profile(s) %s, skipping...", parent.getResourceName(), includes);
return ServerMigrationTaskResult.SKIPPED;
}
}
final String configName = parent.getSubsystemResourceAbsoluteName(subsystem);
taskContext.getLogger().debugf("Adding subsystem config %s...", configName);
addConfiguration(params, taskContext);
Expand Down

0 comments on commit 596171b

Please sign in to comment.