-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transform a Specification into camtemplate.json and camvariables.json #9
- Loading branch information
Showing
4 changed files
with
161 additions
and
0 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
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
93 changes: 93 additions & 0 deletions
93
...inator/src/main/java/com/rigiresearch/middleware/coordinator/templates/CamTemplates.xtend
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,93 @@ | ||
package com.rigiresearch.middleware.coordinator.templates | ||
|
||
import com.rigiresearch.middleware.metamodels.hcl.Dictionary | ||
import com.rigiresearch.middleware.metamodels.hcl.Resource | ||
import com.rigiresearch.middleware.metamodels.hcl.Specification | ||
import com.rigiresearch.middleware.metamodels.hcl.Text | ||
|
||
/** | ||
* JSON templates for generating CAM's camtemplate.json and camvariables.json. | ||
* @author Miguel Jimenez ([email protected]) | ||
* @version $Id$ | ||
* @since 0.1.0 | ||
*/ | ||
class CamTemplates { | ||
|
||
/** | ||
* Generates the content for camtemplate.json. | ||
*/ | ||
def String template() ''' | ||
{ | ||
"name": "ImportedVmwareResources", | ||
"description": "Imported resources from VMware vSphere", | ||
"type": "userCreated", | ||
"version": "1.0", | ||
"manifest": { | ||
"template_type": "Terraform", | ||
"template_format": "HCL", | ||
"template_provider": "VMware vSphere", | ||
"template": { | ||
"templateOutput": "", | ||
"templateVariables": "", | ||
"templateData": "" | ||
}, | ||
"template_source": { | ||
"githubRepoUrl": "", | ||
"githubAccessToken": "", | ||
"relativePathToTemplateFolder": "", | ||
"templateFileName": "main.tf" | ||
} | ||
}, | ||
"metadata": { | ||
"displayName": "ImportedVmwareResources", | ||
"longDescription": "Imported resources from VMware vSphere", | ||
"bullets": [ | ||
{ | ||
"title": "Clouds", | ||
"description": "VMware" | ||
} | ||
] | ||
} | ||
} | ||
''' | ||
/** | ||
* Generates the content for camvariables.json. | ||
*/ | ||
def String variables(Specification specification) ''' | ||
{ | ||
"input_datatypes": [ | ||
], | ||
"output_datatype": "content_template_output", | ||
"input_groups": [ | ||
{ | ||
"name": "all", | ||
"label": "All variables" | ||
} | ||
], | ||
"output_groups": [ | ||
{ | ||
"name": "content_template_output", | ||
"label": "Outputs" | ||
} | ||
], | ||
"template_input_params": [ | ||
«FOR input : specification.resources.filter[it.specifier.equals("variable")]» | ||
{ | ||
"name": "«input.name»", | ||
"type": "«input.attr("type")»", | ||
"description": "«input.attr("description")»", | ||
"group_name": "all" | ||
} | ||
«ENDFOR» | ||
] | ||
} | ||
''' | ||
def private String attr(Resource resource, String name) { | ||
((resource.value as Dictionary).elements | ||
.findFirst[it.name.equals(name)] | ||
?.value as Text)?.value | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
...dinator/src/main/java/com/rigiresearch/middleware/coordinator/templates/package-info.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,7 @@ | ||
/** | ||
* Contains templates for generating IBM CAM's JSON files. | ||
* @author Miguel Jimenez ([email protected]) | ||
* @version $Id$ | ||
* @since 0.1.0 | ||
*/ | ||
package com.rigiresearch.middleware.coordinator.templates; |