Skip to content

Commit

Permalink
feat(plugins): Back orca stage plugins via PF4J (#3248)
Browse files Browse the repository at this point in the history
  • Loading branch information
robzienert authored and mergify[bot] committed Oct 25, 2019
1 parent 2d858cf commit ff6fcb9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
2 changes: 2 additions & 0 deletions orca-api/orca-api.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ test {
}

dependencies {
api "com.netflix.spinnaker.kork:kork-plugins-api"

implementation("com.google.guava:guava")

compileOnly("org.projectlombok:lombok")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.netflix.spinnaker.orca.api;

import com.google.common.annotations.Beta;
import org.pf4j.ExtensionPoint;

/**
* This should be used by plugin developers to create plugin stages.
Expand All @@ -25,7 +26,7 @@
* fields that are required for the stage to run.
*/
@Beta
public interface SimpleStage<T> {
public interface SimpleStage<T> extends ExtensionPoint {
/**
* When this stage runs, the execute method gets called. It takes in a class that is created that
* has the data needed by the stage. It returns a class that contains the status of the stage,
Expand All @@ -36,10 +37,6 @@ public interface SimpleStage<T> {
*/
SimpleStageOutput execute(SimpleStageInput<T> simpleStageInput);

/**
* Sets the name of the stage
*
* @return name of the stage
*/
/** @return name of the stage */
String getName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ public StageResolver(
}
}

simpleStages.stream()
.forEach(
s ->
stageDefinitionBuilderByAlias.put(
s.getName(), new SimpleStageDefinitionBuilder(s)));
simpleStages.forEach(
s -> stageDefinitionBuilderByAlias.put(s.getName(), new SimpleStageDefinitionBuilder(s)));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,10 @@ public TaskResolver taskResolver(Collection<Task> tasks) {
@Bean
public StageResolver stageResolver(
Collection<StageDefinitionBuilder> stageDefinitionBuilders,
Optional<Collection<SimpleStage>> simpleStages) {
Optional<Collection<SimpleStage>> simpleStages,
PluginManager pluginManager) {
Collection<SimpleStage> stages = simpleStages.orElseGet(ArrayList::new);
stages.addAll(pluginManager.getExtensions(SimpleStage.class));
return new StageResolver(stageDefinitionBuilders, stages);
}

Expand Down

0 comments on commit ff6fcb9

Please sign in to comment.