BType listenerType; if ((listenerType = serviceListenerMap.get(plugin)) != null) { for (BLangExpression expr : serviceNode.getAttachedExprs()) { if (!types.isSameType(expr.type, listenerType)) { continue;
for (BLangExpression attachedExpr : bService.getAttachedExprs()) { if (attachedExpr instanceof BLangTypeInit) { BLangTypeInit bListener = (BLangTypeInit) attachedExpr;
KubernetesPluginException { BLangService bService = (BLangService) serviceNode; for (BLangExpression attachedExpr : bService.getAttachedExprs()) { if (attachedExpr instanceof BLangTypeInit) { throw new KubernetesPluginException("Adding @kubernetes:Ingress{} annotation to a service is only " + for (BLangExpression attachedExpr : bService.getAttachedExprs()) { if (attachedExpr instanceof BLangTypeInit) { BLangTypeInit bListener = (BLangTypeInit) attachedExpr;
@Override public void processAnnotation(ServiceNode serviceNode, AnnotationAttachmentNode attachmentNode) throws KubernetesPluginException { BLangService bService = (BLangService) serviceNode; for (BLangExpression attachedExpr : bService.getAttachedExprs()) { // If not anonymous endpoint throw error. if (attachedExpr instanceof BLangSimpleVarRef) { throw new KubernetesPluginException("Adding @kubernetes:Service{} annotation to a service is only " + "supported when the has an anonymous listener"); } } ServiceModel serviceModel = getServiceModelFromAnnotation(attachmentNode); if (isBlank(serviceModel.getName())) { serviceModel.setName(getValidName(serviceNode.getName().getValue()) + SVC_POSTFIX); } // If service annotation port is not empty, then listener port is used for the k8s svc target port while // service annotation port is used for k8s port. // If service annotation port is empty, then listener port is used for both port and target port of the k8s // svc. BLangTypeInit bListener = (BLangTypeInit) bService.getAttachedExprs().get(0); if (serviceModel.getPort() == -1) { serviceModel.setPort(extractPort(bListener)); } serviceModel.setTargetPort(extractPort(bListener)); KubernetesContext.getInstance().getDataHolder().addBListenerToK8sServiceMap(serviceNode.getName().getValue(), serviceModel); }