From ff6fcb923ea7edbf666f6fc10324ec7f0c980725 Mon Sep 17 00:00:00 2001 From: Rob Zienert Date: Fri, 25 Oct 2019 12:58:21 -0700 Subject: [PATCH] feat(plugins): Back orca stage plugins via PF4J (#3248) --- orca-api/orca-api.gradle | 2 ++ .../java/com/netflix/spinnaker/orca/api/SimpleStage.java | 9 +++------ .../java/com/netflix/spinnaker/orca/StageResolver.java | 7 ++----- .../netflix/spinnaker/orca/config/OrcaConfiguration.java | 4 +++- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/orca-api/orca-api.gradle b/orca-api/orca-api.gradle index be990c6a4c..e77627b137 100644 --- a/orca-api/orca-api.gradle +++ b/orca-api/orca-api.gradle @@ -24,6 +24,8 @@ test { } dependencies { + api "com.netflix.spinnaker.kork:kork-plugins-api" + implementation("com.google.guava:guava") compileOnly("org.projectlombok:lombok") diff --git a/orca-api/src/main/java/com/netflix/spinnaker/orca/api/SimpleStage.java b/orca-api/src/main/java/com/netflix/spinnaker/orca/api/SimpleStage.java index 157dea18be..16668eba83 100644 --- a/orca-api/src/main/java/com/netflix/spinnaker/orca/api/SimpleStage.java +++ b/orca-api/src/main/java/com/netflix/spinnaker/orca/api/SimpleStage.java @@ -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. @@ -25,7 +26,7 @@ * fields that are required for the stage to run. */ @Beta -public interface SimpleStage { +public interface SimpleStage 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, @@ -36,10 +37,6 @@ public interface SimpleStage { */ SimpleStageOutput execute(SimpleStageInput simpleStageInput); - /** - * Sets the name of the stage - * - * @return name of the stage - */ + /** @return name of the stage */ String getName(); } diff --git a/orca-core/src/main/java/com/netflix/spinnaker/orca/StageResolver.java b/orca-core/src/main/java/com/netflix/spinnaker/orca/StageResolver.java index e547e4b92f..3c9e802e6b 100644 --- a/orca-core/src/main/java/com/netflix/spinnaker/orca/StageResolver.java +++ b/orca-core/src/main/java/com/netflix/spinnaker/orca/StageResolver.java @@ -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))); } /** diff --git a/orca-core/src/main/java/com/netflix/spinnaker/orca/config/OrcaConfiguration.java b/orca-core/src/main/java/com/netflix/spinnaker/orca/config/OrcaConfiguration.java index d4c1c947cd..b7b5894d13 100644 --- a/orca-core/src/main/java/com/netflix/spinnaker/orca/config/OrcaConfiguration.java +++ b/orca-core/src/main/java/com/netflix/spinnaker/orca/config/OrcaConfiguration.java @@ -204,8 +204,10 @@ public TaskResolver taskResolver(Collection tasks) { @Bean public StageResolver stageResolver( Collection stageDefinitionBuilders, - Optional> simpleStages) { + Optional> simpleStages, + PluginManager pluginManager) { Collection stages = simpleStages.orElseGet(ArrayList::new); + stages.addAll(pluginManager.getExtensions(SimpleStage.class)); return new StageResolver(stageDefinitionBuilders, stages); }