Skip to content

Commit

Permalink
add: enabled/disabled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
kochetkov-ma committed Jul 1, 2024
1 parent 3fbfb17 commit e003e86
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,29 @@ private static Path extractDefaultPlugin() {
}

public Path generate(Path outputDirectory, List<Path> resultsDirectories, String reportUrl) {
listeners.parallelStream().forEach(listener -> evaluateListener(() -> listener.onGenerationStart(resultsDirectories, new PluginContext(reportUrl)), listener.getName(), "before generation"));
var ctx = new PluginContext(reportUrl);

var effectiveListeners = listeners.stream()
.filter(it -> {
if (it.isEnabled(ctx))
return true;
log.info("[PLUGIN] Plugin '{} : {}' is disabled", it.getName(), it.getClass().getName());
return false;
})
.toList();

effectiveListeners.parallelStream()
.forEach(listener -> evaluateListener(() -> listener.onGenerationStart(resultsDirectories, ctx), listener.getName(), "before generation"));

final Collection<LaunchResults> launchesResults;
synchronized (aggregatorGrabber) {
delegate.generate(outputDirectory, resultsDirectories);
launchesResults = aggregatorGrabber.launchesResults();
}

listeners.parallelStream().forEach(listener -> evaluateListener(() -> listener.onGenerationFinish(outputDirectory, launchesResults, new PluginContext(reportUrl)), listener.getName(), "after generation"));
effectiveListeners.parallelStream()
.forEach(listener -> evaluateListener(() -> listener.onGenerationFinish(outputDirectory, launchesResults, ctx), listener.getName(), "after generation"));

return outputDirectory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public interface AllureServerPlugin {

String getName();

default boolean isEnabled(Context context) {
return true;
}

interface Context {

AllureProperties getAllureProperties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public YouTrackPlugin() {
this.dryRun = false;
}

@Override
public boolean isEnabled(Context context) {
return context.tmsProperties().isEnabled();
}

@Override
public void onGenerationStart(Collection<Path> resultsDirectories, Context context) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
@ConfigurationProperties(prefix = "tms")
public class TmsProperties {

private final boolean enabled;
private final String host;
private final String apiBaseUrl;
private final String project;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ logging:
ru.iopump.qa.allure.api: DEBUG

tms:
enabled: false
host: tms.localhost
api-base-url: https://${tms.host}/api
token: "my-token"
Expand Down

0 comments on commit e003e86

Please sign in to comment.