use of me.snowdrop.istio.api.networking.v1alpha3.GatewayBuilder in project kubernetes by ballerinax.
the class IstioGatewayHandler method generate.
/**
* Generate the artifacts.
* @param gatewayModel The gateway model.
* @throws KubernetesPluginException Error if occurred when writing to file.
*/
private void generate(IstioGatewayModel gatewayModel) throws KubernetesPluginException {
try {
Gateway gateway = new GatewayBuilder().withNewMetadata().withName(gatewayModel.getName()).withNamespace(dataHolder.getNamespace()).withLabels(gatewayModel.getLabels()).withAnnotations(gatewayModel.getAnnotations()).endMetadata().withNewSpec().withSelector(gatewayModel.getSelector()).withServers(populateServers(gatewayModel.getServers())).endSpec().build();
String gatewayContent = SerializationUtils.dumpWithoutRuntimeStateAsYaml(gateway);
KubernetesUtils.writeToFile(gatewayContent, ISTIO_GATEWAY_FILE_POSTFIX + YAML);
} catch (IOException e) {
String errorMessage = "error while generating yaml file for istio gateway: " + gatewayModel.getName();
throw new KubernetesPluginException(errorMessage, e);
}
}
Aggregations