Search in sources :

Example 1 with GatewayBuilder

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);
    }
}
Also used : Gateway(me.snowdrop.istio.api.networking.v1alpha3.Gateway) GatewayBuilder(me.snowdrop.istio.api.networking.v1alpha3.GatewayBuilder) IOException(java.io.IOException) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException)

Aggregations

IOException (java.io.IOException)1 Gateway (me.snowdrop.istio.api.networking.v1alpha3.Gateway)1 GatewayBuilder (me.snowdrop.istio.api.networking.v1alpha3.GatewayBuilder)1 KubernetesPluginException (org.ballerinax.kubernetes.exceptions.KubernetesPluginException)1