protected void generateKubernetesJson(File kubernetesJson) throws MojoExecutionException {
if (Strings.isNullOrBlank(jsonTemplate)) {
throw new MojoExecutionException("No fabric8.jsonTemplate specified so cannot generate the Kubernetes JSON file!");
} else {
GenerateTemplateDTO config = new GenerateTemplateDTO();
config.setTemplate(jsonTemplate);
// TODO populate properties, project etc.
MavenProject project = getProject();
Properties properties = project.getProperties();
Map<String, Object> variables = new HashMap<>();
Set<Map.Entry<Object, Object>> entries = properties.entrySet();
for (Map.Entry<Object, Object> entry : entries) {
Object key = entry.getKey();
Object value = entry.getValue();
if (key instanceof String) {
String keyText = key.toString();
// lets replace dots so we can access properties directly inside MVEL
keyText = keyText.replace('.', '_');
variables.put(keyText, value);
}
}
config.setLabels(getLabels());
config.setTemplateVariables(variables);
config.setPorts(getPorts());
config.setName(getKubernetesName());
config.setContainerName(getKubernetesContainerName());
config.setReplicaCount(replicaCount);
config.setEnvironmentVariables(getEnvironmentVariables());
List<ClassLoader> classLoaders = Lists.newArrayList(Thread.currentThread().getContextClassLoader(),
getTestClassLoader(),
getClass().getClassLoader(),
TemplateGenerator.class.getClassLoader());