Skip to content

Commit 1564882

Browse files
authored
Merge pull request #2 from rundeck/script-plugins
different templates for script generator
2 parents ef66a34 + c0aa3c0 commit 1564882

44 files changed

Lines changed: 636 additions & 39 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,32 @@ Download the tar or zip distribution, cd to the bin directory, and run:
88

99
./rundeck-plugin-bootstrap -n MyRundeckPlugin -t java -s Notification -d /tmp
1010

11-
A Java notification plugin will be created at /tmp/myrundeckplugin. You can cd into that directory,
12-
run `gradle build` and you will have an installable notification plugin that you can put in your Rundeck installation.
11+
A Java/Script notification plugin will be created at /tmp/myrundeckplugin. You can cd into that directory,
12+
run `gradle build` and you will have an installable plugin that you can put in your Rundeck installation.
1313

14-
* Note: At this time only Notification plugins can be bootstrapped with this utility.
1514

16-
Other examples:
15+
## Existing service plugins enabled on boostrap-plugin
16+
17+
Java Plugins:
18+
* ResourceModelSource
19+
* Notification
20+
* WorkflowStep
21+
* WorkflowNodeStep
22+
23+
Script Plugins:
24+
* ResourceModelSource
25+
* WorkflowNodeStep
26+
* RemoteScriptNodeStep
27+
* NodeExecutor
28+
* FileCopier
29+
* NodeExecutorFileCopier: Generate both, Node Executor and File Copier service
30+
31+
## Other Examples:
1732

1833
Create a script plugin:
1934

20-
./rundeck-plugin-bootstrap -n MyNodeExecutorPlugin -t script -s NodeExecutor /tmp
35+
./rundeck-plugin-bootstrap -n MyNodeExecutorPlugin -t script -s NodeExecutor -d /tmp
2136

2237
Create a UI script plugin:
2338

24-
./rundeck-plugin-bootstrap -n MyUIPlugin -t ui -s UI /tmp
39+
./rundeck-plugin-bootstrap -n MyUIPlugin -t ui -s UI -d /tmp

src/main/groovy/com/rundeck/plugin/generator/JavaPluginTemplateGenerator.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class JavaPluginTemplateGenerator extends AbstractTemplateGenerator {
2424
private static final String TEMPLATE_BASE = "templates/java-plugin/"
2525
private static final String JAVA_STRUCTURE = "java-plugin.structure"
2626

27-
private static final List ALLOWED_TEMPLATES = ["ResourceModel","Notification","WorkflowStep","WorkflowNodeStep"]
27+
private static final List ALLOWED_TEMPLATES = ["ResourceModelSource","Notification","WorkflowStep","WorkflowNodeStep"]
2828

2929
@Override
3030
Map makeTemplateProperties(final String pluginName, final String providedService) {

src/main/groovy/com/rundeck/plugin/generator/ScriptPluginTemplateGenerator.groovy

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ScriptPluginTemplateGenerator extends AbstractTemplateGenerator {
2424
private static final String TEMPLATE_BASE = "templates/script-plugin/"
2525
private static final String SCRIPT_STRUCTURE = "script-plugin.structure"
2626

27-
private static final List<String> ALLOWED_SERVICE_TYPES = ["NodeExecutor","FileCopier","ResourceModelSource","WorkflowNodeStep","RemoteScriptNodeStep"]
27+
private static final List<String> ALLOWED_SERVICE_TYPES = ["NodeExecutor","FileCopier","ResourceModelSource","WorkflowNodeStep","RemoteScriptNodeStep","NodeExecutorFileCopier"]
2828

2929
@Override
3030
Map makeTemplateProperties(final String pluginName, final String providedService) {
@@ -39,7 +39,8 @@ class ScriptPluginTemplateGenerator extends AbstractTemplateGenerator {
3939

4040
@Override
4141
URL getPluginStructure(final String providedService) {
42-
return getClass().getClassLoader().getResource("${TEMPLATE_BASE}${SCRIPT_STRUCTURE}")
42+
String path = this.getTemplatePath(providedService)
43+
return getClass().getClassLoader().getResource("${TEMPLATE_BASE}${path}/${SCRIPT_STRUCTURE}")
4344
}
4445

4546
@Override
@@ -56,6 +57,25 @@ class ScriptPluginTemplateGenerator extends AbstractTemplateGenerator {
5657

5758
@Override
5859
String resolveTemplateName(final String providedService, final String templateName) {
59-
return "${getTemplateBase()}$templateName"
60+
String path = this.getTemplatePath(providedService)
61+
return "${getTemplateBase()}${path}/$templateName"
62+
}
63+
64+
String getTemplatePath(final String providedService){
65+
String path=""
66+
switch (providedService){
67+
case ["WorkflowNodeStep","RemoteScriptNodeStep"] :
68+
path="workflow"
69+
break
70+
case ["FileCopier","NodeExecutor","ResourceModelSource"]:
71+
path=providedService.toLowerCase()
72+
break
73+
case "NodeExecutorFileCopier":
74+
path="nodeexecutor-filecopier"
75+
break
76+
77+
}
78+
79+
return path
6080
}
6181
}

src/main/resources/templates/java-plugin/resourcemodel/Plugin.java.template renamed to src/main/resources/templates/java-plugin/resourcemodelsource/Plugin.java.template

File renamed without changes.

src/main/resources/templates/java-plugin/resourcemodel/PluginSpec.groovy.template renamed to src/main/resources/templates/java-plugin/resourcemodelsource/PluginSpec.groovy.template

File renamed without changes.

src/main/resources/templates/java-plugin/resourcemodel/README.md.template renamed to src/main/resources/templates/java-plugin/resourcemodelsource/README.md.template

File renamed without changes.

src/main/resources/templates/java-plugin/resourcemodel/build.gradle.template renamed to src/main/resources/templates/java-plugin/resourcemodelsource/build.gradle.template

File renamed without changes.

src/main/resources/templates/java-plugin/resourcemodel/icon.png renamed to src/main/resources/templates/java-plugin/resourcemodelsource/icon.png

File renamed without changes.

src/main/resources/templates/java-plugin/resourcemodel/java-plugin.structure renamed to src/main/resources/templates/java-plugin/resourcemodelsource/java-plugin.structure

File renamed without changes.

src/main/resources/templates/script-plugin/README.md.template

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)