-
Notifications
You must be signed in to change notification settings - Fork 809
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(plugins): allow more than one SimpleStage impl (#3574)
* fix(plugins): allow more than one SimpleStage impl Multiple SimpleStages keeps Orca from starting because SimpleTask had a Component annotation and SimpleStage in the constructor. Orca would try to construct all the Tasks for taskResolver and when it got to SimpleTask it wouldn't know which SimpleStage to inject. So SimpleTask obviously shouldn't be a component. But once the Component annotation was removed it would not execute SimpleStages. The TaskResolver now needs to load all the SimpleStages and wrap each on as a SimpleTask. They need to be keyed by the SimpleStage impl class name, they can't all be keyed as SimpleTask. But you could only use classes of type Task, even though it ultimately just gets turned into a String. On the other side the RunTaskHandler looked up tasks based on a list of Task components and SimpleTask is no longer in that list. Now RunTaskHandler looks up tasks using the TaskResolver. Doesn't it make more sense to use the TaskResolver to resolve tasks anyway? I also uses the implementingClass to look up the task rather than the RunTask.taskType because it would only be SimpleTask when someone is using SimpleStages. This seems cleaner but we still use RunTask.taskType and resolve the task based on type as a backup mainly for existing tests. * add docs to SimpleTaskDefinition
- Loading branch information
Showing
9 changed files
with
280 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
orca-api/src/main/java/com/netflix/spinnaker/orca/api/simplestage/SimpleTaskDefinition.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2020 Armory, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.netflix.spinnaker.orca.api.simplestage; | ||
|
||
import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode; | ||
import com.netflix.spinnaker.orca.api.pipeline.graph.TaskNode.DefinedTask; | ||
import javax.annotation.Nonnull; | ||
|
||
/** | ||
* Provides a TaskDefinition for a SimpleStage which will be wrapped in a SimpleTask. SimpleTask | ||
* alone is not enough information to disambiguate the implementing class. | ||
*/ | ||
public class SimpleTaskDefinition implements TaskNode, DefinedTask { | ||
private final String name; | ||
private final Class<? extends SimpleStage> implementingClass; | ||
|
||
/** | ||
* @param name The name of the SimpleStage that gets executed | ||
* @param implementingClass The SimpleStage class type that will be referenced by the task | ||
* resolver | ||
*/ | ||
public SimpleTaskDefinition( | ||
@Nonnull String name, @Nonnull Class<? extends SimpleStage> implementingClass) { | ||
this.name = name; | ||
this.implementingClass = implementingClass; | ||
} | ||
|
||
@Override | ||
public @Nonnull String getName() { | ||
return name; | ||
} | ||
|
||
/** @return the SimpleStage class that will be executed by the task */ | ||
public @Nonnull Class<? extends SimpleStage> getImplementingClass() { | ||
return implementingClass; | ||
} | ||
|
||
@Override | ||
public @Nonnull String getImplementingClassName() { | ||
return getImplementingClass().getCanonicalName(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.