use of org.wso2.mi.tooling.security.output.K8SecretYaml in project product-mi-tooling by wso2.
the class IOUtils method writeYamlFile.
/**
* Writes k8 secret .yml file
*
* @param filePath file destination
* @param yaml K8SecretYaml object
*/
public static void writeYamlFile(String filePath, K8SecretYaml yaml) {
DumperOptions options = new DumperOptions();
// Configuration to hide the bean type (org.wso2.mi.tooling.security.output.K8SecretYaml)
Representer representer = new Representer();
representer.addClassTag(K8SecretYaml.class, Tag.MAP);
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setPrettyFlow(true);
Yaml output = new Yaml(representer, options);
try (FileWriter writer = new FileWriter(filePath)) {
output.dump(yaml, writer);
System.out.println("Kubernetes secret file created in " + filePath + " with default name and namespace");
System.out.println("You can change the default values as required before applying.");
} catch (IOException e) {
throw new EncryptionToolException("Error while creating " + filePath);
}
}
Aggregations